suspenders 0.2.7 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,10 @@ We love pull requests. Here's a quick guide:
3
3
  1. Fork the repo.
4
4
 
5
5
  2. Run the tests. We only take pull requests with passing tests, and it's great
6
- to know that you have a clean slate: `bundle && rake`
6
+ to know that you have a clean slate: `REPO=path/to/.git bundle && rake`.
7
+
8
+ Note that you must include the `REPO` environment variable pointing at your local
9
+ `.git` repository in order to generate the test application required by tests.
7
10
 
8
11
  3. Add a test for your change. Only refactoring and documentation changes
9
12
  require no new tests. If you are adding functionality or fixing a bug, we need
@@ -35,4 +38,4 @@ Syntax:
35
38
  * a = b and not a=b.
36
39
  * Follow the conventions you see used in the source already.
37
40
 
38
- And in case we didn't emphasize it enough: we love tests!
41
+ And in case we didn't emphasize it enough: we love tests!
data/README.md CHANGED
@@ -17,8 +17,8 @@ This will create a Rails 3.1 app in `projectname'. This script creates a new
17
17
  new git repository. It is not meant to be used against an existing repo.
18
18
 
19
19
  Suspenders uses [Trout](https://github.com/thoughtbot/trout) to make it
20
- easier to maintain a base version of special files (like Gemfile) in
21
- Suspenders.
20
+ easier to maintain a base version of special files like Gemfile and Procfile
21
+ in Suspenders.
22
22
 
23
23
  Whenever you want to get the latest and greatest Suspenders' Gemfile, run:
24
24
 
@@ -61,6 +61,19 @@ Suspenders also comes with:
61
61
  See [template/files](https://github.com/thoughtbot/suspenders/blob/master/template/files) to
62
62
  see what is generated one-time.
63
63
 
64
+ Dependencies
65
+ ------------
66
+
67
+ Some gems included in Suspenders have native extensions. You should have GCC installed on your
68
+ machine before running Suspenders.
69
+
70
+ If you're running OS X, we recommend the [GCC OSX installer](https://github.com/kennethreitz/osx-gcc-installer).
71
+
72
+ We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for full-stack Javascript integration testing.
73
+ It requires you have QT installed on your machine before running Suspenders.
74
+
75
+ Instructions for installing QT on most systems are [available here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT).
76
+
64
77
  Issues
65
78
  ------
66
79
 
@@ -1,23 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path(File.dirname(__FILE__) + "/../lib/create")
4
- require File.expand_path(File.dirname(__FILE__) + "/../lib/errors")
3
+ require File.expand_path(File.join('..', 'lib', 'suspenders', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'suspenders', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'suspenders', 'app_builder'), File.dirname(__FILE__))
5
6
 
6
- include Suspenders::Errors
7
-
8
- def usage
9
- "Usage: #{File.basename(__FILE__)} create new_project_name"
7
+ if ['create', '--create'].include? ARGV[0]
8
+ ARGV.shift
9
+ puts "[WARNING] the suspenders create argument is deprecated. Just use `suspenders #{ARGV.join}` instead"
10
10
  end
11
11
 
12
- case ARGV[0]
13
- when 'create', '--create'
14
- begin
15
- Suspenders::Create.run!(ARGV[1], ARGV[2])
16
- rescue Suspenders::InvalidInput => e
17
- error_with_message(e.message)
18
- end
19
- when 'help', '--help'
20
- puts usage
21
- else
22
- error_with_message "Unknown subcommand: #{ARGV[0]}\n#{usage}"
23
- end
12
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
13
+ Suspenders::Generator.source_root templates_root
14
+ Suspenders::Generator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
15
+
16
+ Suspenders::Generator.start
@@ -0,0 +1,35 @@
1
+ module Suspenders
2
+ module Actions
3
+ def concat_file(source, destination)
4
+ contents = IO.read(find_in_source_paths(source))
5
+ append_file destination, contents
6
+ end
7
+
8
+ def replace_in_file(relative_path, find, replace)
9
+ path = File.join(destination_root, relative_path)
10
+ contents = IO.read(path)
11
+ unless contents.gsub!(find, replace)
12
+ raise "#{find.inspect} not found in #{relative_path}"
13
+ end
14
+ File.open(path, "w") { |file| file.write(contents) }
15
+ end
16
+
17
+ def action_mailer_host(rails_env, host)
18
+ inject_into_file(
19
+ "config/environments/#{rails_env}.rb",
20
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
21
+ :before => "\nend"
22
+ )
23
+ end
24
+
25
+ def download_file(uri_string, destination)
26
+ uri = URI.parse(uri_string)
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+ http.use_ssl = true if uri_string =~ /^https/
29
+ request = Net::HTTP::Get.new(uri.path)
30
+ contents = http.request(request).body
31
+ path = File.join(destination_root, destination)
32
+ File.open(path, "w") { |file| file.write(contents) }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,140 @@
1
+ module Suspenders
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Suspenders::Actions
4
+
5
+ def readme
6
+ copy_file "README_FOR_SUSPENDERS"
7
+ end
8
+
9
+ def remove_public_index
10
+ remove_file 'public/index.html'
11
+ end
12
+
13
+ def remove_public_images_rails
14
+ remove_file 'public/images/rails.png'
15
+ end
16
+
17
+ def setup_staging
18
+ run "cp config/environments/production.rb config/environments/staging.rb"
19
+ end
20
+
21
+ def create_views_shared
22
+ empty_directory "app/views/shared"
23
+ end
24
+
25
+ def create_shared_flashes
26
+ copy_file "_flashes.html.erb", "app/views/shared/_flashes.html.erb"
27
+ end
28
+
29
+ def create_shared_javascripts
30
+ copy_file "_javascript.html.erb", "app/views/shared/_javascript.html.erb"
31
+ end
32
+
33
+ def create_application_layout
34
+ template "suspenders_layout.html.erb.erb",
35
+ "app/views/layouts/application.html.erb",
36
+ :force => true
37
+ end
38
+
39
+ def create_common_javascripts
40
+ directory "javascripts", "app/assets/javascripts"
41
+ end
42
+
43
+ def add_jquery_ui
44
+ inject_into_file "app/assets/javascripts/application.js", "//= require jquery-ui\n", :before => "//= require_tree ."
45
+ end
46
+
47
+ def use_postgres_config_template
48
+ template "postgresql_database.yml.erb", "config/database.yml", :force => true
49
+ end
50
+
51
+ def create_database
52
+ rake "db:create"
53
+ end
54
+
55
+ def include_custom_gems
56
+ additions_path = find_in_source_paths 'Gemfile_additions'
57
+ new_gems = File.open(additions_path).read
58
+ insert_into_file("Gemfile", "\n#{new_gems}", :after => /gem 'jquery-rails'/)
59
+ end
60
+
61
+ def configure_rspec
62
+ generators_config = <<-RUBY
63
+ config.generators do |generate|
64
+ generate.test_framework :rspec
65
+ end
66
+ RUBY
67
+ inject_into_class "config/application.rb", "Application", generators_config
68
+ end
69
+
70
+ def configure_action_mailer
71
+ action_mailer_host "development", "#{app_name}.local"
72
+ action_mailer_host "test", "example.com"
73
+ action_mailer_host "staging", "staging.#{app_name}.com"
74
+ action_mailer_host "production", "#{app_name}.com"
75
+ end
76
+
77
+ def generate_rspec
78
+ generate "rspec:install"
79
+ replace_in_file "spec/spec_helper.rb", "mock_with :rspec", "mock_with :mocha"
80
+ end
81
+
82
+ def generate_cucumber
83
+ generate "cucumber:install", "--rspec", "--capybara"
84
+ inject_into_file "features/support/env.rb",
85
+ %{Capybara.save_and_open_page_path = 'tmp'\n} +
86
+ %{Capybara.javascript_driver = :webkit\n},
87
+ :before => %{Capybara.default_selector = :css}
88
+ end
89
+
90
+ def generate_clearance
91
+ generate "clearance:install"
92
+ generate "clearance:features"
93
+ end
94
+
95
+ def install_factory_girl_steps
96
+ copy_file "factory_girl_steps.rb", "features/step_definitions/factory_girl_steps.rb"
97
+ end
98
+
99
+ def setup_stylesheets
100
+ copy_file "app/assets/stylesheets/application.css", "app/assets/stylesheets/application.css.scss"
101
+ remove_file "app/assets/stylesheets/application.css"
102
+ concat_file "import_scss_styles", "app/assets/stylesheets/application.css.scss"
103
+ create_file "app/assets/stylesheets/_screen.scss"
104
+ end
105
+
106
+ def gitignore_files
107
+ concat_file "suspenders_gitignore", ".gitignore"
108
+ ["app/models",
109
+ "app/views/pages",
110
+ "db/migrate",
111
+ "log",
112
+ "public/images",
113
+ "spec/support",
114
+ "spec/lib",
115
+ "spec/models",
116
+ "spec/views",
117
+ "spec/controllers",
118
+ "spec/helpers",
119
+ "spec/support/matchers",
120
+ "spec/support/mixins",
121
+ "spec/support/shared_examples"].each do |dir|
122
+ empty_directory_with_gitkeep dir
123
+ end
124
+ end
125
+
126
+ def copy_miscellaneous_files
127
+ copy_file "errors.rb", "config/initializers/errors.rb"
128
+ copy_file "time_formats.rb", "config/initializers/time_formats.rb"
129
+ copy_file "Procfile"
130
+ end
131
+
132
+ def setup_root_route
133
+ route "root :to => 'Clearance::Sessions#new'"
134
+ end
135
+
136
+ def migrate_database
137
+ rake "db:migrate"
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,123 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Suspenders
5
+ class Generator < Rails::Generators::AppGenerator
6
+ # let's use postgres by default
7
+ class_option :database, :type => :string, :aliases => "-d", :default => "postgresql",
8
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
9
+ # no Test::Unit by default
10
+ class_option :skip_test_unit, :type => :boolean, :aliases => "-T", :default => true,
11
+ :desc => "Skip Test::Unit files"
12
+
13
+ def finish_template
14
+ invoke :suspenders_customization
15
+ super
16
+ end
17
+
18
+ def suspenders_customization
19
+ invoke :remove_files_we_dont_need
20
+ invoke :setup_staging
21
+ invoke :create_suspenders_views
22
+ invoke :create_common_javascripts
23
+ invoke :add_jquery_ui
24
+ invoke :setup_database
25
+ invoke :customize_gemfile
26
+ invoke :configure_app
27
+ invoke :setup_stylesheets
28
+ invoke :setup_gitignore
29
+ invoke :copy_miscellaneous_files
30
+ invoke :setup_root_route
31
+ invoke :migrate_database
32
+ invoke :outro
33
+ end
34
+
35
+ def remove_files_we_dont_need
36
+ build(:remove_public_index)
37
+ build(:remove_public_images_rails)
38
+ end
39
+
40
+ def setup_staging
41
+ say "Setting up the staging environment"
42
+ build(:setup_staging)
43
+ end
44
+
45
+ def create_suspenders_views
46
+ say "Creating suspenders views"
47
+ build(:create_views_shared)
48
+ build(:create_shared_flashes)
49
+ build(:create_shared_javascripts)
50
+ build(:create_application_layout)
51
+ end
52
+
53
+ def create_common_javascripts
54
+ say "Pulling in some common javascripts"
55
+ build(:create_common_javascripts)
56
+ end
57
+
58
+ def add_jquery_ui
59
+ say "Add jQuery ui to the standard application.js"
60
+ build(:add_jquery_ui)
61
+ end
62
+
63
+ def setup_database
64
+ say "Setting up database"
65
+ if 'postgresql' == options[:database]
66
+ build(:use_postgres_config_template)
67
+ end
68
+ build(:create_database)
69
+ end
70
+
71
+ def customize_gemfile
72
+ build(:include_custom_gems)
73
+ end
74
+
75
+ def configure_app
76
+ say "Configuring app"
77
+ build(:configure_rspec)
78
+ build(:configure_action_mailer)
79
+ build(:generate_rspec)
80
+ build(:generate_cucumber)
81
+ build(:generate_clearance)
82
+ build(:install_factory_girl_steps)
83
+ end
84
+
85
+ def setup_stylesheets
86
+ say "Set up stylesheets"
87
+ build(:setup_stylesheets)
88
+ end
89
+
90
+ def setup_gitignore
91
+ say "Ignore the right files"
92
+ build(:gitignore_files)
93
+ end
94
+
95
+ def copy_miscellaneous_files
96
+ say "Copying miscellaneous support files"
97
+ build(:copy_miscellaneous_files)
98
+ end
99
+
100
+ def setup_root_route
101
+ say "Setting up a root route"
102
+ build(:setup_root_route)
103
+ end
104
+
105
+ def migrate_database
106
+ say "Migrating database"
107
+ build(:migrate_database)
108
+ end
109
+
110
+ def outro
111
+ say "Congratulations! You just pulled our suspenders."
112
+ say "Remember to run 'rails generate airbrake' with your API key."
113
+ end
114
+
115
+ protected
116
+ def get_builder_class
117
+ Suspenders::AppBuilder
118
+ end
119
+
120
+ end
121
+ end
122
+
123
+
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'suspenders'
7
- s.version = '0.2.7'
8
- s.date = '2011-10-03'
7
+ s.version = '0.3'
8
+ s.date = '2011-10-21'
9
9
 
10
10
  s.summary = "Generate a Rails app using thoughtbot's best practices."
11
11
  s.description = <<-HERE
@@ -24,9 +24,8 @@ rush to build something amazing; don't use it if you like missing deadlines.
24
24
  s.rdoc_options = ["--charset=UTF-8"]
25
25
  s.extra_rdoc_files = %w[README.md LICENSE]
26
26
 
27
- s.add_dependency('rails', '3.1.0')
27
+ s.add_dependency('rails', '3.1.1')
28
28
  s.add_dependency('bundler', '>= 1.0.7')
29
- s.add_dependency('trout', '>= 0.3.0')
30
29
  s.add_development_dependency('cucumber', '~> 1.0.2')
31
30
 
32
31
  # = MANIFEST =
@@ -38,22 +37,23 @@ rush to build something amazing; don't use it if you like missing deadlines.
38
37
  bin/suspenders
39
38
  features/rake_clean.feature
40
39
  features/step_definitions/shell.rb
41
- lib/create.rb
42
- lib/errors.rb
40
+ lib/suspenders/actions.rb
41
+ lib/suspenders/app_builder.rb
42
+ lib/suspenders/generators/app_generator.rb
43
43
  suspenders.gemspec
44
- template/files/README_FOR_SUSPENDERS
45
- template/files/_flashes.html.erb
46
- template/files/_javascript.html.erb
47
- template/files/cucumber_assertions_hack
48
- template/files/errors.rb
49
- template/files/factory_girl_steps.rb
50
- template/files/import_scss_styles
51
- template/files/postgresql_database.yml.erb
52
- template/files/suspenders_gitignore
53
- template/files/suspenders_layout.html.erb.erb
54
- template/files/time_formats.rb
55
- template/suspenders.rb
56
- template/trout/Gemfile
44
+ templates/Gemfile_additions
45
+ templates/Procfile
46
+ templates/README_FOR_SUSPENDERS
47
+ templates/_flashes.html.erb
48
+ templates/_javascript.html.erb
49
+ templates/errors.rb
50
+ templates/factory_girl_steps.rb
51
+ templates/import_scss_styles
52
+ templates/javascripts/prefilled_input.js
53
+ templates/postgresql_database.yml.erb
54
+ templates/suspenders_gitignore
55
+ templates/suspenders_layout.html.erb.erb
56
+ templates/time_formats.rb
57
57
  ]
58
58
  # = MANIFEST =
59
59
 
@@ -0,0 +1,37 @@
1
+ gem 'thin'
2
+ gem 'sass'
3
+ gem 'clearance', '~> 0.13.0'
4
+ gem 'high_voltage'
5
+ gem 'paperclip'
6
+ gem 'formtastic'
7
+ gem 'flutie'
8
+ gem 'bourbon'
9
+ gem 'copycopter_client'
10
+ gem 'airbrake'
11
+
12
+ group :development do
13
+ gem "heroku"
14
+ end
15
+
16
+ group :development, :test do
17
+ gem "rspec-rails", "~> 2.6.1"
18
+ gem "ruby-debug19"
19
+ gem "sham_rack"
20
+ end
21
+
22
+ group :test do
23
+ gem "cucumber-rails", "1.1.0"
24
+ gem "capybara-webkit", "~> 0.7.1"
25
+ gem "factory_girl_rails"
26
+ gem "bourne"
27
+ gem "database_cleaner"
28
+ gem "timecop"
29
+ gem "shoulda-matchers"
30
+ gem "launchy"
31
+ gem "email_spec"
32
+ end
33
+
34
+ group :staging, :production do
35
+ gem 'newrelic_rpm'
36
+ gem 'sprockets-redirect'
37
+ end
@@ -0,0 +1 @@
1
+ web: bundle exec thin start -p $PORT -e $RACK_ENV
@@ -16,14 +16,6 @@ Then run:
16
16
  This will create a Rails 3 app in `projectname'. This script creates a new
17
17
  new git repository. It is not meant to be used against an existing repo.
18
18
 
19
- Suspenders uses [Trout](https://github.com/thoughtbot/trout) to make it
20
- easier to maintain a base version of special files (like Gemfile) in
21
- Suspenders.
22
-
23
- Whenever you want to get the latest and greatest Suspenders' Gemfile, run:
24
-
25
- trout update Gemfile
26
-
27
19
  Gemfile
28
20
  -------
29
21
 
@@ -60,6 +52,17 @@ Suspenders also comes with:
60
52
  See [template/files](https://github.com/thoughtbot/suspenders/blob/master/template/files) to
61
53
  see what is generated one-time.
62
54
 
55
+ Dependencies
56
+ ------------
57
+
58
+ Some gems included in Suspenders have native extensions. You should have GCC installed on your
59
+ machine before running Suspenders.
60
+ If you're running OS X, we recommend the [GCC OSX installer](https://github.com/kennethreitz/osx-gcc-installer).
61
+ We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for full-stack Javascript integration testing.
62
+ It requires you have QT installed on your machine before running Suspenders.
63
+ Instructions for installing QT on most systems are [available here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT).
64
+
65
+
63
66
  Issues
64
67
  ------
65
68
 
@@ -1,4 +1,4 @@
1
- <%= javascript_include_tag :application, :cache => true %>
1
+ <%= javascript_include_tag :application %>
2
2
 
3
3
  <%= yield :javascript %>
4
4
 
File without changes
@@ -0,0 +1,59 @@
1
+ // clear inputs with starter values
2
+ new function($) {
3
+ $.fn.prefilledInput = function() {
4
+
5
+ var focus = function () {
6
+ $(this).removeClass('prefilled');
7
+ if (this.value == this.prefilledValue) {
8
+ this.value = '';
9
+ }
10
+ };
11
+
12
+ var blur = function () {
13
+ if (this.value == '') {
14
+ $(this).addClass('prefilled').val(this.prefilledValue);
15
+ } else if (this.value != this.prefilledValue) {
16
+ $(this).removeClass('prefilled');
17
+ }
18
+ };
19
+
20
+ var extractPrefilledValue = function () {
21
+ if (this.title) {
22
+ this.prefilledValue = this.title;
23
+ this.title = '';
24
+ } else if (this.id) {
25
+ this.prefilledValue = $('label[for=' + this.id + ']').hide().text();
26
+ }
27
+ if (this.prefilledValue) {
28
+ this.prefilledValue = this.prefilledValue.replace(/\*$/, '');
29
+ }
30
+ };
31
+
32
+ var initialize = function (index) {
33
+ if (!this.prefilledValue) {
34
+ this.extractPrefilledValue = extractPrefilledValue;
35
+ this.extractPrefilledValue();
36
+ $(this).trigger('blur');
37
+ }
38
+ };
39
+
40
+ return this.filter(":input").
41
+ focus(focus).
42
+ blur(blur).
43
+ each(initialize);
44
+ };
45
+
46
+ var clearPrefilledInputs = function () {
47
+ var form = this.form || this;
48
+ $(form).find("input.prefilled, textarea.prefilled").val("");
49
+ };
50
+
51
+ var prefilledSetup = function () {
52
+ $('input.prefilled, textarea.prefilled').prefilledInput();
53
+ $('form').submit(clearPrefilledInputs);
54
+ $('input:submit, button:submit').click(clearPrefilledInputs);
55
+ };
56
+
57
+ $(document).ready(prefilledSetup);
58
+ $(document).ajaxComplete(prefilledSetup);
59
+ }(jQuery);
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title><%%= page_title %></title>
6
- <%%= stylesheet_link_tag :application, :media => 'all', :cache => true %>
6
+ <%%= stylesheet_link_tag :application, :media => 'all' %>
7
7
  <%%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body class="<%%= body_class %>">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suspenders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-03 00:00:00.000000000Z
12
+ date: 2011-10-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2156880180 !ruby/object:Gem::Requirement
16
+ requirement: &2153397980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
20
20
  - !ruby/object:Gem::Version
21
- version: 3.1.0
21
+ version: 3.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156880180
24
+ version_requirements: *2153397980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2156879720 !ruby/object:Gem::Requirement
27
+ requirement: &2153397500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,10 @@ dependencies:
32
32
  version: 1.0.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156879720
36
- - !ruby/object:Gem::Dependency
37
- name: trout
38
- requirement: &2156879080 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: 0.3.0
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *2156879080
35
+ version_requirements: *2153397500
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: cucumber
49
- requirement: &2156878400 !ruby/object:Gem::Requirement
38
+ requirement: &2153396900 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ~>
@@ -54,7 +43,7 @@ dependencies:
54
43
  version: 1.0.2
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *2156878400
46
+ version_requirements: *2153396900
58
47
  description: ! 'Suspenders is a base Rails project that you can upgrade. It is used
59
48
  by
60
49
 
@@ -78,22 +67,23 @@ files:
78
67
  - bin/suspenders
79
68
  - features/rake_clean.feature
80
69
  - features/step_definitions/shell.rb
81
- - lib/create.rb
82
- - lib/errors.rb
70
+ - lib/suspenders/actions.rb
71
+ - lib/suspenders/app_builder.rb
72
+ - lib/suspenders/generators/app_generator.rb
83
73
  - suspenders.gemspec
84
- - template/files/README_FOR_SUSPENDERS
85
- - template/files/_flashes.html.erb
86
- - template/files/_javascript.html.erb
87
- - template/files/cucumber_assertions_hack
88
- - template/files/errors.rb
89
- - template/files/factory_girl_steps.rb
90
- - template/files/import_scss_styles
91
- - template/files/postgresql_database.yml.erb
92
- - template/files/suspenders_gitignore
93
- - template/files/suspenders_layout.html.erb.erb
94
- - template/files/time_formats.rb
95
- - template/suspenders.rb
96
- - template/trout/Gemfile
74
+ - templates/Gemfile_additions
75
+ - templates/Procfile
76
+ - templates/README_FOR_SUSPENDERS
77
+ - templates/_flashes.html.erb
78
+ - templates/_javascript.html.erb
79
+ - templates/errors.rb
80
+ - templates/factory_girl_steps.rb
81
+ - templates/import_scss_styles
82
+ - templates/javascripts/prefilled_input.js
83
+ - templates/postgresql_database.yml.erb
84
+ - templates/suspenders_gitignore
85
+ - templates/suspenders_layout.html.erb.erb
86
+ - templates/time_formats.rb
97
87
  homepage: http://github.com/thoughtbot/suspenders
98
88
  licenses: []
99
89
  post_install_message:
@@ -115,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
105
  version: '0'
116
106
  requirements: []
117
107
  rubyforge_project:
118
- rubygems_version: 1.8.10
108
+ rubygems_version: 1.8.6
119
109
  signing_key:
120
110
  specification_version: 2
121
111
  summary: Generate a Rails app using thoughtbot's best practices.
@@ -1,80 +0,0 @@
1
- # Methods needed to create a project.
2
-
3
- require 'rubygems'
4
- require File.expand_path(File.dirname(__FILE__) + "/errors")
5
-
6
- module Suspenders
7
- class Create
8
- attr_accessor :project_path, :repo
9
-
10
- def self.run!(project_path, repo)
11
- creator = self.new(project_path, repo)
12
- creator.create_project!
13
- end
14
-
15
- def initialize(project_path, repo)
16
- self.project_path = project_path
17
- validate_project_path
18
- validate_project_name
19
- self.repo = repo if present?(repo)
20
- end
21
-
22
- def create_project!
23
- command = <<-COMMAND
24
- rails #{rails_version} new #{project_path} \
25
- --template=#{template} \
26
- --skip-test-unit \
27
- --skip-prototype \
28
- --database=postgresql
29
- COMMAND
30
- command_with_repo = if repo
31
- "REPO='#{repo}' #{command}"
32
- else
33
- command
34
- end
35
- exec(command_with_repo)
36
- end
37
-
38
- private
39
-
40
- def validate_project_name
41
- project_name = File.basename(project_path)
42
- unless project_name =~ /^[a-z0-9_]+$/
43
- raise InvalidInput.new("Project name must only contain [a-z0-9_]")
44
- end
45
- end
46
-
47
- def validate_project_path
48
- base_directory = Dir.pwd
49
- full_path = File.join(base_directory, project_path)
50
-
51
- # This is for the common case for the user's convenience; the race
52
- # condition can still occur.
53
- if File.exists?(full_path)
54
- raise InvalidInput.new("Project directory (#{project_path}) already exists")
55
- end
56
- end
57
-
58
- def template
59
- File.expand_path(File.dirname(__FILE__) + "/../template/suspenders.rb")
60
- end
61
-
62
- def gemfile
63
- File.expand_path(File.dirname(__FILE__) + "/../template/trout/Gemfile")
64
- end
65
-
66
- def rails_version
67
- gemfile_contents = File.read(gemfile)
68
- gemfile_contents =~ /gem "rails", "(.*)"/
69
- if $1.nil? || $1 == ''
70
- ''
71
- else
72
- "_#{$1}_"
73
- end
74
- end
75
-
76
- def present?(string)
77
- string && string != ''
78
- end
79
- end
80
- end
@@ -1,12 +0,0 @@
1
- # User errors
2
-
3
- module Suspenders
4
- class InvalidInput < Exception; end
5
-
6
- module Errors
7
- def error_with_message(msg)
8
- STDERR.puts msg
9
- exit 1
10
- end
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- if RUBY_VERSION =~ /1.8/
2
- require 'test/unit/testresult'
3
- Test::Unit.run = true
4
- end
@@ -1,165 +0,0 @@
1
- # Suspenders
2
- # =============
3
- # by thoughtbot
4
-
5
- require 'net/http'
6
- require 'net/https'
7
-
8
- template_root = File.expand_path(File.join(File.dirname(__FILE__)))
9
- source_paths << File.join(template_root, "files")
10
-
11
- # Helpers
12
-
13
- def concat_file(source, destination)
14
- contents = IO.read(find_in_source_paths(source))
15
- append_file destination, contents
16
- end
17
-
18
- def replace_in_file(relative_path, find, replace)
19
- path = File.join(destination_root, relative_path)
20
- contents = IO.read(path)
21
- unless contents.gsub!(find, replace)
22
- raise "#{find.inspect} not found in #{relative_path}"
23
- end
24
- File.open(path, "w") { |file| file.write(contents) }
25
- end
26
-
27
- def action_mailer_host(rails_env, host)
28
- inject_into_file(
29
- "config/environments/#{rails_env}.rb",
30
- "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
31
- :before => "\nend"
32
- )
33
- end
34
-
35
- def download_file(uri_string, destination)
36
- uri = URI.parse(uri_string)
37
- http = Net::HTTP.new(uri.host, uri.port)
38
- http.use_ssl = true if uri_string =~ /^https/
39
- request = Net::HTTP::Get.new(uri.path)
40
- contents = http.request(request).body
41
- path = File.join(destination_root, destination)
42
- File.open(path, "w") { |file| file.write(contents) }
43
- end
44
-
45
- def origin
46
- if ENV['REPO'].present?
47
- ENV['REPO']
48
- else
49
- "git://github.com/thoughtbot/suspenders.git"
50
- end
51
- end
52
-
53
- def trout(destination_path)
54
- run "trout checkout --source-root=template/trout #{destination_path} #{origin}"
55
- end
56
-
57
- say "Getting rid of files we don't use"
58
-
59
- remove_file "README"
60
- remove_file "public/index.html"
61
- remove_file "public/images/rails.png"
62
-
63
- say "Setting up the staging environment"
64
-
65
- run "cp config/environments/production.rb config/environments/staging.rb"
66
-
67
- say "Creating suspenders views"
68
-
69
- empty_directory "app/views/shared"
70
- copy_file "_flashes.html.erb", "app/views/shared/_flashes.html.erb"
71
- copy_file "_javascript.html.erb", "app/views/shared/_javascript.html.erb"
72
- template "suspenders_layout.html.erb.erb",
73
- "app/views/layouts/application.html.erb",
74
- :force => true
75
-
76
- say "Get ready for bundler... (this will take a while)"
77
-
78
- trout 'Gemfile'
79
- run "bundle install"
80
-
81
- say "Pulling in some common javascripts"
82
-
83
- trout "app/assets/javascripts/prefilled_input.js"
84
-
85
- say "Add jQuery ui to the standard application.js"
86
-
87
- inject_into_file "app/assets/javascripts/application.js", "//= require jquery-ui\n", :before => "//= require_tree ."
88
-
89
- say "Documentation"
90
-
91
- copy_file "README_FOR_SUSPENDERS", "doc/README_FOR_SUSPENDERS"
92
-
93
- say "Let's use PostgreSQL"
94
-
95
- template "postgresql_database.yml.erb", "config/database.yml", :force => true
96
- rake "db:create"
97
-
98
- say "Setting up plugins"
99
-
100
- generators_config = <<-RUBY
101
- config.generators do |generate|
102
- generate.test_framework :rspec
103
- end
104
- RUBY
105
- inject_into_class "config/application.rb", "Application", generators_config
106
-
107
- action_mailer_host "development", "#{app_name}.local"
108
- action_mailer_host "test", "example.com"
109
- action_mailer_host "staging", "staging.#{app_name}.com"
110
- action_mailer_host "production", "#{app_name}.com"
111
-
112
- generate "rspec:install"
113
- generate "cucumber:install", "--rspec --capybara"
114
- generate "clearance:install"
115
- generate "clearance:features"
116
-
117
- copy_file "factory_girl_steps.rb", "features/step_definitions/factory_girl_steps.rb"
118
-
119
- replace_in_file "spec/spec_helper.rb", "mock_with :rspec", "mock_with :mocha"
120
-
121
- inject_into_file "features/support/env.rb",
122
- %{Capybara.save_and_open_page_path = 'tmp'\n} +
123
- %{Capybara.javascript_driver = :webkit\n},
124
- :before => %{Capybara.default_selector = :css}
125
-
126
- say "Set up stylesheets"
127
-
128
- copy_file "app/assets/stylesheets/application.css", "app/assets/stylesheets/application.css.scss"
129
- remove_file "app/assets/stylesheets/application.css"
130
- concat_file "import_scss_styles", "app/assets/stylesheets/application.css.scss"
131
- create_file "app/assets/stylesheets/_screen.scss"
132
-
133
- say "Ignore the right files"
134
-
135
- concat_file "suspenders_gitignore", ".gitignore"
136
- concat_file "cucumber_assertions_hack", "features/support/env.rb"
137
-
138
- ["app/models",
139
- "app/views/pages",
140
- "db/migrate",
141
- "log",
142
- "public/images",
143
- "spec/support",
144
- "spec/lib",
145
- "spec/models",
146
- "spec/views",
147
- "spec/controllers",
148
- "spec/helpers",
149
- "spec/support/matchers",
150
- "spec/support/mixins",
151
- "spec/support/shared_examples"].each do |dir|
152
- empty_directory_with_gitkeep dir
153
- end
154
-
155
- say "Copying miscellaneous support files"
156
-
157
- copy_file "errors.rb", "config/initializers/errors.rb"
158
- copy_file "time_formats.rb", "config/initializers/time_formats.rb"
159
-
160
- say "Setting up a root route"
161
-
162
- route "root :to => 'Clearance::Sessions#new'"
163
-
164
- say "Congratulations! You just pulled our suspenders."
165
- say "Remember to run 'rails generate airbrake' with your API key."
@@ -1,48 +0,0 @@
1
- source :rubygems
2
-
3
- gem "rails", "3.1.0"
4
-
5
- # Gems used only for assets and not required
6
- # in production environments by default.
7
- group :assets do
8
- gem "sass-rails", " ~> 3.1.0"
9
- gem "coffee-rails", "~> 3.1.0"
10
- gem "uglifier", ">= 1.0.3"
11
- end
12
-
13
- gem "pg"
14
- gem "jquery-rails"
15
- gem "sass"
16
- gem "RedCloth", :require => "redcloth"
17
- gem "clearance", "~> 0.11.1"
18
- gem "high_voltage"
19
- gem "paperclip"
20
- gem "formtastic"
21
- gem "flutie"
22
- gem "bourbon"
23
- gem "airbrake"
24
- gem "dynamic_form"
25
-
26
- gem "rake", "0.9.2"
27
-
28
- # RSpec needs to be in :development group to expose generators
29
- # and rake tasks without having to type RAILS_ENV=test.
30
- group :development, :test do
31
- gem "rspec-rails", "~> 2.6.1"
32
- gem "ruby-debug", :platforms => :mri_18
33
- end
34
-
35
- group :test do
36
- gem "cucumber-rails", "1.0.2"
37
- gem "factory_girl_rails"
38
- gem "bourne"
39
- gem "database_cleaner"
40
- gem "fakeweb"
41
- gem "sham_rack"
42
- gem "timecop"
43
- gem "treetop"
44
- gem "shoulda-matchers"
45
- gem "launchy"
46
- gem "capybara-webkit"
47
- gem "thin"
48
- end