Module: MrHyde
- Defined in:
- lib/mr_hyde.rb,
lib/mr_hyde/site.rb,
lib/mr_hyde/command.rb,
lib/mr_hyde/version.rb,
lib/mr_hyde/commands/new.rb,
lib/mr_hyde/commands/list.rb,
lib/mr_hyde/configuration.rb,
lib/mr_hyde/commands/build.rb,
lib/mr_hyde/commands/serve.rb,
lib/mr_hyde/extensions/new.rb,
lib/mr_hyde/commands/remove.rb
Defined Under Namespace
Modules: Commands, Extensions Classes: Command, Configuration, Site
Constant Summary collapse
- VERSION =
"0.2.1"
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.configuration(override = Hash.new) ⇒ Object
Mr.Hyde Configuration.
-
.source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
- .build(opts = {}) ⇒ Object
- .built_list ⇒ Object
-
.configure {|configuration| ... } ⇒ Object
OBSOLETE.
-
.create(args, opts = {}) ⇒ Object
Creates the folders for the sources and destination, by default will be created under root folder.
- .destination ⇒ Object
- .draft_list ⇒ Object
- .has_jekyll_config? ⇒ Boolean
-
.jekyll_defaults(site_name = nil) ⇒ Object
If no site name is passed in then the configuration defaults are set for the main site.
-
.logger ⇒ Object
Public: Fetch the logger instance for this Jekyll process.
- .logger=(writer) ⇒ Object
- .main_site ⇒ Object
-
.main_site_configuration ⇒ Object
Jekyll Configuration.
-
.site_configuration(site_name = nil) ⇒ Object
Jekyll per site configuration This method gets the config files which must be read from jekyll.
- .sources ⇒ Object
- .sources_list ⇒ Object
- .sources_sites ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/mr_hyde.rb', line 20 def config @config end |
.configuration(override = Hash.new) ⇒ Object
Mr.Hyde Configuration
30 31 32 |
# File 'lib/mr_hyde.rb', line 30 def configuration @configuration end |
.source ⇒ Object (readonly)
Returns the value of attribute source.
20 21 22 |
# File 'lib/mr_hyde.rb', line 20 def source @source end |
Class Method Details
.build(opts = {}) ⇒ Object
129 130 131 |
# File 'lib/mr_hyde.rb', line 129 def build(opts = {}) Commands::Build.process opts end |
.built_list ⇒ Object
133 134 135 |
# File 'lib/mr_hyde.rb', line 133 def built_list Site.built_list end |
.configure {|configuration| ... } ⇒ Object
OBSOLETE
24 25 26 27 |
# File 'lib/mr_hyde.rb', line 24 def configure self.configuration ||= Configuration.new yield(configuration) if block_given? end |
.create(args, opts = {}) ⇒ Object
Creates the folders for the sources and destination, by default will be created under root folder. Copies the default _config.yml for all sites, in root folder.
Throws a SystemExit exception
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/mr_hyde.rb', line 113 def create(args, opts = {}) args = [args] if args.kind_of? String new_site_path = File.(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_site_path if preserve_source_location?(new_site_path, opts) raise SystemExit.new "#{new_site_path} exists and is not empty." end if opts['blank'] create_blank_site new_site_path else create_sample_files new_site_path end new_site_path end |
.destination ⇒ Object
88 89 90 |
# File 'lib/mr_hyde.rb', line 88 def destination config['destination'] end |
.draft_list ⇒ Object
141 142 143 |
# File 'lib/mr_hyde.rb', line 141 def draft_list Site.draft_list end |
.has_jekyll_config? ⇒ Boolean
76 77 78 |
# File 'lib/mr_hyde.rb', line 76 def has_jekyll_config? File.exist? File.(File.join(source, @config['jekyll_config'])) end |
.jekyll_defaults(site_name = nil) ⇒ Object
If no site name is passed in then the configuration defaults are set for the main site
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mr_hyde.rb', line 62 def jekyll_defaults(site_name = nil) conf = if site_name { 'baseurl' => '/' + site_name, 'destination' => File.join(MrHyde.destination, site_name), 'source' => File.join(MrHyde.sources_sites, site_name) } else site_name = config['mainsite'] { 'source' => File.join(sources, site_name), 'destination' => File.join(MrHyde.destination) } end conf.merge({ 'layouts' => File.join(MrHyde.sources, config['layouts']) }) end |
.logger ⇒ Object
Public: Fetch the logger instance for this Jekyll process.
Returns the LogAdapter instance.
99 100 101 |
# File 'lib/mr_hyde.rb', line 99 def logger @logger = LogAdapter.new(Stevenson.new, (ENV['MRHYDE_LOG_LEVEL'] || :info).to_sym) end |
.logger=(writer) ⇒ Object
103 104 105 |
# File 'lib/mr_hyde.rb', line 103 def logger=(writer) @logger = LogAdapter.new(writer) end |
.main_site ⇒ Object
92 93 94 |
# File 'lib/mr_hyde.rb', line 92 def main_site File.join source, sources, config['mainsite'] end |
.main_site_configuration ⇒ Object
Jekyll Configuration
39 40 41 42 |
# File 'lib/mr_hyde.rb', line 39 def main_site_configuration # The order is important here, the last one overrides the previous ones site_configuration nil end |
.site_configuration(site_name = nil) ⇒ Object
Jekyll per site configuration This method gets the config files which must be read from jekyll. _config.yml < sources/sites/site/_config.yml < override
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mr_hyde.rb', line 48 def site_configuration(site_name = nil) jekyll_config = jekyll_defaults(site_name) site_name ||= config['mainsite'] opts = {} # The order is important here, the last one overrides the previous one opts['config'] = [] opts['config'] << Jekyll.sanitized_path(source, config['jekyll_config']) if has_jekyll_config? opts['config'] << Site.custom_config(site_name, config) if Site.has_custom_config?(site_name, config) jekyll_config.merge(opts) end |
.sources ⇒ Object
80 81 82 |
# File 'lib/mr_hyde.rb', line 80 def sources config['sources'] end |
.sources_list ⇒ Object
137 138 139 |
# File 'lib/mr_hyde.rb', line 137 def sources_list Site.sources_list end |
.sources_sites ⇒ Object
84 85 86 |
# File 'lib/mr_hyde.rb', line 84 def sources_sites File.join config['sources'], config['sources_sites'] end |