mr_hyde 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 608e05d085560eb38898a27c5ffcef2dc1220c96
4
- data.tar.gz: 98c227e6bec0118e0c7fa15bb5cbb474ba752262
3
+ metadata.gz: d579e8f6091be07c9c6fd4ac4093a4b0f4996358
4
+ data.tar.gz: 169be6e63526f66e802575c7985fe66d136500b9
5
5
  SHA512:
6
- metadata.gz: 8e8b2dc18dd88fd38cc98a20bbc75d4a769c970e3b14038e1739d814a03b14c11d1427b592a7a8efc10deab4cd740f27ab2a5962b36b238255dee02751effd4c
7
- data.tar.gz: 9df017b5e3c7c9dc2b0c83c3bc964c0d62d67d76f5ba368d24615f224893662c4bc813594948c550a6f93dbfd06864563e74c291a80067c62bbb2c7037051761
6
+ metadata.gz: 4c216b1cbf271516184c0f09abac6a477524f86d96f2e1075395fb00126b9ba7d0042b677a3589d44faa937d33f84b0bf2c97536ad3b5f96fdd2025880545d92
7
+ data.tar.gz: bd02909e7c8d1fa097775ef1cfa1300fa725725ee3c2e5d7299924f30ffdcad4cf19965d9f1c3882b17280609fc4e113508ce97d51d87074f2fc44d41309188b
data/bin/mrhyde CHANGED
@@ -11,6 +11,30 @@ require 'mr_hyde/commands/remove'
11
11
  require 'mr_hyde/commands/serve'
12
12
  require 'mr_hyde/commands/list'
13
13
 
14
+ # Helpers
15
+ def cmd_remove(command)
16
+ command.syntax "remove name[ name ... n] "
17
+ command.description "Remove a nested site within Mr.Hyde folder. By default it removes just the built site."
18
+
19
+ command.alias(:rm)
20
+
21
+ #srm.option "force", "--force", "Don't ask for remove blog"
22
+ command.option "all", "--all", "Remove all built sites."
23
+ command.option "full", "--full", "Remove all built and source site/s. This option can be used with the rest of options."
24
+
25
+ command.action do |args, options|
26
+ MrHyde::Commands::Remove.process(args, options)
27
+ end
28
+ end
29
+
30
+ def cmd_build(command)
31
+ command.option "all", "--all", "Builds main site and nested sites. Not applied when building a nested site."
32
+
33
+ command.action do |args, options|
34
+ options['main'] = true if args.length == 0
35
+ MrHyde::Commands::Build.process args, options
36
+ end
37
+ end
14
38
 
15
39
  Mercenary.program(:mrhyde) do |p|
16
40
  p.version MrHyde::VERSION
@@ -45,29 +69,14 @@ Mercenary.program(:mrhyde) do |p|
45
69
  end
46
70
 
47
71
  site.command(:remove) do |srm|
48
- srm.syntax "remove name[ name ... n] "
49
- srm.description "Remove a Jekyll site when on Mr.Hyde root folder. By default it removes just the built site."
50
-
51
- srm.alias(:rm)
52
-
53
- #srm.option "force", "--force", "Don't ask for remove blog"
54
- srm.option "all", "--all", "Remove all built sites."
55
- srm.option "full", "--full", "Remove all built and source site/s. This option can be used with the rest of options."
56
-
57
- srm.action do |args, options|
58
- MrHyde::Commands::Remove.process(args, options)
59
- end
72
+ cmd_remove srm
60
73
  end
61
74
 
62
75
  site.command(:build) do |sbuild|
63
76
  sbuild.syntax "build name[ name ... n] "
64
77
  sbuild.description "Build the named site or sites. By default if no name is indicated then all sites will be build."
65
78
 
66
- sbuild.option "all", "--all", "Build all nested sites"
67
-
68
- sbuild.action do |args, options|
69
- MrHyde::Commands::Build.process args, options
70
- end
79
+ cmd_build sbuild
71
80
  end
72
81
  end
73
82
 
@@ -92,15 +101,9 @@ Mercenary.program(:mrhyde) do |p|
92
101
 
93
102
 
94
103
  p.command(:build) do |build|
95
- build.syntax "build"
104
+ build.syntax "build [site name]"
96
105
  build.description "Build the main site"
97
-
98
- build.option "full", "--full", "Builds main site and nested sites."
99
-
100
- build.action do |args, options|
101
- options['main'] = true
102
- MrHyde::Commands::Build.process args, options
103
- end
106
+ cmd_build build
104
107
  end
105
108
 
106
109
  p.command(:list) do |list|
@@ -108,11 +111,16 @@ Mercenary.program(:mrhyde) do |p|
108
111
  list.description "Shows a list of all sites within sources."
109
112
 
110
113
  list.option "built", "--built", "Shows a list of built sites."
114
+ list.option "draft", "--drafts", "Shows a list of sites not built."
111
115
 
112
116
  list.action do |args, options|
113
117
  MrHyde::Commands::List.process options
114
118
  end
115
119
  end
120
+
121
+ p.command(:remove) do |rm|
122
+ cmd_remove rm
123
+ end
116
124
 
117
125
  p.action do |args, options|
118
126
  if args.empty?
@@ -13,7 +13,7 @@ module MrHyde
13
13
  # Options
14
14
  def process(args, opts = {})
15
15
  MrHyde::Site.build args, opts
16
- MrHyde.logger.info "Built process is fisished, you can look the result in '#{MrHyde.destination}' folder"
16
+ MrHyde.logger.info "Built process is finished, you can see the result in '#{MrHyde.destination}' folder"
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,4 @@
1
1
  require "mr_hyde/command"
2
- require "mr_hyde/site"
3
2
 
4
3
  module MrHyde
5
4
  module Commands
@@ -11,6 +10,8 @@ module MrHyde
11
10
 
12
11
  if opts['built']
13
12
  show_built_sites
13
+ elsif opts['draft']
14
+ show_draft_sites
14
15
  else
15
16
  show_sources_sites
16
17
  end
@@ -18,14 +19,22 @@ module MrHyde
18
19
 
19
20
  def show_built_sites
20
21
  if File.exist? MrHyde.destination
21
- show_list "Built sites (#{MrHyde.destination})", Site.built_list
22
+ show_list "Built sites (#{MrHyde.destination})", MrHyde.built_list
22
23
  else
23
24
  MrHyde.logger.warn "Still there is not a built site"
24
25
  end
25
26
  end
26
27
 
28
+ def show_draft_sites
29
+ if File.exist? MrHyde.destination
30
+ show_list "Draft sites (#{MrHyde.sources_sites})", MrHyde.draft_list
31
+ else
32
+ show_sources_sites
33
+ end
34
+ end
35
+
27
36
  def show_sources_sites
28
- show_list "Source Sites (#{MrHyde.sources_sites})", Site.sources_list
37
+ show_list "Source Sites (#{MrHyde.sources_sites})", MrHyde.sources_list
29
38
  end
30
39
 
31
40
  def show_list(title, list)
@@ -6,7 +6,11 @@ module MrHyde
6
6
  class Remove < MrHyde::Command
7
7
  class << self
8
8
  def process(args, opts = {})
9
- Site.remove args, opts
9
+ if args.length == 0
10
+ MrHyde.logger.warn("A site name must be typed. You can see a list of nested sites using the 'list' command.")
11
+ else
12
+ Site.remove args, opts
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -28,8 +28,10 @@ module MrHyde
28
28
 
29
29
  begin
30
30
  files.each do |config_file|
31
- new_config = read_config_file(config_file)
32
- configuration = Jekyll::Utils.deep_merge_hashes(configuration, new_config)
31
+ if File.exist? config_file
32
+ new_config = read_config_file(config_file)
33
+ configuration = Jekyll::Utils.deep_merge_hashes(configuration, new_config)
34
+ end
33
35
  end
34
36
  rescue ArgumentError => err
35
37
  MrHyde.logger.warn "WARNING:", "Error reading configuration. " +
data/lib/mr_hyde/site.rb CHANGED
@@ -91,20 +91,25 @@ module MrHyde
91
91
  build_main_site(opts) unless File.exist? MrHyde.destination
92
92
 
93
93
  if opts["all"]
94
- build_sites list(MrHyde.sources_sites), opts
94
+ build_sites sources_list, opts
95
95
  elsif args.kind_of? Array
96
96
  build_sites args, opts
97
97
  elsif args.kind_of? String
98
98
  build_site args, opts
99
99
  end
100
100
  else
101
- # Fetching the list of built sites to rebuild again once the main site has been built
102
- if File.exist? MrHyde.destination
103
- nested_sites = built_list
101
+ if opts["all"]
104
102
  build_main_site(opts)
105
- build_sites nested_sites, opts
103
+ build_sites sources_list, opts
106
104
  else
107
- build_main_site(opts)
105
+ # Fetching the list of built sites to rebuild again once the main site has been built
106
+ if File.exist? MrHyde.destination
107
+ nested_sites = built_list
108
+ build_main_site(opts)
109
+ build_sites nested_sites, opts
110
+ else
111
+ build_main_site(opts)
112
+ end
108
113
  end
109
114
  end
110
115
  rescue Exception => e
@@ -134,6 +139,16 @@ module MrHyde
134
139
  end
135
140
  end
136
141
 
142
+ def draft_list
143
+ return sources_list unless File.exist? MrHyde.destination
144
+ sources = sources_list
145
+ builts = built_list
146
+
147
+ sources.reject do |site|
148
+ site if builts.include?(site)
149
+ end
150
+ end
151
+
137
152
  def exist?(name, opts)
138
153
  File.exist? File.join(@source, name)
139
154
  end
@@ -1,3 +1,3 @@
1
1
  module MrHyde
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/mr_hyde.rb CHANGED
@@ -74,7 +74,7 @@ module MrHyde
74
74
  end
75
75
 
76
76
  def has_jekyll_config?
77
- File.exist? File.expand_path(source, @config['jekyll_config'])
77
+ File.exist? File.expand_path(File.join(source, @config['jekyll_config']))
78
78
  end
79
79
 
80
80
  def sources
@@ -138,6 +138,10 @@ module MrHyde
138
138
  Site.sources_list
139
139
  end
140
140
 
141
+ def draft_list
142
+ Site.draft_list
143
+ end
144
+
141
145
  private
142
146
 
143
147
  def preserve_source_location?(path, opts)
@@ -4,7 +4,7 @@ title: "Welcome to Mr. Hyde!"
4
4
  date: <%= Time.now.strftime('%Y-%m-%d %H:%M:%S') %>
5
5
  categories: mrhyde jekyll update
6
6
  ---
7
- ![Dr. Jekyll and Mr. Hyde]({{ site.baseurl }}/assets/dr_jekyll_and_mr_hyde_poster.png)
7
+ ![Dr. Jekyll and Mr. Hyde]({{ site.baseurl }}/assets/dr_jekyll_and_mr_hyde_poster.jpg)
8
8
 
9
9
  You’ll find this post in your `sources/_sites/sample-site/_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `mrhyde build`, which build your site, and after `mrhyde serve`, which launches a web server.
10
10
 
data/spec/list_spec.rb CHANGED
@@ -11,27 +11,47 @@ describe "Mr. Hyde Listing" do
11
11
  @defaults = MrHyde::Configuration::DEFAULTS
12
12
  @tmp_dir = Dir.mktmpdir('mrhyde_new_test')
13
13
  Dir.chdir(@tmp_dir)
14
- MrHyde.create @site_name
14
+ MrHyde.create @site_name, { 'blank' => true }
15
15
  Dir.chdir(@site_name)
16
16
  end
17
17
 
18
18
  after do
19
+ Dir.chdir(@tmp_dir)
19
20
  FileUtils.remove_dir(@site_name) if File.exist? @site_name
20
21
  end
21
22
 
23
+ def create_sites(sites_number)
24
+ sites_name = []
25
+ sites_number.times { |i| sites_name << "#{@nested_site_name}_#{i}" }
26
+ MrHyde::Site.create sites_name, { 'blank' => true }
27
+ end
28
+
29
+ def build_sites(sites_number = 0)
30
+ entries = fetch_entries(MrHyde.sources_sites)
31
+ sites_number = entries.length if sites_number == 0
32
+
33
+ MrHyde::Site.build entries[0..sites_number - 1]
34
+ end
35
+
22
36
  def fetch_entries(path)
23
37
  entries = Dir.entries path
24
38
  entries.reject{ |entry| entry == '.' or entry == '..' }
25
39
  end
26
40
 
27
41
  it "can list all sites in sources" do
28
- MrHyde.sources_list.length.must_be :==, fetch_entries(MrHyde.sources_sites).length
42
+ create_sites(5)
43
+ MrHyde.sources_list.length.must_be :==, 5
29
44
  end
30
45
 
31
46
  it "can list all built sites" do
32
- sources = MrHyde.sources_list
33
- entries = MrHyde::Site.build [], { 'all' => true }
34
- entries.select! { |entry| entry if sources.include? entry }
35
- MrHyde.built_list.length.must_be :==, entries.length
47
+ create_sites(5)
48
+ build_sites(3)
49
+ MrHyde.built_list.length.must_be :==, 3
50
+ end
51
+
52
+ it "can list all draft sites" do
53
+ create_sites(5)
54
+ build_sites(3)
55
+ MrHyde.draft_list.length.must_be :==, 2
36
56
  end
37
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mr_hyde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Enrique Arias Cervero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,7 +132,7 @@ files:
132
132
  - lib/subsite_template/_config.yml
133
133
  - lib/subsite_template/_posts/0000-00-00-welcome-to-mr-hyde.markdown.erb
134
134
  - lib/subsite_template/about.md
135
- - lib/subsite_template/assets/dr_jekyll_and_mr_hyde_poster.png
135
+ - lib/subsite_template/assets/dr_jekyll_and_mr_hyde_poster.jpg
136
136
  - lib/subsite_template/feed.xml
137
137
  - lib/subsite_template/index.html
138
138
  - mr_hyde.gemspec