beet 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +2 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +13 -0
  4. data/Rakefile +59 -0
  5. data/TODO +17 -0
  6. data/VERSION +1 -0
  7. data/beet.gemspec +89 -0
  8. data/bin/beet +112 -0
  9. data/features/generating.feature +24 -0
  10. data/features/step_definitions/beet_steps.rb +7 -0
  11. data/features/step_definitions/common_steps.rb +172 -0
  12. data/features/support/common.rb +33 -0
  13. data/features/support/env.rb +25 -0
  14. data/lib/beet.rb +10 -0
  15. data/lib/beet/capistrano.rb +14 -0
  16. data/lib/beet/execution.rb +50 -0
  17. data/lib/beet/executor.rb +195 -0
  18. data/lib/beet/file_system.rb +143 -0
  19. data/lib/beet/gem_location_map.rb +64 -0
  20. data/lib/beet/interaction.rb +37 -0
  21. data/lib/beet/logger.rb +44 -0
  22. data/lib/beet/rails.rb +146 -0
  23. data/lib/beet/recipes/passenger/vhost.rb +17 -0
  24. data/lib/beet/recipes/rack/middleware.rb +17 -0
  25. data/lib/beet/recipes/rails/authlogic.rb +297 -0
  26. data/lib/beet/recipes/rails/clean_files.rb +4 -0
  27. data/lib/beet/recipes/rails/clearance.rb +22 -0
  28. data/lib/beet/recipes/rails/cms/bcms_blog.rb +21 -0
  29. data/lib/beet/recipes/rails/cms/bcms_event.rb +24 -0
  30. data/lib/beet/recipes/rails/css/blueprint.rb +5 -0
  31. data/lib/beet/recipes/rails/css/reset.rb +10 -0
  32. data/lib/beet/recipes/rails/db/mysql.rb +42 -0
  33. data/lib/beet/recipes/rails/db/postgres.rb +52 -0
  34. data/lib/beet/recipes/rails/git.rb +23 -0
  35. data/lib/beet/recipes/rails/jquery.rb +11 -0
  36. data/lib/beet/recipes/rails/rspec.rb +3 -0
  37. data/lib/beet/recipes/rails/shoulda.rb +1 -0
  38. data/lib/beet/scm.rb +36 -0
  39. data/lib/beet/scm/git.rb +15 -0
  40. data/lib/beet/scm/svn.rb +5 -0
  41. data/lib/beet/template_location_map.rb +13 -0
  42. data/test/executor_test.rb +24 -0
  43. data/test/file_system_test.rb +59 -0
  44. data/test/test_helper.rb +12 -0
  45. metadata +110 -0
@@ -0,0 +1,4 @@
1
+ run "rm README"
2
+ run "rm public/index.html"
3
+ run "rm public/favicon.ico"
4
+ run "rm public/robots.txt"
@@ -0,0 +1,22 @@
1
+ gem 'thoughtbot-clearance', :lib => 'clearance',:source => 'http://gems.github.com', :version => '~> 0.6'
2
+ gem 'webrat'
3
+ gem 'cucumber'
4
+ gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => "http://gems.github.com"
5
+
6
+
7
+ rake "gems:install", :sudo => true
8
+ rake "gems:unpack"
9
+ rake "db:create:all"
10
+
11
+ generate "clearance"
12
+ generate "cucumber"
13
+ generate "clearance_features"
14
+ rake "db:migrate"
15
+
16
+ environment "HOST = 'localhost'", :env => "development"
17
+ environment "HOST = 'localhost'", :env => "test"
18
+ environment "DO_NOT_REPLY = \"donotreply@example.com\""
19
+ route "map.root :controller => 'sessions', :action => 'new'"
20
+
21
+ run "cp -fr vendor/gems/thoughtbot-clearance*/app/views app/"
22
+
@@ -0,0 +1,21 @@
1
+ # install the gem
2
+ if `gem list bcms_blog | grep bcms_blog`.empty?
3
+ # Run this inside or outside your bcms_blog directory, otherwise download the code
4
+ git "clone git://github.com/browsermedia/bcms_blog.git" unless File.exists?('./bcms_blog') || File.basename(Dir.pwd) == 'bcms_blog'
5
+ FileUtils.chdir 'bcms_blog' do
6
+ system "gem build *.gemspec"
7
+ sudo "gem install bcms_blog*.gem"
8
+ end
9
+ if yes? "Should I delete bcms_blog/"
10
+ FileUtils.rm_rf('bcms_blog')
11
+ end
12
+ end
13
+
14
+ # add to project
15
+ add_after 'config/environment.rb', "config.gem 'browsercms'" do
16
+ "\tconfig.gem 'bcms_blog'"
17
+ end
18
+
19
+ add_before 'config/routes.rb', 'map.routes_for_browser_cms' do
20
+ "\tmap.routes_for_bcms_blog"
21
+ end
@@ -0,0 +1,24 @@
1
+ # install the gem
2
+ if `gem list bcms_event | grep bcms_event`.empty?
3
+ # Run this inside or outside your bcms_event directory, otherwise download the code
4
+ git "clone git://github.com/browsermedia/bcms_event.git" unless File.exists?('./bcms_event') || File.basename(Dir.pwd) == 'bcms_event'
5
+ FileUtils.chdir 'bcms_event' do
6
+ system "gem build *.gemspec"
7
+ sudo "gem install bcms_event*.gem"
8
+ end
9
+ if yes? "Should I delete bcms_event/"
10
+ FileUtils.rm_rf('bcms_event')
11
+ end
12
+ end
13
+
14
+ # add to project
15
+ add_after 'config/environment.rb', "config.gem 'browsercms'" do
16
+ "\tconfig.gem 'bcms_event'"
17
+ end
18
+
19
+ add_before 'config/routes.rb', 'map.routes_for_browser_cms' do
20
+ "\tmap.routes_for_bcms_event\n"
21
+ end
22
+
23
+ generate "browser_cms"
24
+ rake "db:migrate"
@@ -0,0 +1,5 @@
1
+ FileUtils.mkdir_p("public/stylesheets/blueprint")
2
+ %w(forms.css grid.css grid.png ie.css print.css reset.css typography.css).each do |file|
3
+ run "curl -L http://github.com/joshuaclayton/blueprint-css/blob/master/blueprint/src/#{file} \
4
+ > public/stylesheets/blueprint/#{file}"
5
+ end
@@ -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,42 @@
1
+ file 'config/database.yml' do
2
+ %{
3
+ # MySQL. Versions 4.1 and 5.0 are recommended.
4
+ #
5
+ # Install the MySQL driver:
6
+ # gem install mysql
7
+ # On Mac OS X:
8
+ # sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
9
+ # On Mac OS X Leopard:
10
+ # sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
11
+ # This sets the ARCHFLAGS environment variable to your native architecture
12
+ # On Windows:
13
+ # gem install mysql
14
+ # Choose the win32 build.
15
+ # Install MySQL and put its /bin directory on your path.
16
+ #
17
+ # And be sure to use new-style password hashing:
18
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
19
+ ---
20
+ development: &defaults
21
+ adapter: mysql
22
+ encoding: utf8
23
+ reconnect: false
24
+ database: #{project_name}_development
25
+ pool: 5
26
+ username: root
27
+ password:
28
+
29
+ # Warning: The database defined as "test" will be erased and
30
+ # re-generated from your development database when you run "rake".
31
+ # Do not set this db to the same as development or production.
32
+ test:
33
+ <<: *defaults
34
+ database: #{project_name}_test
35
+
36
+ production:
37
+ <<: *defaults
38
+ database: #{project_name}_production
39
+ }
40
+ end
41
+
42
+ FileUtils.copy "config/database.yml", "config/database.yml.example"
@@ -0,0 +1,52 @@
1
+ file 'config/database.yml' do
2
+ %{
3
+ # PostgreSQL. Versions 7.4 and 8.x are supported.
4
+ #
5
+ # Install the ruby-postgres driver:
6
+ # gem install pg
7
+ # On Mac OS X:
8
+ # gem install ruby-postgres -- --include=/usr/local/pgsql
9
+ # On Windows:
10
+ # gem install ruby-postgres
11
+ # Choose the win32 build.
12
+ # Install PostgreSQL and put its /bin directory on your path.
13
+
14
+ development: &defaults
15
+ adapter: postgresql
16
+ encoding: unicode
17
+ database: #{project_name}_development
18
+ pool: 5
19
+ username: root
20
+ password:
21
+
22
+ # Connect on a TCP socket. Omitted by default since the client uses a
23
+ # domain socket that doesn't need configuration. Windows does not have
24
+ # domain sockets, so uncomment these lines.
25
+ #host: localhost
26
+ #port: 5432
27
+
28
+ # Schema search path. The server defaults to $user,public
29
+ #schema_search_path: myapp,sharedapp,public
30
+
31
+ # Minimum log levels, in increasing order:
32
+ # debug5, debug4, debug3, debug2, debug1,
33
+ # log, notice, warning, error, fatal, and panic
34
+ # The server defaults to notice.
35
+ #min_messages: warning
36
+
37
+
38
+ # Warning: The database defined as "test" will be erased and
39
+ # re-generated from your development database when you run "rake".
40
+ # Do not set this db to the same as development or production.
41
+ test:
42
+ <<: *defaults
43
+ database: #{project_name}_test
44
+
45
+ production:
46
+ <<: *defaults
47
+ database: #{project_name}_production
48
+ }
49
+ end
50
+
51
+ FileUtils.copy "config/database.yml", "config/database.yml.example"
52
+
@@ -0,0 +1,23 @@
1
+ ["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f|
2
+ run("rmdir ./#{f}")
3
+ end
4
+
5
+ run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;")
6
+
7
+ git :init
8
+
9
+ file '.gitignore', <<-CODE
10
+ log/*.*
11
+ db/*.db
12
+ db/*.sqlite3
13
+ db/schema.rb
14
+ tmp/*.*
15
+ .DS_Store
16
+ doc/api
17
+ doc/app
18
+ config/database.yml
19
+ CODE
20
+
21
+ git :add => "."
22
+
23
+ git :commit => "-m 'Initial commit. Enjoy.'"
@@ -0,0 +1,11 @@
1
+ FileUtils.rm_r Dir.glob("public/javascripts/*.js")
2
+
3
+ run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
4
+ run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
5
+
6
+ # Thanks to Chris Wanstrath and Doug Ramsay. The below will make it so that Rails recognizes form requests
7
+ file 'public/javascripts/application.js', <<-CODE
8
+ jQuery.ajaxSetup({
9
+ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
10
+ });
11
+ CODE
@@ -0,0 +1,3 @@
1
+ ruby script/plugin install git://github.com/dchelimsky/rspec.git -r 'refs/tags/1.2.6'
2
+ ruby script/plugin install git://github.com/dchelimsky/rspec-rails.git -r 'refs/tags/1.2.6'
3
+ ruby script/generate rspec
@@ -0,0 +1 @@
1
+ gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'
data/lib/beet/scm.rb ADDED
@@ -0,0 +1,36 @@
1
+ class Scm
2
+
3
+ private
4
+
5
+ def self.hash_to_parameters(hash)
6
+ hash.collect { |key, value| "--#{key} #{(value.kind_of?(String) ? value : "")}"}.join(" ")
7
+ end
8
+ end
9
+ require File.dirname(__FILE__) + '/scm/git'
10
+ require File.dirname(__FILE__) + '/scm/svn'
11
+
12
+ module Beet
13
+ module SCM
14
+ # Run a command in git.
15
+ #
16
+ # ==== Examples
17
+ #
18
+ # git :init
19
+ # git :add => "this.file that.rb"
20
+ # git :add => "onefile.rb", :rm => "badfile.cxx"
21
+ #
22
+ def git(command = {})
23
+ in_root do
24
+ if command.is_a?(Symbol)
25
+ log 'running', "git #{command}"
26
+ Git.run(command.to_s)
27
+ else
28
+ command.each do |command, options|
29
+ log 'running', "git #{command} #{options}"
30
+ Git.run("#{command} #{options}")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ class Git < Scm
2
+ def self.clone(repos, branch=nil)
3
+ system("git clone #{repos}")
4
+
5
+ if branch
6
+ system("cd #{repos.split('/').last}/")
7
+ system("git checkout #{branch}")
8
+ end
9
+ end
10
+
11
+ def self.run(command)
12
+ system("git #{command}")
13
+ end
14
+ end
15
+
@@ -0,0 +1,5 @@
1
+ class Svn < Scm
2
+ def self.checkout(repos, branch = nil)
3
+ `svn checkout #{repos}/#{branch || "trunk"}`
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ TEMPLATE_LOCATIONS = {
2
+ 'browsercms' => 'http://github.com/browsermedia/browsercms/raw/master/templates/blank.rb',
3
+ 'browsercms_demo' => 'http://github.com/browsermedia/browsercms/raw/master/templates/demo.rb',
4
+ 'bort' => 'http://github.com/jeremymcanally/rails-templates/raw/master/bort.rb',
5
+ 'daring' => 'http://github.com/jeremymcanally/rails-templates/raw/master/daring.rb',
6
+ 'datamapper' => 'http://github.com/jeremymcanally/rails-templates/raw/master/datamapper.rb',
7
+ 'entp' => 'http://github.com/jeremymcanally/rails-templates/raw/master/entp.rb',
8
+ 'facebook' => 'http://github.com/jeremymcanally/rails-templates/raw/master/facebook.rb',
9
+ 'google_app_engine' => 'http://github.com/jeremymcanally/rails-templates/raw/master/google_app_engine.rb',
10
+ 'newgit' => 'http://github.com/jeremymcanally/rails-templates/raw/master/newgit.rb',
11
+ 'sethbc' => 'http://github.com/jeremymcanally/rails-templates/raw/master/sethbc.rb',
12
+ 'suspenders' => 'http://github.com/jeremymcanally/rails-templates/raw/master/suspenders.rb'
13
+ }
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class ExecutorShouldaTest < Test::Unit::TestCase
4
+
5
+ should "set project root to Dir.pwd + project_name in general case" do
6
+ executor = Beet::Executor.new('foobar')
7
+ assert_equal Dir.pwd + "/foobar", executor.root
8
+ end
9
+
10
+ should "set project root to project name if project name looks like /Users/jack/something" do
11
+ executor = Beet::Executor.new('/Users/jack/foobar')
12
+ assert_equal '/Users/jack/foobar', executor.root
13
+ end
14
+
15
+ should "set project root to Dir.pwd if directory one level above is the same as the project name" do
16
+ FileUtils.mkdir_p 'foobar'
17
+ FileUtils.chdir 'foobar' do
18
+ executor = Beet::Executor.new('foobar')
19
+ assert_equal Dir.pwd, executor.root
20
+ end
21
+ FileUtils.rm_rf 'foobar'
22
+ end
23
+
24
+ end
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+
3
+ include Beet::FileSystem
4
+
5
+ # define some methods that file_system recipes expect to exist
6
+ def root; '.'; end
7
+ class FileSystemTest < Test::Unit::TestCase
8
+ context "#add_after" do
9
+ setup do
10
+ @filename = 'test.file'
11
+ File.open(@filename,'w') do |f|
12
+ f.puts "first line"
13
+ f.puts "second line"
14
+ end
15
+ end
16
+
17
+ teardown do
18
+ File.unlink(@filename)
19
+ end
20
+
21
+ should "add the given text after the specified text" do
22
+ add_after @filename, "first line", "middle line"
23
+ assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
24
+ end
25
+
26
+ should "not add the given text if it already exists after the specified text" do
27
+ add_after @filename, "first line", "middle line"
28
+ assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
29
+ add_after @filename, "first line", "middle line"
30
+ assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
31
+ end
32
+
33
+ should "add the given text if it exists but only elsewhere in the specified text" do
34
+ add_after @filename, "first line", "middle line"
35
+ assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
36
+ add_after @filename, "first line", "second line"
37
+ assert_equal "first line\nsecond line\nmiddle line\nsecond line\n", File.read(@filename)
38
+ end
39
+ end
40
+
41
+ context "#append_file" do
42
+ setup do
43
+ @filename = 'test.file'
44
+ File.open(@filename,'w') do |f|
45
+ f.puts "first line"
46
+ f.puts "second line"
47
+ end
48
+ end
49
+
50
+ teardown do
51
+ File.unlink(@filename)
52
+ end
53
+
54
+ should "add text to the end of the file" do
55
+ append_file @filename, "third line"
56
+ assert_equal "first line\nsecond line\nthird line", File.read(@filename)
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'beet'
8
+ if RUBY_VERSION <= '1.8.6'
9
+ require 'ruby-debug'
10
+ end
11
+ class Test::Unit::TestCase
12
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack Dempsey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-24 00:00:00 -04:00
13
+ default_executable: beet
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: wycats-thor
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.11.5
24
+ version:
25
+ description:
26
+ email: jack.dempsey@gmail.com
27
+ executables:
28
+ - beet
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .gitignore
36
+ - LICENSE
37
+ - README.rdoc
38
+ - Rakefile
39
+ - TODO
40
+ - VERSION
41
+ - beet.gemspec
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
48
+ - lib/beet.rb
49
+ - lib/beet/capistrano.rb
50
+ - lib/beet/execution.rb
51
+ - lib/beet/executor.rb
52
+ - lib/beet/file_system.rb
53
+ - lib/beet/gem_location_map.rb
54
+ - lib/beet/interaction.rb
55
+ - lib/beet/logger.rb
56
+ - lib/beet/rails.rb
57
+ - lib/beet/recipes/passenger/vhost.rb
58
+ - lib/beet/recipes/rack/middleware.rb
59
+ - lib/beet/recipes/rails/authlogic.rb
60
+ - lib/beet/recipes/rails/clean_files.rb
61
+ - lib/beet/recipes/rails/clearance.rb
62
+ - lib/beet/recipes/rails/cms/bcms_blog.rb
63
+ - lib/beet/recipes/rails/cms/bcms_event.rb
64
+ - lib/beet/recipes/rails/css/blueprint.rb
65
+ - lib/beet/recipes/rails/css/reset.rb
66
+ - lib/beet/recipes/rails/db/mysql.rb
67
+ - lib/beet/recipes/rails/db/postgres.rb
68
+ - lib/beet/recipes/rails/git.rb
69
+ - lib/beet/recipes/rails/jquery.rb
70
+ - lib/beet/recipes/rails/rspec.rb
71
+ - lib/beet/recipes/rails/shoulda.rb
72
+ - lib/beet/scm.rb
73
+ - lib/beet/scm/git.rb
74
+ - lib/beet/scm/svn.rb
75
+ - lib/beet/template_location_map.rb
76
+ - test/executor_test.rb
77
+ - test/file_system_test.rb
78
+ - test/test_helper.rb
79
+ has_rdoc: true
80
+ homepage: http://github.com/jackdempsey/beet
81
+ licenses: []
82
+
83
+ post_install_message:
84
+ rdoc_options:
85
+ - --charset=UTF-8
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.5
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: A gem to help with easily generating projects
107
+ test_files:
108
+ - test/executor_test.rb
109
+ - test/file_system_test.rb
110
+ - test/test_helper.rb