jackdempsey-beet 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ tmp
2
+ *output
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.email = "jack.dempsey@gmail.com"
10
10
  gem.homepage = "http://github.com/jackdempsey/beet"
11
11
  gem.authors = ["Jack Dempsey"]
12
- gem.add_dependency "wycats-thor"
12
+ gem.add_dependency "wycats-thor", "= 0.11.5"
13
13
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
14
  end
15
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/beet.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{beet}
5
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Jack Dempsey"]
9
- s.date = %q{2009-07-18}
12
+ s.date = %q{2009-08-20}
10
13
  s.default_executable = %q{beet}
11
14
  s.email = %q{jack.dempsey@gmail.com}
12
15
  s.executables = ["beet"]
@@ -15,13 +18,19 @@ Gem::Specification.new do |s|
15
18
  "README.rdoc"
16
19
  ]
17
20
  s.files = [
18
- "LICENSE",
21
+ ".gitignore",
22
+ "LICENSE",
19
23
  "README.rdoc",
20
24
  "Rakefile",
21
25
  "TODO",
22
26
  "VERSION",
23
27
  "beet.gemspec",
24
28
  "bin/beet",
29
+ "features/generating.feature",
30
+ "features/step_definitions/beet_steps.rb",
31
+ "features/step_definitions/common_steps.rb",
32
+ "features/support/common.rb",
33
+ "features/support/env.rb",
25
34
  "lib/beet.rb",
26
35
  "lib/beet/capistrano.rb",
27
36
  "lib/beet/execution.rb",
@@ -57,7 +66,7 @@ Gem::Specification.new do |s|
57
66
  s.homepage = %q{http://github.com/jackdempsey/beet}
58
67
  s.rdoc_options = ["--charset=UTF-8"]
59
68
  s.require_paths = ["lib"]
60
- s.rubygems_version = %q{1.3.4}
69
+ s.rubygems_version = %q{1.3.5}
61
70
  s.summary = %q{A gem to help with easily generating projects}
62
71
  s.test_files = [
63
72
  "test/executor_test.rb",
@@ -70,11 +79,11 @@ Gem::Specification.new do |s|
70
79
  s.specification_version = 3
71
80
 
72
81
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
73
- s.add_runtime_dependency(%q<wycats-thor>, [">= 0"])
82
+ s.add_runtime_dependency(%q<wycats-thor>, ["= 0.11.5"])
74
83
  else
75
- s.add_dependency(%q<wycats-thor>, [">= 0"])
84
+ s.add_dependency(%q<wycats-thor>, ["= 0.11.5"])
76
85
  end
77
86
  else
78
- s.add_dependency(%q<wycats-thor>, [">= 0"])
87
+ s.add_dependency(%q<wycats-thor>, ["= 0.11.5"])
79
88
  end
80
89
  end
data/bin/beet CHANGED
@@ -26,14 +26,14 @@ class BeetRunner < Thor
26
26
  map "--display" => :display
27
27
 
28
28
  desc 'generate [app_name]', "the main app generate method"
29
- method_options :recipes => :string, :gems => :string, :template => :string, :save => :string, :use => :string
29
+ method_options %w(recipes -r) => :string, %w(gems -g) => :string, %w(template -t) => :string, %w(save -s) => :string, %w(use -u) => :string
30
30
  def generate(app_name, project_type=:rails)
31
31
  executor = Beet::Executor.new(app_name, options.merge('project_type' => project_type))
32
32
  executor.start
33
33
  end
34
34
 
35
35
  desc 'just_recipe', "when you just need a recipe"
36
- method_options :recipes => :string, :gems => :string, :save => :string, :use => :string
36
+ method_options %w(recipes -r) => :string, %w(gems -g) => :string, %w(save -s) => :string, %w(use -u) => :string
37
37
  def just_recipe(app_name='.')
38
38
  executor = Beet::Executor.new(app_name, options.merge('generate' => false))
39
39
  executor.start
@@ -54,7 +54,7 @@ class BeetRunner < Thor
54
54
  end
55
55
 
56
56
  desc 'display', "Display the code for the recipes/templates"
57
- method_options :recipes => :string, :template => :string
57
+ method_options %w(recipes -r) => :string, %w(template -t) => :string
58
58
  def display(app_name='.')
59
59
  executor = Beet::Executor.new(app_name,options.merge('generate' => false, 'display' => true))
60
60
  executor.start
@@ -0,0 +1,24 @@
1
+ Feature: Generating Projects
2
+ In order to reduce the time needed to build new rails apps
3
+ As a developer
4
+ I want to generate apps with beet
5
+
6
+ Background:
7
+ Given this will run inside a clean "generated_output" directory
8
+
9
+ Scenario: Generating a rails app
10
+ When I run local executable "beet" with arguments "-g rails_app"
11
+ Then folder "rails_app" is created
12
+ And "rails_app" should be a rails app
13
+
14
+ Scenario: Generating a rails app with rails/git recipe
15
+ When I run local executable "beet" with arguments "-g rails_app -r rails/git"
16
+ Then folder "rails_app" is created
17
+ And "rails_app" should be a rails app
18
+ And folder "rails_app/.git" is created
19
+
20
+ Scenario: Generating a rails app then running rails/git recipe separately
21
+ When I run local executable "beet" with arguments "-g rails_app"
22
+ And inside "rails_app" I run local executable "beet" with arguments "-j -r rails/git"
23
+ And folder "rails_app/.git" is created"
24
+
@@ -0,0 +1,7 @@
1
+ Then /^"(.*)" should be a rails app$/ do |directory|
2
+ File.exists?(File.join(@active_project_folder, 'app'))
3
+ File.exists?(File.join(@active_project_folder, 'config'))
4
+ File.exists?(File.join(@active_project_folder, 'db'))
5
+ File.exists?(File.join(@active_project_folder, 'public'))
6
+ File.exists?(File.join(@active_project_folder, 'vendor'))
7
+ end
@@ -0,0 +1,172 @@
1
+ Given /this will run inside a clean "(.*)" directory/ do |directory|
2
+ @active_project_folder = File.expand_path File.join(File.dirname(__FILE__), '..', '..', directory)
3
+ FileUtils.rm_rf @active_project_folder
4
+ FileUtils.mkdir_p @active_project_folder
5
+ end
6
+
7
+ Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
8
+ ENV[env_var] = value
9
+ end
10
+
11
+ Given /"(.*)" folder is deleted/ do |folder|
12
+ in_project_folder { FileUtils.rm_rf folder }
13
+ end
14
+
15
+ When /^inside "(.*)" I run local executable "(.*)" with arguments "(.*)"$/ do |directory, executable, arguments|
16
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
17
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
18
+ in_project_subfolder(directory) do
19
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
20
+ end
21
+ end
22
+
23
+ When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
24
+ @stdout = StringIO.new
25
+ in_project_folder do
26
+ if Object.const_defined?("APP_ROOT")
27
+ APP_ROOT.replace(FileUtils.pwd)
28
+ else
29
+ APP_ROOT = FileUtils.pwd
30
+ end
31
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
32
+ end
33
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
34
+ @stdout.rewind
35
+ f << @stdout.read
36
+ end
37
+ end
38
+
39
+ When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
40
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
41
+ in_project_folder do
42
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
43
+ end
44
+ end
45
+
46
+ When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
47
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
48
+ in_project_folder do
49
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
50
+ end
51
+ end
52
+
53
+ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
54
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
55
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
56
+ in_project_folder do
57
+ `ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}`
58
+ end
59
+ end
60
+
61
+ When /^I invoke task "rake (.*)"/ do |task|
62
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
63
+ in_project_folder do
64
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
65
+ end
66
+ end
67
+
68
+ Then /^folder "(.*)" (is|is not) created/ do |folder, is|
69
+ in_project_folder do
70
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
71
+ end
72
+ end
73
+
74
+ Then /^file "(.*)" (is|is not) created/ do |file, is|
75
+ in_project_folder do
76
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
77
+ end
78
+ end
79
+
80
+ Then /^file with name matching "(.*)" is created/ do |pattern|
81
+ in_project_folder do
82
+ Dir[pattern].should_not be_empty
83
+ end
84
+ end
85
+
86
+ Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
87
+ in_project_folder do
88
+ actual_output = File.read(file)
89
+ (does == 'does') ?
90
+ actual_output.should(match(/#{regex}/)) :
91
+ actual_output.should_not(match(/#{regex}/))
92
+ end
93
+ end
94
+
95
+ Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
96
+ File.exists?(gem_file).should be_true
97
+ File.exists?(project_file).should be_true
98
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
99
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
100
+ project_file_contents.should == gem_file_contents
101
+ end
102
+
103
+ Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
104
+ actual_output = File.read(@stdout)
105
+ does_invoke == "does" ?
106
+ actual_output.should(match(/dependency\s+#{generator}/)) :
107
+ actual_output.should_not(match(/dependency\s+#{generator}/))
108
+ end
109
+
110
+ Then /I should see help option "(.*)"/ do |opt|
111
+ actual_output = File.read(@stdout)
112
+ actual_output.should match(/#{opt}/)
113
+ end
114
+
115
+ Then /^I should see$/ do |text|
116
+ actual_output = File.read(@stdout)
117
+ actual_output.should contain(text)
118
+ end
119
+
120
+ Then /^I should not see$/ do |text|
121
+ actual_output = File.read(@stdout)
122
+ actual_output.should_not contain(text)
123
+ end
124
+
125
+ Then /^I should see exactly$/ do |text|
126
+ actual_output = File.read(@stdout)
127
+ actual_output.should == text
128
+ end
129
+
130
+ Then /^I should see all (\d+) tests pass/ do |expected_test_count|
131
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
132
+ actual_output = File.read(@stdout)
133
+ actual_output.should match(expected)
134
+ end
135
+
136
+ Then /^I should see all (\d+) examples pass/ do |expected_test_count|
137
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
138
+ actual_output = File.read(@stdout)
139
+ actual_output.should match(expected)
140
+ end
141
+
142
+ Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
143
+ in_project_folder do
144
+ yaml = eval yaml
145
+ YAML.load(File.read(file)).should == yaml
146
+ end
147
+ end
148
+
149
+ Then /^Rakefile can display tasks successfully/ do
150
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
151
+ in_project_folder do
152
+ system "rake -T > #{@stdout} 2> #{@stdout}"
153
+ end
154
+ actual_output = File.read(@stdout)
155
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
156
+ end
157
+
158
+ Then /^task "rake (.*)" is executed successfully/ do |task|
159
+ @stdout.should_not be_nil
160
+ actual_output = File.read(@stdout)
161
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
162
+ actual_output.should_not match(/Error/i)
163
+ end
164
+
165
+ Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
166
+ in_project_folder do
167
+ gem_file = Dir["pkg/*.gem"].first
168
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
169
+ spec_value = gem_spec.send(key.to_sym)
170
+ spec_value.to_s.should match(/#{regex}/)
171
+ end
172
+ end
@@ -0,0 +1,33 @@
1
+ module CommonHelpers
2
+ def in_tmp_folder(&block)
3
+ FileUtils.chdir(@tmp_root, &block)
4
+ end
5
+
6
+ def in_project_folder(&block)
7
+ project_folder = @active_project_folder || @tmp_root
8
+ FileUtils.chdir(project_folder, &block)
9
+ end
10
+
11
+ def in_project_subfolder(folder, &block)
12
+ FileUtils.chdir(File.join(@active_project_folder, folder), &block)
13
+ end
14
+
15
+ def in_home_folder(&block)
16
+ FileUtils.chdir(@home_path, &block)
17
+ end
18
+
19
+ def force_local_lib_override(project_name = @project_name)
20
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
21
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
22
+ f << "$:.unshift('#{@lib_path}')\n"
23
+ f << rakefile
24
+ end
25
+ end
26
+
27
+ def setup_active_project_folder project_name
28
+ @active_project_folder = File.join(@tmp_root, project_name)
29
+ @project_name = project_name
30
+ end
31
+ end
32
+
33
+ World(CommonHelpers)
@@ -0,0 +1,25 @@
1
+ gem 'cucumber'
2
+ require 'cucumber'
3
+ gem 'rspec'
4
+ require 'spec'
5
+
6
+ Before do
7
+ @tmp_root = File.dirname(__FILE__) + "/../../tmp"
8
+ @home_path = File.expand_path(File.join(@tmp_root, "home"))
9
+ FileUtils.rm_rf @tmp_root
10
+ FileUtils.mkdir_p @home_path
11
+ ENV['HOME'] = @home_path
12
+ end
13
+
14
+ After do
15
+ unless ENV['LEAVE_CUCUMBER_GENERATED_OUTPUT']
16
+ FileUtils.rm_rf @active_project_folder
17
+ end
18
+ end
19
+
20
+ gem "fakeweb"
21
+ require "fakeweb"
22
+
23
+ Before do
24
+ FakeWeb.allow_net_connect = false
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackdempsey-beet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Dempsey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-18 00:00:00 -07:00
12
+ date: 2009-08-20 00:00:00 -07:00
13
13
  default_executable: beet
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
23
+ version: 0.11.5
24
24
  version:
25
25
  description:
26
26
  email: jack.dempsey@gmail.com
@@ -32,6 +32,7 @@ extra_rdoc_files:
32
32
  - LICENSE
33
33
  - README.rdoc
34
34
  files:
35
+ - .gitignore
35
36
  - LICENSE
36
37
  - README.rdoc
37
38
  - Rakefile
@@ -39,6 +40,11 @@ files:
39
40
  - VERSION
40
41
  - beet.gemspec
41
42
  - bin/beet
43
+ - features/generating.feature
44
+ - features/step_definitions/beet_steps.rb
45
+ - features/step_definitions/common_steps.rb
46
+ - features/support/common.rb
47
+ - features/support/env.rb
42
48
  - lib/beet.rb
43
49
  - lib/beet/capistrano.rb
44
50
  - lib/beet/execution.rb
@@ -72,6 +78,7 @@ files:
72
78
  - test/test_helper.rb
73
79
  has_rdoc: false
74
80
  homepage: http://github.com/jackdempsey/beet
81
+ licenses:
75
82
  post_install_message:
76
83
  rdoc_options:
77
84
  - --charset=UTF-8
@@ -92,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
99
  requirements: []
93
100
 
94
101
  rubyforge_project:
95
- rubygems_version: 1.2.0
102
+ rubygems_version: 1.3.5
96
103
  signing_key:
97
104
  specification_version: 3
98
105
  summary: A gem to help with easily generating projects