nanoc-oo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/nanoc-oo CHANGED
@@ -14,5 +14,4 @@ class CLI < Thor::Group
14
14
  def self.banner; super.sub('cli ','') end
15
15
  end
16
16
 
17
- ARGV << '--help' if ARGV.empty?
18
17
  CLI.start
@@ -112,4 +112,6 @@ end
112
112
  #
113
113
  # FIXME "if" just for specs, to prevent crashes
114
114
  #
115
- Builder.build! root(fake.items, classes), self, fake if fake.items.count > 0
115
+ Builder.build! root(fake.items, classes), self, fake if fake.items.count > 0
116
+
117
+ __END__
@@ -0,0 +1,33 @@
1
+ Feature: command line interface
2
+
3
+ Scenario: nanoc output
4
+ When $ nanoc-oo mysite
5
+ Then the output should contain "Enjoy!"
6
+ When $ nanoc-oo mysite
7
+ Then the output should contain "already exists"
8
+
9
+ Scenario: (no side effect between features I)
10
+ When $ nanoc-oo thesite
11
+ Then the output should contain "Enjoy!"
12
+ Scenario: (no side effect between features II)
13
+ When $ nanoc-oo thesite
14
+ Then the output should contain "Enjoy!"
15
+
16
+ Scenario: create site
17
+ When $ nanoc-oo site
18
+ Then a file named "site/Rules" should exist
19
+ And a file named "site/content/index.html" should exist
20
+
21
+ Scenario: create blank site
22
+ When $ nanoc-oo site --blank
23
+ Then a file named "site/Rules" should exist
24
+ And a file named "site/content/index.html" should not exist
25
+
26
+ Scenario: Rules file is replaced
27
+ When $ nanoc-oo site
28
+ Then the file "site/Rules" should contain "FakeItem"
29
+
30
+ Scenario: it describes actions
31
+ When $ nanoc-oo thesite
32
+ Then the output should contain "force"
33
+ Then the output should contain "classes"
@@ -1,4 +1,3 @@
1
- @wip
2
1
  Feature: move children items
3
2
 
4
3
  Background:
@@ -36,6 +35,10 @@ Feature: move children items
36
35
 
37
36
  class ThatItem < Page
38
37
  GOOD_ID = 'one/*'
38
+
39
+ def route *a
40
+ super.sub 'one', 'two' # more declarative way to do this needed
41
+ end
39
42
  end
40
43
  """
41
44
  When I successfully compile it
@@ -20,4 +20,13 @@ Step '(the )?*( files)? are the only (ones|files) in( the)? "*" directory' do |g
20
20
  missing = ideal - really
21
21
  step 'the following files should exist:', make_table(missing)
22
22
  step 'the following files should not exist:', make_table(extra)
23
- end
23
+ end
24
+
25
+ Step 'the following empty files exist:' do |table|
26
+ table.raw.map{|x|x[0]}.each do |file|
27
+ step 'an empty file named "%s"' % file
28
+ end
29
+ # table is a Cucumber::Ast::Table
30
+ #pending # express the regexp above with the code you wish you had
31
+ end
32
+
@@ -1,3 +1,3 @@
1
1
  module NanocOO
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/nanoc-oo.rb CHANGED
@@ -1,26 +1,71 @@
1
1
  require "nanoc-oo/version"
2
- require 'fileutils'
2
+ require 'thor'
3
+
4
+ THIS_GEM = 'nanoc-oo'
5
+
6
+ class ForcedDataCopier < Thor
7
+ include Thor::Actions
8
+ class_option :force, type: :boolean, default: true
9
+
10
+ desc 'copy',''
11
+ def copy source, dest
12
+ directory source, dest
13
+ end
14
+
15
+ def self.source_root
16
+ Gem.datadir(THIS_GEM)
17
+ end
18
+ end
19
+
20
+ class Force < Thor
21
+ include Thor::Actions
22
+ class_option :force, type: :boolean, default: true
23
+
24
+ def self.remove_file file
25
+ new.remove_file file
26
+ end
27
+ end
28
+
3
29
 
4
30
  module NanocOO
5
- include FileUtils
6
-
7
31
  def create_site name, blank=false
8
- `nanoc create-site #{name}`
32
+ system "nanoc create-site #{name}"
9
33
  wrap name
10
34
  delete_content name if blank
11
35
  end
12
36
 
13
37
  def wrap dir
14
- cp_r wrapper+'/.', dir
38
+ copier = ForcedDataCopier.new.copy 'wrapper', dir
39
+
40
+ #prepend_file join(dir,'Rules'), File.read(join(wrapper,'Rules'))
41
+ #directory 'lib', dir
42
+ #cp_r wrapper+'/.', dir
43
+ # act = Thor::Actions.new :force
44
+ # act.directory wrapper+'/.', dir
45
+ end
46
+
47
+ def data_dir
48
+ Gem.datadir('nanoc-oo')
15
49
  end
16
50
 
17
51
  def wrapper
18
- File.join Gem.datadir('nanoc-oo'), 'wrapper'
52
+ join data_dir, 'wrapper'
19
53
  end
20
54
 
21
55
  def delete_content dir
22
- rm_r Dir.glob File.join(dir,'content','*')
56
+ Dir.glob(join(dir,'content','*')).each do |supposedly_file|
57
+ Force.remove_file supposedly_file
58
+ end
23
59
  end
24
60
 
25
61
  extend self
62
+
63
+ # def source_root
64
+ # File.expand_path(File.dirname(__FILE__))
65
+ # end
26
66
  end
67
+
68
+
69
+ BEGIN{
70
+ def join *a; File.join *a end
71
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-oo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -180,6 +180,7 @@ files:
180
180
  - data/nanoc-oo/wrapper/lib/filter_for.rb
181
181
  - data/nanoc-oo/wrapper/lib/item_class.rb
182
182
  - features/_related_tests.feature
183
+ - features/cli.feature
183
184
  - features/composite_file.example
184
185
  - features/move_children.example
185
186
  - features/paginate_article.example
@@ -195,7 +196,6 @@ files:
195
196
  - nanoc-oo.gemspec
196
197
  - old-README.md
197
198
  - spec/add_item_spec.rb
198
- - spec/cli/all_spec.rb
199
199
  - spec/item_children_and_comiling_spec.rb
200
200
  - spec/items_configuration_spec.rb
201
201
  - spec/layouts_spec.rb
@@ -243,6 +243,7 @@ specification_version: 3
243
243
  summary: nanoc wrapper with OO taste
244
244
  test_files:
245
245
  - features/_related_tests.feature
246
+ - features/cli.feature
246
247
  - features/composite_file.example
247
248
  - features/move_children.example
248
249
  - features/paginate_article.example
@@ -254,7 +255,6 @@ test_files:
254
255
  - features/support/my_extension.rb
255
256
  - features/support/nice_steps.rb
256
257
  - spec/add_item_spec.rb
257
- - spec/cli/all_spec.rb
258
258
  - spec/item_children_and_comiling_spec.rb
259
259
  - spec/items_configuration_spec.rb
260
260
  - spec/layouts_spec.rb
data/spec/cli/all_spec.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'nanoc-oo'
2
-
3
- describe NanocOO do
4
- include FileUtils
5
-
6
- let(:temp){ 'temp' }
7
- let(:site){ "#{temp}/site" }
8
- before :each do
9
- rm_rf temp
10
- end
11
- after :each do
12
- rm_rf temp
13
- end
14
-
15
- it 'creates site with nanoc' do
16
- `nanoc-oo #{site}`
17
- File.should exist join(site,'Rules')
18
- content_files.count.should > 0
19
- end
20
-
21
- it 'creates site with nanoc (w/o cli)' do
22
- NanocOO.create_site site
23
- File.should exist join(site,'Rules')
24
- content_files.count.should > 0
25
- end
26
-
27
- it 'creates site without content if --blank specified' do
28
- `nanoc-oo #{site} --blank`
29
- File.should exist join(site,'Rules')
30
- content_files.count.should == 0
31
- Dir.should exist join(site,'content')
32
- end
33
-
34
- describe 'created site' do
35
- before do
36
- `nanoc-oo #{site}`
37
- end
38
-
39
- it 'is wrapped' do
40
- read(join(site,'Rules')).should == read(join(NanocOO.wrapper,'Rules'))
41
- end
42
-
43
- context 'terminal outputs' do
44
- specify 'nanoc output'
45
- specify 'wrapping info'
46
- specify '--help?'
47
- end if false
48
- end
49
- end
50
-
51
- BEGIN{
52
- def join *a
53
- File.join *a
54
- end
55
- def read *a
56
- File.read *a
57
- end
58
- def content_files
59
- Dir[join(site,'content','*')]
60
- end
61
- }