beet 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
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 "thor", "~> 0.11.6"
12
+ gem.add_dependency "thor", "~> 0.14.0"
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.5.0
1
+ 0.6.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{beet}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jack Dempsey"]
12
- s.date = %q{2010-03-14}
12
+ s.date = %q{2010-08-31}
13
13
  s.default_executable = %q{beet}
14
14
  s.email = %q{jack.dempsey@gmail.com}
15
15
  s.executables = ["beet"]
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  "features/support/env.rb",
35
35
  "lib/beet.rb",
36
36
  "lib/beet/capistrano.rb",
37
- "lib/beet/execution.rb",
37
+ "lib/beet/command_execution.rb",
38
38
  "lib/beet/executor.rb",
39
39
  "lib/beet/file_system.rb",
40
40
  "lib/beet/files/swfupload/images/cancelbutton.gif",
@@ -65,6 +65,14 @@ Gem::Specification.new do |s|
65
65
  "lib/beet/recipes/rails/swfupload.rb",
66
66
  "lib/beet/recipes/rails/testing/rspec.rb",
67
67
  "lib/beet/recipes/rails/testing/shoulda.rb",
68
+ "lib/beet/recipes/rails3/auth/devise.rb",
69
+ "lib/beet/recipes/rails3/clean_files.rb",
70
+ "lib/beet/recipes/rails3/css/reset.rb",
71
+ "lib/beet/recipes/rails3/db/mysql.rb",
72
+ "lib/beet/recipes/rails3/git.rb",
73
+ "lib/beet/recipes/rails3/js/jquery.rb",
74
+ "lib/beet/recipes/rails3/testing/cucumber.rb",
75
+ "lib/beet/recipes/rails3/testing/rspec.rb",
68
76
  "lib/beet/scm.rb",
69
77
  "lib/beet/scm/git.rb",
70
78
  "lib/beet/scm/svn.rb",
@@ -76,7 +84,7 @@ Gem::Specification.new do |s|
76
84
  s.homepage = %q{http://github.com/jackdempsey/beet}
77
85
  s.rdoc_options = ["--charset=UTF-8"]
78
86
  s.require_paths = ["lib"]
79
- s.rubygems_version = %q{1.3.6}
87
+ s.rubygems_version = %q{1.3.7}
80
88
  s.summary = %q{A gem to help with easily generating projects}
81
89
  s.test_files = [
82
90
  "test/executor_test.rb",
@@ -88,13 +96,13 @@ Gem::Specification.new do |s|
88
96
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
89
97
  s.specification_version = 3
90
98
 
91
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
92
- s.add_runtime_dependency(%q<thor>, ["~> 0.11.6"])
99
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
100
+ s.add_runtime_dependency(%q<thor>, ["~> 0.14.0"])
93
101
  else
94
- s.add_dependency(%q<thor>, ["~> 0.11.6"])
102
+ s.add_dependency(%q<thor>, ["~> 0.14.0"])
95
103
  end
96
104
  else
97
- s.add_dependency(%q<thor>, ["~> 0.11.6"])
105
+ s.add_dependency(%q<thor>, ["~> 0.14.0"])
98
106
  end
99
107
  end
100
108
 
data/bin/beet CHANGED
@@ -103,16 +103,6 @@ class BeetRunner < Thor
103
103
  }
104
104
  end
105
105
  end
106
- def method_missing(*args)
107
- unless @activesupport_required
108
- require 'activesupport'
109
- @activesupport_required = true
110
- m = args.shift
111
- send(m, *args)
112
- else
113
- super
114
- end
115
- end
116
106
 
117
107
  BeetRunner.start
118
108
 
@@ -1,5 +1,5 @@
1
1
  module Beet
2
- module Execution
2
+ module CommandExecution
3
3
  # Executes a command
4
4
  #
5
5
  # ==== Example
@@ -5,7 +5,7 @@ require 'yaml'
5
5
  module Beet
6
6
  class Executor
7
7
  BEET_DATA_FILE = "~/.beet.yml"
8
- include Beet::Execution
8
+ include Beet::CommandExecution
9
9
  include Beet::FileSystem
10
10
  include Beet::Interaction
11
11
 
@@ -25,7 +25,7 @@ module Beet
25
25
  @options = options
26
26
  @todo_items = ''
27
27
  @recipes = []
28
- @project_type = options[:project_type].to_sym || :rails
28
+ @project_type = (options[:project_type] && options[:project_type].to_sym) || :rails3
29
29
  @generate = true unless options[:generate] == false
30
30
  @display = options[:display]
31
31
  extract_commands_from_options
@@ -45,24 +45,16 @@ module Beet
45
45
  if @display && @template
46
46
  puts open(TEMPLATE_LOCATIONS[@template]).read
47
47
  else
48
- case @project_type
49
- when :rails3
50
- # TODO win compatibility
51
- unless `which rails3`.blank?
52
- if @generate
53
- puts "Generating rails 3 project #{project_name}..."
54
- if @template
55
- system("rails3 #{project_name} -m #{TEMPLATE_LOCATIONS[@template]}")
56
- else
57
- system("rails3 #{project_name}")
58
- end
48
+ if @generate
49
+ # TODO maybe let people specify path to rails 3 script rather than just assume its 'rails'
50
+ if @project_type == :rails3
51
+ puts "Generating rails 3 project #{project_name}..."
52
+ if @template
53
+ system("rails new #{project_name} -m #{TEMPLATE_LOCATIONS[@template]}")
54
+ else
55
+ system("rails new #{project_name}")
59
56
  end
60
57
  else
61
- puts "Beet relies on you defining a rails3 command to build rails 3 projects. Please make sure one is available in your PATH."
62
- exit
63
- end
64
- when :rails
65
- if @generate
66
58
  puts "Generating rails project #{project_name}..."
67
59
  if @template
68
60
  system("rails #{project_name} -m #{TEMPLATE_LOCATIONS[@template]}")
@@ -87,9 +87,8 @@ module Beet
87
87
  #
88
88
  # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
89
89
  #
90
- def gsub_file(relative_destination, regexp, *args, &block)
90
+ def gsub_file(path, regexp, *args, &block)
91
91
  #path = destination_path(relative_destination)
92
- path = relative_destination
93
92
  content = File.read(path)
94
93
  check_for = args.first || yield('')
95
94
  regex = Regexp.new(regexp.source + Regexp.escape(check_for))
@@ -121,6 +120,21 @@ module Beet
121
120
  end
122
121
  end
123
122
 
123
+ # Add text after matching line, otherwise append to file wrapped in before/after text
124
+ #
125
+ # ==== Example
126
+ #
127
+ # add_after_or_append 'Gemfile', 'group :test', "gem 'rspec-rails'", "group :test do", "end"
128
+ #
129
+ def add_after_or_append(filename, matching_text, text_to_add, before_text, after_text)
130
+ content = File.read(filename)
131
+ if content.include?(matching_text)
132
+ add_after(filename, matching_text, text_to_add)
133
+ else
134
+ append_file(filename, [before_text, text_to_add, after_text].join("\n"))
135
+ end
136
+ end
137
+
124
138
  # Add text before matching line
125
139
  #
126
140
  # ==== Example
@@ -53,22 +53,46 @@ module Beet
53
53
  end
54
54
  end
55
55
 
56
+ def gem_group(group)
57
+ @_gem_group = group
58
+ yield
59
+ @_gem_group = nil
60
+ end
61
+
56
62
  # Adds an entry into config/environment.rb for the supplied gem :
57
63
  def gem(name, options = {})
58
64
  log 'gem', name
59
- env = options.delete(:env)
65
+ group = options.delete(:group) || @_gem_group
66
+ version = options.delete(:version)
60
67
 
61
- gems_code = "config.gem '#{name}'"
68
+ gems_code = "gem '#{name}'"
69
+ gems_code << ", '#{version}'" if version
62
70
 
63
71
  if options.any?
64
72
  opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ")
65
73
  gems_code << ", #{opts}"
66
74
  end
67
75
 
68
- environment gems_code, :env => env
76
+ gemfile(gems_code, :group => group)
77
+ end
78
+
79
+ # Adds a line inside the Gemfile. Used by #gem
80
+ # If options :group is specified, the line is added inside the corresponding group
81
+ def gemfile(data, options={})
82
+ if group = options[:group]
83
+ if group.is_a?(Array)
84
+ group.each do |g|
85
+ add_after_or_append "Gemfile", "group :#{g} do", "\s\s" + data, "group :#{g} do", "end\n"
86
+ end
87
+ else
88
+ add_after_or_append "Gemfile", "group :#{group} do", "\s\s" + data, "group :#{group} do", "end\n"
89
+ end
90
+ else
91
+ append_file "Gemfile", data
92
+ end
69
93
  end
70
94
 
71
- # Adds a line inside the Initializer block for config/environment.rb. Used by #gem
95
+ # Adds a line inside the Initializer block for config/environment.rb.
72
96
  # If options :env is specified, the line is appended to the corresponding
73
97
  # file in config/environments/#{env}.rb
74
98
  def environment(data = nil, options = {}, &block)
@@ -140,7 +164,7 @@ module Beet
140
164
  log 'generating', what
141
165
  argument = args.map {|arg| arg.to_s }.flatten.join(" ")
142
166
 
143
- in_root { run_ruby_script("script/generate #{what} #{argument}", false) }
167
+ in_root { run_ruby_script("script/rails generate #{what} #{argument}", false) }
144
168
  end
145
169
  end # Rails
146
170
  end # Beet
@@ -0,0 +1,8 @@
1
+ # this is designed for rails 3
2
+ gem 'devise', :version => '1.1.rc2'
3
+
4
+ generate "devise:install"
5
+ generate "devise User"
6
+ generate "devise:views"
7
+
8
+ rake "db:migrate"
@@ -0,0 +1,3 @@
1
+ run "rm README"
2
+ run "rm public/index.html"
3
+ run "rm public/favicon.ico"
@@ -0,0 +1,10 @@
1
+ reset_file_location = "http://developer.yahoo.com/yui/build/reset/reset.css"
2
+ unless File.exists?('public/stylesheets/reset.css')
3
+ begin
4
+ file "public/stylesheets/reset.css" do
5
+ open(reset_file_location).read
6
+ end
7
+ rescue
8
+ "Couldn't load #{reset_file_location}"
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ file 'config/database.yml' do
2
+ %{
3
+ ---
4
+ development: &defaults
5
+ adapter: mysql
6
+ encoding: utf8
7
+ reconnect: false
8
+ database: #{project_name}_development
9
+ pool: 5
10
+ username: root
11
+ password:
12
+
13
+ # Warning: The database defined as "test" will be erased and
14
+ # re-generated from your development database when you run "rake".
15
+ # Do not set this db to the same as development or production.
16
+ test:
17
+ <<: *defaults
18
+ database: #{project_name}_test
19
+
20
+ production:
21
+ <<: *defaults
22
+ database: #{project_name}_production
23
+ }
24
+ end
25
+
26
+ FileUtils.copy "config/database.yml", "config/database.yml.example"
27
+
28
+ if yes?("Create databases using rake db:create:all?")
29
+ rake "db:create:all"
30
+ end
31
+
@@ -0,0 +1,8 @@
1
+ # .gitignore is now created for us by rails
2
+ # only need to init git, add the current dir, and commit!
3
+
4
+ git :init
5
+
6
+ git :add => "."
7
+
8
+ git :commit => "-m 'Initial commit from Beet. Enjoy.'"
@@ -0,0 +1,9 @@
1
+ %w(application controls dragdrop effects prototype rails).each do |filename|
2
+ FileUtils.rm("public/javascripts/#{filename}.js")
3
+ end
4
+
5
+ run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.4.1.min.js > public/javascripts/jquery.js"
6
+ run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
7
+ run "curl -L http://github.com/rails/jquery-ujs/raw/master/src/rails.js > public/javascripts/rails.js"
8
+
9
+ prepend_file 'public/javascripts/rails.js', %{jQuery.ajaxSetup({'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript");}})}
@@ -0,0 +1,13 @@
1
+ gem_group :cucumber do
2
+ gem 'capybara'
3
+ gem 'database_cleaner'
4
+ gem 'cucumber-rails'
5
+ gem 'cucumber', :version => '0.7.3'
6
+ gem 'rspec-rails', :version => '~> 2.0.0.beta.19'
7
+ gem 'spork'
8
+ gem 'launchy'
9
+ end
10
+
11
+ run 'bundle install'
12
+
13
+ generate 'cucumber:skeleton --rspec --capybara'
@@ -0,0 +1,15 @@
1
+ gem 'rspec-rails', :version => '~> 2.0.0.beta.19', :group => [:development,:test]
2
+
3
+ run "bundle install"
4
+
5
+ generate "rspec:install"
6
+
7
+ in_root do
8
+ add_after 'config/application.rb', 'class Application < Rails::Application' do
9
+ %{
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+ }
14
+ end
15
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beet
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 5
8
+ - 6
8
9
  - 0
9
- version: 0.5.0
10
+ version: 0.6.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jack Dempsey
@@ -14,21 +15,23 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-14 00:00:00 -05:00
18
+ date: 2010-08-31 00:00:00 -04:00
18
19
  default_executable: beet
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thor
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ~>
26
28
  - !ruby/object:Gem::Version
29
+ hash: 39
27
30
  segments:
28
31
  - 0
29
- - 11
30
- - 6
31
- version: 0.11.6
32
+ - 14
33
+ - 0
34
+ version: 0.14.0
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  description:
@@ -57,7 +60,7 @@ files:
57
60
  - features/support/env.rb
58
61
  - lib/beet.rb
59
62
  - lib/beet/capistrano.rb
60
- - lib/beet/execution.rb
63
+ - lib/beet/command_execution.rb
61
64
  - lib/beet/executor.rb
62
65
  - lib/beet/file_system.rb
63
66
  - lib/beet/files/swfupload/images/cancelbutton.gif
@@ -88,6 +91,14 @@ files:
88
91
  - lib/beet/recipes/rails/swfupload.rb
89
92
  - lib/beet/recipes/rails/testing/rspec.rb
90
93
  - lib/beet/recipes/rails/testing/shoulda.rb
94
+ - lib/beet/recipes/rails3/auth/devise.rb
95
+ - lib/beet/recipes/rails3/clean_files.rb
96
+ - lib/beet/recipes/rails3/css/reset.rb
97
+ - lib/beet/recipes/rails3/db/mysql.rb
98
+ - lib/beet/recipes/rails3/git.rb
99
+ - lib/beet/recipes/rails3/js/jquery.rb
100
+ - lib/beet/recipes/rails3/testing/cucumber.rb
101
+ - lib/beet/recipes/rails3/testing/rspec.rb
91
102
  - lib/beet/scm.rb
92
103
  - lib/beet/scm/git.rb
93
104
  - lib/beet/scm/svn.rb
@@ -105,23 +116,27 @@ rdoc_options:
105
116
  require_paths:
106
117
  - lib
107
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
108
120
  requirements:
109
121
  - - ">="
110
122
  - !ruby/object:Gem::Version
123
+ hash: 3
111
124
  segments:
112
125
  - 0
113
126
  version: "0"
114
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
115
129
  requirements:
116
130
  - - ">="
117
131
  - !ruby/object:Gem::Version
132
+ hash: 3
118
133
  segments:
119
134
  - 0
120
135
  version: "0"
121
136
  requirements: []
122
137
 
123
138
  rubyforge_project:
124
- rubygems_version: 1.3.6
139
+ rubygems_version: 1.3.7
125
140
  signing_key:
126
141
  specification_version: 3
127
142
  summary: A gem to help with easily generating projects