tony 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +37 -0
- data/lib/tony/tony.rb +6 -1
- data/lib/tony/version.rb +1 -1
- data/spec/generator_spec.rb +26 -38
- data/spec/tony_spec.rb +8 -4
- metadata +4 -3
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
tony
|
2
|
+
====
|
3
|
+
|
4
|
+
tony is a generator for ruby projects.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
```
|
9
|
+
gem install tony
|
10
|
+
```
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
```
|
16
|
+
$ tony
|
17
|
+
Supported Generators
|
18
|
+
heroku
|
19
|
+
rspec
|
20
|
+
sinatra
|
21
|
+
sinatra and rspec
|
22
|
+
```
|
23
|
+
|
24
|
+
```
|
25
|
+
$ tony rspec sinatra heroku
|
26
|
+
create .gems
|
27
|
+
create Rakefile
|
28
|
+
create spec/helper.rb
|
29
|
+
create config.ru
|
30
|
+
create lib/application.rb
|
31
|
+
create lib/configuration.rb
|
32
|
+
create public/scripts/main.js
|
33
|
+
create public/styles/main.css
|
34
|
+
create views/index.erb
|
35
|
+
create views/layout.erb
|
36
|
+
create spec/application_spec.rb
|
37
|
+
```
|
data/lib/tony/tony.rb
CHANGED
@@ -19,7 +19,12 @@ module Tony
|
|
19
19
|
if ARGV.size == 0
|
20
20
|
puts 'Supported Generators'
|
21
21
|
generators.each do |generator|
|
22
|
-
puts generator.name
|
22
|
+
puts generator.name unless generator.combination
|
23
|
+
end
|
24
|
+
puts
|
25
|
+
puts 'Combination Generators'
|
26
|
+
generators.each do |generator|
|
27
|
+
puts generator.name if generator.combination
|
23
28
|
end
|
24
29
|
end
|
25
30
|
used_generators.each do |used_generator|
|
data/lib/tony/version.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
@@ -47,62 +47,50 @@ describe Tony::Generator do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe ".generate" do
|
50
|
-
|
51
|
-
test_file = File.join(@test_directory, 'test.file')
|
52
|
-
generator = Tony::Generator.new { |options|
|
50
|
+
before :each do
|
51
|
+
@test_file = File.join(@test_directory, 'test.file')
|
52
|
+
@generator = Tony::Generator.new { |options|
|
53
53
|
options.files = {
|
54
|
-
test_file => ''
|
54
|
+
@test_file => ''
|
55
55
|
}
|
56
|
-
}
|
57
|
-
|
56
|
+
}
|
57
|
+
@generator.stub!(:puts)
|
58
|
+
end
|
59
|
+
it "creates files if they don't exist" do
|
60
|
+
@generator.generate
|
61
|
+
File.exist?(@test_file).should == true
|
58
62
|
end
|
59
63
|
|
60
64
|
it "creates all directories below the file if they don't exist" do
|
61
65
|
non_existent_directory = File.join(@test_directory, 'non_existent_directory')
|
62
|
-
test_file = File.join(non_existent_directory, 'test.file')
|
63
|
-
generator =
|
64
|
-
|
65
|
-
test_file => ''
|
66
|
-
}
|
67
|
-
}.generate
|
66
|
+
@test_file = File.join(non_existent_directory, 'test.file')
|
67
|
+
@generator.files[@test_file] = ''
|
68
|
+
@generator.generate
|
68
69
|
File.directory?(non_existent_directory).should == true
|
69
|
-
File.exist?(test_file).should == true
|
70
|
+
File.exist?(@test_file).should == true
|
70
71
|
end
|
71
72
|
|
72
73
|
it "writes the specified text to the file" do
|
73
|
-
test_file = File.join(@test_directory, 'test.file')
|
74
74
|
file_contents = "this is some text"
|
75
|
-
generator =
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
}.generate
|
80
|
-
File.read(test_file).should == file_contents + "\n"
|
75
|
+
@generator.files[@test_file] = file_contents
|
76
|
+
@generator.generate
|
77
|
+
File.read(@test_file).should == file_contents + "\n"
|
81
78
|
end
|
82
79
|
|
83
80
|
it "appends the specified text to the file if it exists" do
|
84
81
|
test_file = File.join(@test_directory, 'test.file')
|
85
|
-
generator =
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
generator.generate
|
91
|
-
generator.generate
|
92
|
-
File.read(test_file).should == "hello\nhello\n"
|
82
|
+
@generator.files[@test_file] = 'hello'
|
83
|
+
@generator.generate
|
84
|
+
@generator.generate
|
85
|
+
File.read(@test_file).should == "hello\nhello\n"
|
93
86
|
end
|
94
87
|
|
95
88
|
it "outputs information about whether the file was created or appended" do
|
96
|
-
test_file = File.join(@test_directory, 'test.file')
|
97
|
-
generator
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
}
|
102
|
-
generator.should_receive(:puts).with("create #{test_file}")
|
103
|
-
generator.generate
|
104
|
-
generator.should_receive(:puts).with("append #{test_file}")
|
105
|
-
generator.generate
|
89
|
+
@test_file = File.join(@test_directory, 'test.file')
|
90
|
+
@generator.should_receive(:puts).with("create #{@test_file}")
|
91
|
+
@generator.generate
|
92
|
+
@generator.should_receive(:puts).with("append #{@test_file}")
|
93
|
+
@generator.generate
|
106
94
|
end
|
107
95
|
end
|
108
96
|
end
|
data/spec/tony_spec.rb
CHANGED
@@ -31,12 +31,16 @@ describe Tony do
|
|
31
31
|
Tony.generate
|
32
32
|
end
|
33
33
|
|
34
|
-
it "outputs a list of generators
|
34
|
+
it "outputs a list of generators" do
|
35
35
|
ARGV = []
|
36
36
|
generator = mock_generator('generator')
|
37
|
-
|
38
|
-
Tony.
|
39
|
-
Tony.should_receive(:puts).with('
|
37
|
+
combination_generator = mock_generator('combination generator', ['generator'])
|
38
|
+
Tony.stub!(:generators).and_return([generator, combination_generator])
|
39
|
+
Tony.should_receive(:puts).with('Supported Generators').ordered
|
40
|
+
Tony.should_receive(:puts).with('generator').ordered
|
41
|
+
Tony.should_receive(:puts).ordered
|
42
|
+
Tony.should_receive(:puts).with('Combination Generators').ordered
|
43
|
+
Tony.should_receive(:puts).with('combination generator').ordered
|
40
44
|
Tony.generate
|
41
45
|
end
|
42
46
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andrew Vos
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-05-
|
17
|
+
date: 2011-05-11 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- .rspec
|
45
45
|
- Gemfile
|
46
46
|
- Gemfile.lock
|
47
|
+
- README.md
|
47
48
|
- Rakefile
|
48
49
|
- bin/tony
|
49
50
|
- lib/tony.rb
|