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.4.0"
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(opts = nil) ⇒ Object
Jekyll Configuration.
-
.site_configuration(site_name = nil, opts_args = nil) ⇒ Object
Jekyll per site configuration This method gets the config files which must be read from jekyll.
- .sources_list ⇒ Object
- .sources_sites ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/mr_hyde.rb', line 21 def config @config end |
.configuration(override = Hash.new) ⇒ Object
Mr.Hyde Configuration
31 32 33 |
# File 'lib/mr_hyde.rb', line 31 def configuration @configuration end |
.source ⇒ Object (readonly)
Returns the value of attribute source.
21 22 23 |
# File 'lib/mr_hyde.rb', line 21 def source @source end |
Class Method Details
.build(opts = {}) ⇒ Object
128 129 130 |
# File 'lib/mr_hyde.rb', line 128 def build(opts = {}) Commands::Build.process opts end |
.built_list ⇒ Object
132 133 134 |
# File 'lib/mr_hyde.rb', line 132 def built_list Site.built_list end |
.configure {|configuration| ... } ⇒ Object
OBSOLETE
25 26 27 28 |
# File 'lib/mr_hyde.rb', line 25 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
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/mr_hyde.rb', line 112 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
87 88 89 |
# File 'lib/mr_hyde.rb', line 87 def destination config['destination'] end |
.draft_list ⇒ Object
140 141 142 |
# File 'lib/mr_hyde.rb', line 140 def draft_list Site.draft_list end |
.has_jekyll_config? ⇒ Boolean
79 80 81 |
# File 'lib/mr_hyde.rb', line 79 def has_jekyll_config? File.exist? File.(File.join(source, @config['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
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mr_hyde.rb', line 65 def jekyll_defaults(site_name = nil) conf = if site_name { 'baseurl' => '/' + site_name, 'destination' => File.join(MrHyde.destination, site_name), 'source' => Pathname.pwd.join(MrHyde.sources_sites, site_name).to_s } else site_name = config['mainsite'] { 'source' => Pathname.pwd.join(site_name).to_s, 'destination' => File.join(MrHyde.destination).to_s } end conf.merge({ 'layouts_dir' => File.join(config['layouts_dir']) }) end |
.logger ⇒ Object
Public: Fetch the logger instance for this Jekyll process.
Returns the LogAdapter instance.
98 99 100 |
# File 'lib/mr_hyde.rb', line 98 def logger @logger ||= LogAdapter.new(Stevenson.new, (ENV['MRHYDE_LOG_LEVEL'] || :info).to_sym) end |
.logger=(writer) ⇒ Object
102 103 104 |
# File 'lib/mr_hyde.rb', line 102 def logger=(writer) @logger = LogAdapter.new(writer) end |
.main_site ⇒ Object
91 92 93 |
# File 'lib/mr_hyde.rb', line 91 def main_site File.join source, config['mainsite'] end |
.main_site_configuration(opts = nil) ⇒ Object
Jekyll Configuration
40 41 42 43 |
# File 'lib/mr_hyde.rb', line 40 def main_site_configuration(opts = nil) # The order is important here, the last one overrides the previous ones site_configuration nil, opts end |
.site_configuration(site_name = nil, opts_args = nil) ⇒ Object
Jekyll per site configuration This method gets the config files which must be read from jekyll. _config.yml < sites/site/_config.yml < override
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mr_hyde.rb', line 49 def site_configuration(site_name = nil, opts_args = nil) clone_opts_args = opts_args.clone if opts_args 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['config']) if has_jekyll_config? opts['config'] << Site.custom_config(site_name, config) if Site.has_custom_config?(site_name, config) opts['config'].concat(Configuration[Configuration::DEFAULTS].config_files(clone_opts_args)) if clone_opts_args and clone_opts_args['config'] jekyll_config.merge(opts) end |
.sources_list ⇒ Object
136 137 138 |
# File 'lib/mr_hyde.rb', line 136 def sources_list Site.sources_list end |
.sources_sites ⇒ Object
83 84 85 |
# File 'lib/mr_hyde.rb', line 83 def sources_sites File.join config['sources_sites'] end |