valley-rails-generator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTcyMTMxNWFjNTgwOTZlMTkzYzE4MzI4ZmM0NDliNDdmZDhlMjc3Mg==
5
+ data.tar.gz: !binary |-
6
+ N2Q4YWUwYWJmN2VlNGFiNmI5YWI0ZjRmODNlYzZjNDliOWQ0YWE3YQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MzhkYzNhZTYyM2Y2OTNkZDRlNjE1YWRmODhlOTI4MDg2NmI3ZGI1YmE3YzAw
10
+ MzVjZjk1MWIxMmQ1ZTZlYjhkOGY0MjQ3ZWQ3ZDU2YmU5YTA2OTkyNDlkM2Nm
11
+ MThmMGI2OWUyYzZiYjYwZDI3MDZiMGFjYzAwZTA2YTI4NjEwMWQ=
12
+ data.tar.gz: !binary |-
13
+ ZWQ5ZmZmMjM0N2UwYWI0ZGU1MWUwNWExOWYyMGM3OWI1ZTNjYTliZWEwOTA4
14
+ Y2Q3NTQ3MzQ4M2ZhMDhkOWFiZDI1ZWFjYjBmMjNkYjZhYjlkZDBlZmNhOWZj
15
+ OTAwY2Q5MWM5OWQyMWQwZWZkOWZkYWI2NTJlYzMzMGVhMGVkN2Q=
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ Valley Rails Generator
2
+ ======================
3
+
4
+ The Valley Rails Generator is a project heavily based on [suspenders](https://github.com/thoughtbot/suspenders) by thoughtbot
5
+ and used to generate our base rails applications at OSU Libraries & Press.
6
+
7
+ It includes our common testing solutions and what we consider "best practice" defaults.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ Install the gem
13
+
14
+ ```
15
+ gem install valley-rails-generator
16
+ ```
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', 'lib', 'valley-rails-generator', 'generators', 'app_generator'), File.dirname(__FILE__))
4
+ require File.expand_path(File.join('..', 'lib', 'valley-rails-generator', 'actions'), File.dirname(__FILE__))
5
+ require File.expand_path(File.join('..', 'lib', 'valley-rails-generator', 'app_builder'), File.dirname(__FILE__))
6
+
7
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
8
+ ValleyRailsGenerator::AppGenerator.source_root templates_root
9
+ ValleyRailsGenerator::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
10
+
11
+ ValleyRailsGenerator::AppGenerator.start
@@ -0,0 +1,40 @@
1
+ module ValleyRailsGenerator
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
+ host_config = "config.action_mailer.default_url_option = { host: '#{host}' }"
19
+ configure_environment(rails_env, host_config)
20
+ end
21
+
22
+ def configure_environment(rails_env, config)
23
+ inject_into_file(
24
+ "config/environments/#{rails_env}.rb",
25
+ "\n\n #{config}",
26
+ before: "\nend"
27
+ )
28
+ end
29
+
30
+ def download_file(uri_string, destination)
31
+ uri = URI.parse(uri_string)
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.use_ssl = true if uri_string =~ /^https/
34
+ request = Net::HTTP::Get.new(uri.path)
35
+ contents = http.request(request).body
36
+ path = File.join(destination_root, destination)
37
+ File.open(path, "w") { |file| file.write(contents) }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,291 @@
1
+ module ValleyRailsGenerator
2
+ class AppBuilder < Rails::AppBuilder
3
+ include ValleyRailsGenerator::Actions
4
+
5
+ def readme
6
+ template 'README.md.erb', 'README.md'
7
+ end
8
+
9
+ def remove_public_index
10
+ remove_file 'public/index.html'
11
+ end
12
+
13
+ def remove_rails_logo_image
14
+ remove_file 'app/assets/images/rails.png'
15
+ end
16
+
17
+ def raise_on_delivery_errors
18
+ replace_in_file 'config/environments/development.rb',
19
+ 'raise_delivery_errors = false', 'raise_delivery_errors = true'
20
+ end
21
+
22
+ def raise_on_unpermitted_parameters
23
+ configure_environment 'development',
24
+ 'config.action_controller.action_on_unpermitted_parameters = :raise'
25
+ end
26
+
27
+ def enable_factory_girl_syntax
28
+ copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
29
+ end
30
+
31
+ def test_factories_first
32
+ copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
33
+ append_file 'Rakefile', factories_spec_rake_task
34
+ end
35
+
36
+ def configure_smtp
37
+ copy_file 'smtp.rb', 'config/initializers/smtp.rb'
38
+
39
+ prepend_file 'config/environments/production.rb',
40
+ "require Rails.root.join('config/initializers/smtp')\n"
41
+
42
+ config = <<-RUBY
43
+
44
+ config.action_mailer.delivery_method = :smtp
45
+ config.action_mailer.smtp_settings = SMTP_SETTINGS
46
+ RUBY
47
+
48
+ inject_into_file 'config/environments/production.rb', config,
49
+ :after => 'config.action_mailer.raise_delivery_errors = false'
50
+ end
51
+
52
+ def initialize_on_precompile
53
+ inject_into_file 'config/application.rb',
54
+ "\n config.assets.initialize_on_precompile = false",
55
+ :after => 'config.assets.enabled = true'
56
+ end
57
+
58
+ def create_partials_directory
59
+ empty_directory 'app/views/application'
60
+ end
61
+
62
+ def create_shared_flashes
63
+ copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
64
+ end
65
+ # CHANGE?
66
+ def create_shared_javascripts
67
+ copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
68
+ end
69
+
70
+ def create_application_layout
71
+ template 'valley_layout.html.erb.erb',
72
+ 'app/views/layouts/application.html.erb',
73
+ :force => true
74
+ end
75
+ # CHANGE
76
+ def create_common_javascripts
77
+ directory 'javascripts', 'app/assets/javascripts'
78
+ end
79
+
80
+ def add_jquery_ui
81
+ inject_into_file 'app/assets/javascripts/application.js',
82
+ "//= require jquery-ui\n", :before => '//= require_tree .'
83
+ end
84
+
85
+ def use_postgres_config_template
86
+ template 'postgresql_database.yml.erb', 'config/database.yml',
87
+ :force => true
88
+ end
89
+
90
+ def use_mysql_config_template
91
+ template 'mysql_database.yml.erb', 'config/database.yml',
92
+ :force => true
93
+ end
94
+
95
+ def use_sqlite3_config_templatje
96
+ template 'sqlite3_database.yml.erb', 'config/database.yml',
97
+ :force => true
98
+ end
99
+
100
+ def create_database
101
+ bundle_command 'exec rake db:create'
102
+ end
103
+
104
+ def replace_gemfile
105
+ remove_file 'Gemfile'
106
+ copy_file 'Gemfile_clean', 'Gemfile'
107
+ end
108
+
109
+ def set_ruby_to_version_being_used
110
+ inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
111
+ after: /source 'https:\/\/rubygems.org'/
112
+ end
113
+
114
+ def enable_database_cleaner
115
+ replace_in_file 'spec/spec_helper.rb',
116
+ 'config.use_transactional_fixtures = true',
117
+ 'config.use_transactional_fixtures = false'
118
+
119
+ copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
120
+ end
121
+
122
+ def configure_rspec
123
+ remove_file '.rspec'
124
+ copy_file 'rspec', '.rspec'
125
+ prepend_file 'spec/spec_helper.rb', simplecov_init
126
+
127
+ rspec_expect_syntax = <<-RUBY
128
+
129
+ config.expect_with :rspec do |c|
130
+ c.syntax = :should
131
+ end
132
+ RUBY
133
+
134
+ config = <<-RUBY
135
+ config.generators do |generate|
136
+ generate.test_framework :rspec
137
+ generate.helper false
138
+ generate.stylesheets false
139
+ generate.javascript_engine false
140
+ generate.view_specs false
141
+ end
142
+
143
+ RUBY
144
+
145
+ inject_into_file 'spec/spec_helper.rb', rspec_expect_syntax,
146
+ :after => 'RSpec.configure do |config|'
147
+ inject_into_class 'config/application.rb', 'Application', config
148
+ end
149
+
150
+ def configure_background_jobs_for_rspec
151
+ copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
152
+ run 'rails g delayed_job:active_record'
153
+ end
154
+
155
+ def blacklist_active_record_attributes
156
+ replace_in_file 'config/application.rb',
157
+ 'config.active_record.whitelist_attributes = true',
158
+ 'config.active_record.whitelist_attributes = false'
159
+ end
160
+
161
+ def configure_strong_parameters
162
+ copy_file 'strong_parameters.rb', 'config/initializers/strong_parameters.rb'
163
+ end
164
+
165
+ def configure_time_zone
166
+ config = <<-RUBY
167
+ config.active_record.default_timezone = :utc
168
+
169
+ RUBY
170
+ inject_into_class 'config/application.rb', 'Application', config
171
+ end
172
+
173
+ def configure_time_formats
174
+ remove_file 'config/locales/en.yml'
175
+ copy_file 'config_locales_en.yml', 'config/locales/en.yml'
176
+ end
177
+
178
+ def configure_action_mailer
179
+ action_mailer_host 'development', "#{app_name}.local"
180
+ action_mailer_host 'test', 'www.example.com'
181
+ #action_mailer_host 'staging', "staging.#{app_name}.com"
182
+ action_mailer_host 'production', "#{app_name}.com"
183
+ end
184
+
185
+ def generate_rspec
186
+ generate 'rspec:install'
187
+ end
188
+ # Stop using this - switch to PhantomJS/Poltergeist
189
+ def configure_capybara_webkit
190
+ append_file 'spec/spec_helper.rb' do
191
+ "\nCapybara.javascript_driver = :webkit"
192
+ end
193
+ end
194
+ def configure_poltergeist
195
+ append_file 'spec/spec_helper.rb' do
196
+ "\nCapybara.javascript_driver = :poltergeist"
197
+ end
198
+ end
199
+
200
+ def setup_stylesheets
201
+ copy_file 'app/assets/stylesheets/application.css',
202
+ 'app/assets/stylesheets/application.css.scss'
203
+ remove_file 'app/assets/stylesheets/application.css'
204
+ concat_file 'import_scss_styles', 'app/assets/stylesheets/application.css.scss'
205
+ end
206
+
207
+ def gitignore_files
208
+ concat_file 'valley_gitignore', '.gitignore'
209
+ [
210
+ 'app/models',
211
+ 'app/assets/images',
212
+ 'app/views/pages',
213
+ 'db/migrate',
214
+ 'log',
215
+ 'spec/support',
216
+ 'spec/lib',
217
+ 'spec/models',
218
+ 'spec/views',
219
+ 'spec/controllers',
220
+ 'spec/helpers',
221
+ 'spec/support/matchers',
222
+ 'spec/support/mixins',
223
+ 'spec/support/shared_examples',
224
+ 'spec/factories',
225
+ 'db'
226
+ ].each do |dir|
227
+ empty_directory_with_gitkeep dir
228
+ end
229
+ end
230
+
231
+ def init_git
232
+ run 'git init'
233
+ end
234
+
235
+ # Figure out what this does.
236
+ def copy_miscellaneous_files
237
+ copy_file 'errors.rb', 'config/initializers/errors.rb'
238
+ end
239
+
240
+ def customize_error_pages
241
+ meta_tags =<<-EOS
242
+ <meta charset='utf-8' />
243
+ <meta name='ROBOTS' content='NOODP' />
244
+ EOS
245
+ style_tags =<<-EOS
246
+ <link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
247
+ EOS
248
+
249
+ %w(500 404 422).each do |page|
250
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
251
+ replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
252
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
253
+ end
254
+ end
255
+
256
+ def remove_routes_comment_lines
257
+ replace_in_file 'config/routes.rb',
258
+ /Application\.routes\.draw do.*end/m,
259
+ "Application.routes.draw do\nend"
260
+ end
261
+
262
+ def add_email_validator
263
+ copy_file 'email_validator.rb', 'app/validators/email_validator.rb'
264
+ end
265
+
266
+ def disable_xml_params
267
+ copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
268
+ end
269
+
270
+ def setup_default_rake_task
271
+ append_file 'Rakefile' do
272
+ "task(:default).clear\ntask :default => [:spec]"
273
+ end
274
+ end
275
+
276
+ def setup_guard
277
+ copy_file 'Guardfile_example', 'Guardfile'
278
+ copy_file 'spring.rb', 'config/spring.rb'
279
+ end
280
+
281
+ private
282
+
283
+ def factories_spec_rake_task
284
+ IO.read find_in_source_paths('factories_spec_rake_task.rb')
285
+ end
286
+
287
+ def simplecov_init
288
+ IO.read find_in_source_paths('simplecov_init.rb')
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,182 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module ValleyRailsGenerator
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, :type => :string, :aliases => '-d', :default => 'sqlite3',
7
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
8
+
9
+ class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
10
+ :desc => 'Skip Test::Unit files'
11
+
12
+ def finish_template
13
+ invoke :valley_customization
14
+ super
15
+ end
16
+
17
+ def valley_customization
18
+ invoke :remove_files_we_dont_need
19
+ invoke :customize_gemfile
20
+ invoke :setup_database
21
+ invoke :setup_development_environment
22
+ invoke :setup_test_environment
23
+ invoke :setup_production_environment
24
+ invoke :setup_staging_environment
25
+ invoke :create_valley_views
26
+ #invoke :create_common_javascripts
27
+ #invoke :add_jquery_ui
28
+ invoke :configure_app
29
+ invoke :setup_stylesheets
30
+ invoke :copy_miscellaneous_files
31
+ invoke :customize_error_pages
32
+ invoke :remove_routes_comment_lines
33
+ invoke :setup_git
34
+ invoke :outro
35
+ end
36
+
37
+ def remove_files_we_dont_need
38
+ build :remove_public_index
39
+ build :remove_rails_logo_image
40
+ end
41
+
42
+ def customize_gemfile
43
+ build :replace_gemfile
44
+ build :set_ruby_to_version_being_used
45
+ bundle_command 'install --binstubs=bin/stubs'
46
+ end
47
+
48
+ def setup_database
49
+ say 'Setting up database'
50
+
51
+ if 'postgresql' == options[:database]
52
+ build :use_postgres_config_template
53
+ end
54
+
55
+ if 'mysql' == options[:database]
56
+ build :use_mysql_config_template
57
+ end
58
+
59
+ if 'sqlite3' == options[:database]
60
+ build :use_sqlite3_config_template
61
+ end
62
+
63
+ build :create_database
64
+ end
65
+
66
+ def setup_development_environment
67
+ say 'Setting up the development environment'
68
+ build :raise_on_delivery_errors
69
+ build :raise_on_unpermitted_parameters
70
+ end
71
+
72
+ def setup_test_environment
73
+ say 'Setting up the test environment'
74
+ build :enable_factory_girl_syntax
75
+ build :test_factories_first
76
+ build :generate_rspec
77
+ build :configure_rspec
78
+ build :enable_database_cleaner
79
+ build :configure_poltergeist
80
+ build :setup_guard
81
+ end
82
+
83
+ def setup_production_environment
84
+ say 'Setting up the production environment'
85
+ build :configure_smtp
86
+ end
87
+
88
+ def setup_staging_environment
89
+ say 'Setting up the staging environment'
90
+ build :initialize_on_precompile
91
+ end
92
+
93
+ def create_valley_views
94
+ say 'Creating valley views'
95
+ build :create_partials_directory
96
+ build :create_shared_flashes
97
+ build :create_shared_javascripts
98
+ build :create_application_layout
99
+ end
100
+
101
+ def configure_app
102
+ say 'Configuring app'
103
+ build :configure_action_mailer
104
+ build :blacklist_active_record_attributes
105
+ build :configure_time_zone
106
+ build :configure_time_formats
107
+ build :disable_xml_params
108
+ build :add_email_validator
109
+ build :setup_default_rake_task
110
+ end
111
+
112
+ def setup_stylesheets
113
+ say 'Set up stylesheets'
114
+ build :setup_stylesheets
115
+ end
116
+
117
+ def setup_git
118
+ say 'Initializing git'
119
+ invoke :setup_gitignore
120
+ invoke :init_git
121
+ end
122
+
123
+ def create_heroku_apps
124
+ if options[:heroku]
125
+ say 'Creating Heroku apps'
126
+ build :create_heroku_apps
127
+ end
128
+ end
129
+
130
+ def create_github_repo
131
+ if options[:github]
132
+ say 'Creating Github repo'
133
+ build :create_github_repo, options[:github]
134
+ end
135
+ end
136
+
137
+ def setup_gitignore
138
+ build :gitignore_files
139
+ end
140
+
141
+ def init_git
142
+ build :init_git
143
+ end
144
+
145
+ def copy_libraries
146
+ say 'Copying libraries'
147
+ build :copy_libraries
148
+ end
149
+
150
+ def copy_miscellaneous_files
151
+ say 'Copying miscellaneous support files'
152
+ build :copy_miscellaneous_files
153
+ end
154
+
155
+ def customize_error_pages
156
+ say 'Customizing the 500/404/422 pages'
157
+ build :customize_error_pages
158
+ end
159
+
160
+ def remove_routes_comment_lines
161
+ build :remove_routes_comment_lines
162
+ end
163
+
164
+ def outro
165
+ say 'Generation Complete'
166
+ end
167
+
168
+ def run_bundle
169
+ # Let's not: We'll bundle manually at the right spot
170
+ end
171
+
172
+ protected
173
+
174
+ def get_builder_class
175
+ ValleyRailsGenerator::AppBuilder
176
+ end
177
+
178
+ def using_active_record?
179
+ !options[:skip_active_record]
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,3 @@
1
+ module ValleyRailsGenerator
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,37 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jquery-rails'
4
+ gem 'mysql2'
5
+ gem 'sqlite3'
6
+ gem 'rails', '>= 3.2.12'
7
+ gem 'simple_form'
8
+ gem 'yard'
9
+ gem 'active_model_serializers', '~> 0.7.0'
10
+
11
+ group :assets do
12
+ gem 'coffee-rails'
13
+ gem 'sass-rails'
14
+ gem 'uglifier'
15
+ end
16
+
17
+ group :development do
18
+ gem 'better_errors'
19
+ gem 'binding_of_caller'
20
+ gem 'jazz_hands'
21
+ gem 'meta_request'
22
+ end
23
+
24
+ group :development, :test do
25
+ gem 'factory_girl_rails'
26
+ gem 'rspec-rails'
27
+ gem 'spring'
28
+ gem 'guard'
29
+ gem 'guard-rspec'
30
+ end
31
+
32
+ group :test do
33
+ gem 'poltergeist'
34
+ gem 'database_cleaner'
35
+ gem 'shoulda-matchers'
36
+ gem 'simplecov', require: false
37
+ end
@@ -0,0 +1,22 @@
1
+ guard 'rspec', :cli => '--color --drb --format documentation', :env => {'SPRING_TMP_PATH' => "/tmp"}, :spring => true do
2
+ watch('config/routes.rb')
3
+ watch(%r{^spec/.+_spec.rb$})
4
+ watch(%r{^lib/(.+).rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
5
+ watch('spec/spec_helper.rb') { 'spec' }
6
+
7
+ # Rails example
8
+ watch(%r{^app/(.+).rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch(%r{^app/(.*)(.erb|.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
10
+ watch(%r{^app/controllers/(.+)_(controller).rb$}) { |m| %W(spec/routing/#{m[1]}_routing_spec.rb spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb spec/acceptance/#{m[1]}_spec.rb) }
11
+ watch(%r{^spec/support/(.+).rb$}) { 'spec' }
12
+ watch('config/routes.rb') { 'spec/routing' }
13
+ watch('app/controllers/application_controller.rb') { 'spec/controllers' }
14
+ watch(%r{^spec/factories/.+.rb$}) { 'spec' }
15
+
16
+ # Capybara features specs
17
+ watch(%r{^app/views/(.+)/.*.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
18
+
19
+ # Turnip features and steps
20
+ watch(%r{^spec/acceptance/(.+).feature$})
21
+ watch(%r{^spec/acceptance/steps/(.+)_steps.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
22
+ end
@@ -0,0 +1,4 @@
1
+ Generated by Valley Rails Generator
2
+ ============================
3
+
4
+ Follow the developer guidelines here: https://github.com/osulp/Dev-Standards
@@ -0,0 +1,5 @@
1
+ <div id="flash">
2
+ <% flash.each do |key, value| -%>
3
+ <div id="flash_<%= key %>"><%= value %></div>
4
+ <% end -%>
5
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
@@ -0,0 +1,11 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default: '%m/%d/%Y'
5
+ with_weekday: '%a %m/%d/%y'
6
+
7
+ time:
8
+ formats:
9
+ default: '%a, %b %-d, %Y at %r'
10
+ date: '%b %-d, %Y'
11
+ short: '%B %d'
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, :js => true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,7 @@
1
+ class EmailValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
4
+ record.errors[attribute] << (options[:message] || "is not an email")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ require 'net/http'
2
+ require 'net/smtp'
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [Timeout::Error,
12
+ Errno::EINVAL,
13
+ Errno::ECONNRESET,
14
+ EOFError,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError]
18
+
19
+ SMTP_SERVER_ERRORS = [TimeoutError,
20
+ IOError,
21
+ Net::SMTPUnknownError,
22
+ Net::SMTPServerBusy,
23
+ Net::SMTPAuthenticationError]
24
+
25
+ SMTP_CLIENT_ERRORS = [Net::SMTPFatalError,
26
+ Net::SMTPSyntaxError]
27
+
28
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'validate FactoryGirl factories' do
4
+ FactoryGirl.factories.each do |factory|
5
+ context "with factory for :#{factory.name}" do
6
+ subject { FactoryGirl.build(factory.name) }
7
+
8
+ it 'is valid' do
9
+ is_valid = subject.valid?
10
+ expect(is_valid).to be_true, subject.errors.full_messages.join(',')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ if defined?(RSpec)
2
+ desc 'Run factory specs.'
3
+ RSpec::Core::RakeTask.new(:factory_specs) do |t|
4
+ t.pattern = './spec/models/factories_spec.rb'
5
+ end
6
+
7
+ task spec: :factory_specs
8
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
File without changes
@@ -0,0 +1,18 @@
1
+ development: &default
2
+ adapter: <%%= ENV["<%= app_name.upcase %>_ADAPTER"] || "mysql2" %>
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: 5
7
+ timeout: 5000
8
+ username: <%%= ENV["<%= app_name.upcase %>_DB_USERNAME"] %>
9
+ password: <%%= ENV["<%= app_name.upcase %>_DB_PASSWORD"] %>
10
+ host: <%%= ENV["<%= app_name.upcase %>_DB_HOST"] %>
11
+
12
+ test:
13
+ <<: *default
14
+ database: <%= app_name %>_test
15
+
16
+ production:
17
+ <<: *default
18
+ database: <%= app_name %>_production
@@ -0,0 +1,11 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ test:
10
+ <<: *default
11
+ database: <%= app_name %>_test
data/templates/rspec ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --drb
3
+ --profile
@@ -0,0 +1,2 @@
1
+ require 'simplecov'
2
+ SimpleCov.start 'rails'
data/templates/smtp.rb ADDED
@@ -0,0 +1,10 @@
1
+ if Rails.env.staging? || Rails.env.production?
2
+ SMTP_SETTINGS = {
3
+ address: ENV['SMTP_ADDRESS'], # example: 'smtp.sendgrid.net'
4
+ authentication: :plain,
5
+ domain: ENV['SMTP_DOMAIN'], # example: 'this-app.com'
6
+ password: ENV['SMTP_PASSWORD'],
7
+ port: '587',
8
+ user_name: ENV['SMTP_USERNAME']
9
+ }
10
+ end
@@ -0,0 +1,3 @@
1
+ Spring::Commands::RSpec.preloads = []
2
+ Spring.watch "#{File.expand_path File.dirname(__FILE__)}/../spec/factories"
3
+ Spring.watch "#{File.expand_path File.dirname(__FILE__)}/../spec/spec_helper.rb"
@@ -0,0 +1,20 @@
1
+ development: &default
2
+ adapter: sqlite3
3
+ database: db/development.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ test:
8
+ <<: *default
9
+ database: db/test.sqlite3
10
+
11
+ production:
12
+ adapter: <%%= ENV["<%= app_name.upcase %>_ADAPTER"] || "mysql2" %>
13
+ database: <%= app_name %>_production
14
+ encoding: utf8
15
+ min_messages: warning
16
+ pool: 5
17
+ timeout: 5000
18
+ username: <%%= ENV["<%= app_name.upcase %>_DB_USERNAME"] %>
19
+ password: <%%= ENV["<%= app_name.upcase %>_DB_PASSWORD"] %>
20
+ host: <%%= ENV["<%= app_name.upcase %>_DB_HOST"] %>
@@ -0,0 +1,10 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swp
4
+ .env
5
+ bin/stubs
6
+ coverage/*
7
+ public/system
8
+ rerun.txt
9
+ tags
10
+ vendor/bundler_gems
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="ROBOTS" content="NOODP" />
6
+ <title><%%= page_title %></title>
7
+ <%%= stylesheet_link_tag :application, :media => 'all' %>
8
+ <%%= csrf_meta_tags %>
9
+ </head>
10
+ <body class="<%%= body_class %>">
11
+ <%%= render 'flashes' -%>
12
+ <%%= yield %>
13
+ <%%= render 'javascript' %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'valley-rails-generator/version'
4
+ require 'date'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.required_ruby_version = '>= 1.9.2'
8
+ s.add_dependency 'bundler', '~> 1.3'
9
+ s.add_dependency 'rails', '>=3.2.11'
10
+ s.authors = ['osulp']
11
+ s.date = Date.today.strftime('%Y-%m-%d')
12
+
13
+ s.description = <<-HERE
14
+ Valley Rails Generator is a rails generator developed by OSU Libraries & Press
15
+ to speed up the creation of new Rails projects. It contains our commonly-used
16
+ defaults.
17
+ HERE
18
+
19
+ s.email = 'lib.dev@oregonstate.edu'
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
21
+ s.extra_rdoc_files = %w[README.md LICENSE]
22
+ s.files = `git ls-files`.split("\n")
23
+ s.homepage = 'http://github.com/osulp/valley-rails-generator'
24
+ s.name = 'valley-rails-generator'
25
+ s.rdoc_options = ['--charset=UTF-8']
26
+ s.require_paths = ['lib']
27
+ s.summary = "Generates a rails app with OSU Valley Library's defaults."
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.version = ValleyRailsGenerator::VERSION
30
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: valley-rails-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - osulp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.11
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.11
41
+ description: ! 'Valley Rails Generator is a rails generator developed by OSU Libraries
42
+ & Press
43
+
44
+ to speed up the creation of new Rails projects. It contains our commonly-used
45
+
46
+ defaults.
47
+
48
+ '
49
+ email: lib.dev@oregonstate.edu
50
+ executables:
51
+ - valleyrailsgen
52
+ extensions: []
53
+ extra_rdoc_files:
54
+ - README.md
55
+ - LICENSE
56
+ files:
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - bin/valleyrailsgen
61
+ - lib/valley-rails-generator/actions.rb
62
+ - lib/valley-rails-generator/app_builder.rb
63
+ - lib/valley-rails-generator/generators/app_generator.rb
64
+ - lib/valley-rails-generator/version.rb
65
+ - templates/Gemfile_clean
66
+ - templates/Guardfile_example
67
+ - templates/README.md.erb
68
+ - templates/_flashes.html.erb
69
+ - templates/_javascript.html.erb
70
+ - templates/config_locales_en.yml
71
+ - templates/database_cleaner_rspec.rb
72
+ - templates/disable_xml_params.rb
73
+ - templates/email_validator.rb
74
+ - templates/errors.rb
75
+ - templates/factories_spec.rb
76
+ - templates/factories_spec_rake_task.rb
77
+ - templates/factory_girl_syntax_rspec.rb
78
+ - templates/import_scss_styles
79
+ - templates/mysql_database.yml.erb
80
+ - templates/postgresql_database.yml.erb
81
+ - templates/rspec
82
+ - templates/simplecov_init.rb
83
+ - templates/smtp.rb
84
+ - templates/spring.rb
85
+ - templates/sqlite3_database.yml.erb
86
+ - templates/valley_gitignore
87
+ - templates/valley_layout.html.erb.erb
88
+ - valley-rails-generator.gemspec
89
+ homepage: http://github.com/osulp/valley-rails-generator
90
+ licenses: []
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options:
94
+ - --charset=UTF-8
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 1.9.2
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Generates a rails app with OSU Valley Library's defaults.
113
+ test_files: []