I'm wondering how it may be possible to access Nanoc's variables (e.g. @items
, @config
, etc.) from a Rakefile.
I have a file called nanoc.yaml
that has data like this in it:
products:
ce:
name: 'Community Edition'
ee:
name: 'Enterprise Edition'
I'd like to be able to access this in the Rakefile so I have a "single source of truth" that can be accessed from within the Nanoc site as well as the Rakefile which pulls down some documentation. In the Nanoc site you can access these with @config[:products]
, for example, but not in the Rakefile.
Do I need to include
something from Nanoc in the Rakefile?
Caution: This answer deals with a private API!
You can create a site using the SiteLoader
:
site = Nanoc::Int::SiteLoader.new.new_from_cwd
The site has a config:
site.config[:products][:ce][:name]
# => Community Edition
Again, this is part of a private API (for the time being, at least), so the code above might break in a future release.