raygun 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. data/.ruby-gemset +1 -0
  2. data/.ruby-version +1 -1
  3. data/CHANGES.md +7 -0
  4. data/README.md +3 -1
  5. data/bin/raygun +67 -44
  6. data/cleanup.sh +5 -0
  7. data/lib/colorize.rb +194 -0
  8. data/lib/raygun/version.rb +1 -1
  9. data/rails_32/.ruby-gemset +1 -0
  10. data/rails_32/Gemfile +1 -0
  11. data/rails_32/spec/spec_helper.rb +1 -17
  12. data/rails_32/spec/support/database_cleaner.rb +24 -0
  13. data/rails_40/.env +8 -0
  14. data/rails_40/.gitignore +16 -0
  15. data/rails_40/.rspec +1 -0
  16. data/rails_40/.ruby-gemset +1 -0
  17. data/rails_40/.ruby-version +1 -0
  18. data/rails_40/Gemfile +53 -0
  19. data/rails_40/Guardfile +32 -0
  20. data/rails_40/Procfile +2 -0
  21. data/rails_40/README.md +66 -0
  22. data/rails_40/Rakefile +15 -0
  23. data/rails_40/app/assets/javascripts/application.js +17 -0
  24. data/rails_40/app/assets/stylesheets/_footer.less +30 -0
  25. data/rails_40/app/assets/stylesheets/_navbar.less +5 -0
  26. data/rails_40/app/assets/stylesheets/application.css.less +3 -0
  27. data/rails_40/app/controllers/application_controller.rb +5 -0
  28. data/rails_40/app/controllers/concerns/.keep +0 -0
  29. data/rails_40/app/controllers/pages_controller.rb +6 -0
  30. data/rails_40/app/helpers/application_helper.rb +11 -0
  31. data/rails_40/app/mailers/.keep +0 -0
  32. data/rails_40/app/models/.keep +0 -0
  33. data/rails_40/app/models/concerns/.keep +0 -0
  34. data/rails_40/app/views/layouts/application.html.slim +36 -0
  35. data/rails_40/app/views/pages/root.html.slim +12 -0
  36. data/rails_40/bin/bundle +3 -0
  37. data/rails_40/bin/rails +4 -0
  38. data/rails_40/bin/rake +4 -0
  39. data/rails_40/config/application.rb +36 -0
  40. data/rails_40/config/boot.rb +4 -0
  41. data/rails_40/config/database.yml +15 -0
  42. data/rails_40/config/environment.rb +5 -0
  43. data/rails_40/config/environments/acceptance.rb +82 -0
  44. data/rails_40/config/environments/development.rb +31 -0
  45. data/rails_40/config/environments/production.rb +82 -0
  46. data/rails_40/config/environments/test.rb +38 -0
  47. data/rails_40/config/initializers/backtrace_silencers.rb +7 -0
  48. data/rails_40/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/rails_40/config/initializers/inflections.rb +16 -0
  50. data/rails_40/config/initializers/mailcacher.rb +15 -0
  51. data/rails_40/config/initializers/mime_types.rb +5 -0
  52. data/rails_40/config/initializers/secret_token.rb +12 -0
  53. data/rails_40/config/initializers/session_store.rb +3 -0
  54. data/rails_40/config/initializers/simple_form.rb +142 -0
  55. data/rails_40/config/initializers/simple_form_bootstrap.rb +45 -0
  56. data/rails_40/config/initializers/wrap_parameters.rb +14 -0
  57. data/rails_40/config/locales/en.yml +23 -0
  58. data/rails_40/config/locales/simple_form.en.yml +26 -0
  59. data/rails_40/config/routes.rb +5 -0
  60. data/rails_40/config/unicorn.rb +27 -0
  61. data/rails_40/config.ru +18 -0
  62. data/rails_40/db/sample_data.rb +11 -0
  63. data/rails_40/db/schema.rb +19 -0
  64. data/rails_40/db/seeds.rb +7 -0
  65. data/rails_40/lib/assets/.keep +0 -0
  66. data/rails_40/lib/tasks/.keep +0 -0
  67. data/rails_40/lib/tasks/coverage.rake +10 -0
  68. data/rails_40/lib/tasks/db.rake +7 -0
  69. data/rails_40/lib/tasks/spec.rake +23 -0
  70. data/rails_40/lib/templates/rails/scaffold_controller/controller.rb +61 -0
  71. data/rails_40/lib/templates/rspec/controller/controller_spec.rb +16 -0
  72. data/rails_40/lib/templates/rspec/scaffold/controller_spec.rb +155 -0
  73. data/rails_40/lib/templates/rspec/scaffold/edit_spec.rb +18 -0
  74. data/rails_40/lib/templates/rspec/scaffold/index_spec.rb +26 -0
  75. data/rails_40/lib/templates/rspec/scaffold/new_spec.rb +19 -0
  76. data/rails_40/lib/templates/rspec/scaffold/show_spec.rb +16 -0
  77. data/rails_40/lib/templates/slim/scaffold/_form.html.slim +13 -0
  78. data/rails_40/lib/templates/slim/scaffold/edit.html.slim +5 -0
  79. data/rails_40/lib/templates/slim/scaffold/index.html.slim +29 -0
  80. data/rails_40/lib/templates/slim/scaffold/new.html.slim +4 -0
  81. data/rails_40/lib/templates/slim/scaffold/show.html.slim +17 -0
  82. data/rails_40/log/.keep +0 -0
  83. data/rails_40/public/404.html +58 -0
  84. data/rails_40/public/422.html +58 -0
  85. data/rails_40/public/500.html +57 -0
  86. data/rails_40/public/favicon.ico +0 -0
  87. data/rails_40/public/robots.txt +5 -0
  88. data/rails_40/spec/controllers/pages_controller_spec.rb +12 -0
  89. data/rails_40/spec/features/pages_spec.rb +18 -0
  90. data/rails_40/spec/spec_helper.rb +79 -0
  91. data/rails_40/spec/support/database_cleaner.rb +24 -0
  92. data/rails_40/spec/support/factory_girl.rb +3 -0
  93. data/rails_40/vendor/assets/javascripts/.keep +0 -0
  94. data/rails_40/vendor/assets/stylesheets/.keep +0 -0
  95. metadata +88 -6
  96. data/.rvmrc +0 -1
  97. data/app_prototype/config/routes.rb +0 -21
  98. data/app_prototype/db/schema.rb +0 -54
  99. data/rails_32/.rvmrc +0 -1
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ raygun
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ ruby-1.9.3-p392
data/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.29 [2013-06-14]
4
+
5
+ * Migrate from ```.rvmrc``` to ```.ruby-version``` and ```.ruby-gemset``` (#93).
6
+ * Use database_cleaner instead of the shared connection (#101).
7
+ * Support generating rails 4.0 apps (beta!) using the ```-r 40``` command line flag.
8
+ * Improve and colorize output (#86).
9
+
3
10
  ## 0.0.28 [2013-03-26]
4
11
 
5
12
  * Use unicorn by default instead of thin, as per heroku's recommendation.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/raygun.png)](http://badge.fury.io/rb/raygun)
2
+ [![Code Climate](https://codeclimate.com/github/carbonfive/raygun.png)](https://codeclimate.com/github/carbonfive/raygun)
1
3
  <img src="https://raw.github.com/carbonfive/raygun/master/marvin.jpg" align="right"/>
2
4
 
3
5
  # Raygun
@@ -50,7 +52,7 @@ To run your new application's specs or fire up its server, you'll need to meet t
50
52
  * PhantomJS for JavaScript testing (```brew install phantomjs```)
51
53
 
52
54
  The generated app will be configured to use the ruby version that was used to invoke raygun. If you're using
53
- another ruby, just change the ```Gemfile```, ```.rvmrc``` and/or ```.ruby-version``` as necessary.
55
+ another ruby, just change the ```Gemfile``` and ```.ruby-version``` as necessary.
54
56
 
55
57
  ## Usage
56
58
 
data/bin/raygun CHANGED
@@ -1,20 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
+ require 'ostruct'
4
5
  require 'fileutils'
5
6
  require 'securerandom'
7
+ require 'colorize'
6
8
 
7
9
  module Raygun
8
10
  class Runner
9
- attr_accessor :app_name, :app_dir, :title_name, :snake_name, :camel_name, :dash_name
11
+ attr_accessor :target_dir, :app_dir, :app_name, :dash_name, :snake_name, :camel_name, :title_name, :prototype
10
12
 
11
- def initialize(app_name_arg)
12
- @app_dir = File.expand_path(app_name_arg.strip.to_s)
13
- @app_name = File.basename(app_dir).gsub(/\s+/, '-')
14
- @dash_name = app_name.gsub('_', '-')
13
+ def initialize(target_dir, prototype)
14
+ @target_dir = target_dir
15
+ @app_dir = File.expand_path(target_dir.strip.to_s)
16
+ @app_name = File.basename(app_dir).gsub(/\s+/, '-')
17
+ @dash_name = app_name.gsub('_', '-')
15
18
  @snake_name = app_name.gsub('-', '_')
16
19
  @camel_name = camelize(snake_name)
17
20
  @title_name = titleize(snake_name)
21
+ @prototype = prototype
18
22
  end
19
23
 
20
24
  def check_target
@@ -27,7 +31,7 @@ module Raygun
27
31
  def copy_prototype
28
32
  FileUtils.mkdir_p(app_dir)
29
33
 
30
- Dir.glob(File.expand_path("../../rails_32/*", __FILE__), File::FNM_DOTMATCH) do |f|
34
+ Dir.glob(File.expand_path("../../#{@prototype}/*", __FILE__), File::FNM_DOTMATCH) do |f|
31
35
  next if %w{. ..}.include?(File.basename(f))
32
36
  FileUtils.cp_r(f, app_dir)
33
37
  end
@@ -58,7 +62,7 @@ module Raygun
58
62
  current_ruby_patch_level = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
59
63
 
60
64
  Dir.chdir(app_dir) do
61
- shell "#{sed_i} 's/#{prototype_ruby_patch_level}/#{current_ruby_patch_level}/g' .rvmrc .ruby-version README.md"
65
+ shell "#{sed_i} 's/#{prototype_ruby_patch_level}/#{current_ruby_patch_level}/g' .ruby-version README.md"
62
66
  shell "#{sed_i} 's/#{prototype_ruby_version}/#{current_ruby_version}/g' Gemfile"
63
67
  end
64
68
  end
@@ -72,30 +76,43 @@ module Raygun
72
76
  end
73
77
 
74
78
  def print_plan
79
+
80
+ project_template = prototype == 'rails_32' ? '3.2' : '4'
81
+
82
+ puts ' ____ '.colorize(:light_yellow)
83
+ puts ' / __ \____ ___ ______ ___ ______ '.colorize(:light_yellow)
84
+ puts ' / /_/ / __ `/ / / / __ `/ / / / __ \ '.colorize(:light_yellow)
85
+ puts ' / _, _/ /_/ / /_/ / /_/ / /_/ / / / / '.colorize(:light_yellow)
86
+ puts ' /_/ |_|\__,_/\__, /\__, /\__,_/_/ /_/ '.colorize(:light_yellow)
87
+ puts ' /____//____/ '.colorize(:light_yellow)
88
+ puts
89
+ puts "Creating new app in directory".colorize(:yellow) + " #{target_dir}".colorize(:yellow) + "...".colorize(:yellow)
75
90
  puts
76
- puts "Creating new app #{camel_name} in directory #{app_dir}..."
91
+ puts "-".colorize(:blue) + " Application Name:".colorize(:light_blue) + " #{title_name}".colorize(:light_reen)
92
+ puts "-".colorize(:blue) + " Project Template:".colorize(:light_blue) + " Rails #{project_template}".colorize(:light_reen)
93
+ puts "-".colorize(:blue) + " Ruby Version: ".colorize(:light_blue) + " #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".colorize(:light_reen)
77
94
  puts
78
95
  end
79
96
 
80
97
  def print_next_steps
81
- puts "Done! Next steps..."
98
+ puts "Done! Next steps...".colorize(:yellow)
82
99
  puts ""
83
- puts "# Install updated dependencies"
84
- puts "$ cd #{app_dir}"
85
- puts "$ gem install bundler"
86
- puts "$ bundle update"
100
+ puts "# Install updated dependencies".colorize(:light_green)
101
+ puts "$".colorize(:blue) + " cd #{target_dir}".colorize(:light_blue)
102
+ puts "$".colorize(:blue) + " gem install bundler".colorize(:light_blue)
103
+ puts "$".colorize(:blue) + " bundle update".colorize(:light_blue)
87
104
  puts ""
88
- puts "# Prepare the database: schema and reference / sample data"
89
- puts "$ rake db:setup db:sample_data"
105
+ puts "# Prepare the database: schema and reference / sample data".colorize(:light_green)
106
+ puts "$".colorize(:blue) + " rake db:setup db:sample_data".colorize(:light_blue)
90
107
  puts ""
91
- puts "# Run the specs (they should all pass)"
92
- puts "$ rake"
108
+ puts "# Run the specs (they should all pass)".colorize(:light_green)
109
+ puts "$".colorize(:blue) + " rake".colorize(:light_blue)
93
110
  puts ""
94
- puts "# Run the app and check things out"
95
- puts "$ foreman start"
96
- puts "$ open http://0.0.0.0:3000"
111
+ puts "# Run the app and check things out".colorize(:light_green)
112
+ puts "$".colorize(:blue) + " foreman start".colorize(:light_blue)
113
+ puts "$".colorize(:blue) + " open http://0.0.0.0:3000".colorize(:light_blue)
97
114
  puts ""
98
- puts "Enjoy your Carbon Five flavored Rails application!"
115
+ puts "Enjoy your Carbon Five flavored Rails application!".colorize(:yellow)
99
116
  end
100
117
 
101
118
  protected
@@ -124,37 +141,43 @@ module Raygun
124
141
  raise "#{command} failed with status #{$?.exitstatus}." unless $?.success?
125
142
  end
126
143
 
127
- class << self
128
- def parse(args)
129
- raygun = nil
144
+ def self.parse(args)
145
+ raygun = nil
146
+ options = OpenStruct.new
147
+ options.target_dir = nil
148
+ options.prototype = 'rails_32'
130
149
 
131
- parser = OptionParser.new do |opts|
132
- opts.banner = "Usage: raygun [options] NEW_APP_DIRECTORY"
150
+ parser = OptionParser.new do |opts|
151
+ opts.banner = "Usage: raygun [options] NEW_APP_DIRECTORY"
133
152
 
134
- opts.on("-h", "--help", "Show raygun usage") do |variable|
135
- usage_and_exit(opts)
136
- end
137
-
138
- if ARGV.size == 0
139
- usage_and_exit(opts)
140
- else
141
- raygun = Raygun::Runner.new(ARGV.first)
142
- end
153
+ opts.on('-h', '--help', "Show raygun usage") do |variable|
154
+ usage_and_exit(opts)
143
155
  end
144
156
 
145
- begin
146
- parser.parse!
147
- rescue OptionParser::InvalidOption
148
- usage_and_exit(parser)
157
+ opts.on('-r', '--rails (32|40)', "Rails version, 32 for 3.2.x or 40 for 4.0.x") do |ext|
158
+ ext = '40' if ext = '4'
159
+ options.prototype = "rails_#{ext}"
149
160
  end
150
-
151
- raygun
152
161
  end
153
162
 
154
- def usage_and_exit(parser)
155
- puts parser
156
- exit 1
163
+ begin
164
+ parser.parse!
165
+ options.target_dir = ARGV.first
166
+
167
+ raise OptionParser::InvalidOption if options.target_dir.nil?
168
+
169
+ raygun = Raygun::Runner.new(options.target_dir, options.prototype)
170
+
171
+ rescue OptionParser::InvalidOption
172
+ usage_and_exit(parser)
157
173
  end
174
+
175
+ raygun
176
+ end
177
+
178
+ def self.usage_and_exit(parser)
179
+ puts parser
180
+ exit 1
158
181
  end
159
182
  end
160
183
  end
data/cleanup.sh CHANGED
@@ -11,3 +11,8 @@ rm -rfv rails_32/.DS_Store
11
11
  rm -rfv rails_32/log/*
12
12
  rm -rfv rails_32/tmp/*
13
13
  rm -rfv rails_32/coverage
14
+
15
+ rm -rfv rails_40/.DS_Store
16
+ rm -rfv rails_40/log/*
17
+ rm -rfv rails_40/tmp/*
18
+ rm -rfv rails_40/coverage
data/lib/colorize.rb ADDED
@@ -0,0 +1,194 @@
1
+ #
2
+ # Colorize String class extension.
3
+ #
4
+ # Borrowed directly from the colorize gem. It hasn't changed in 4 years and I didn't
5
+ # want to add a gem dependency.
6
+
7
+ class String
8
+
9
+ #
10
+ # Colors Hash
11
+ #
12
+ COLORS = {
13
+ :black => 0,
14
+ :red => 1,
15
+ :green => 2,
16
+ :yellow => 3,
17
+ :blue => 4,
18
+ :magenta => 5,
19
+ :cyan => 6,
20
+ :white => 7,
21
+ :default => 9,
22
+
23
+ :light_black => 10,
24
+ :light_red => 11,
25
+ :light_green => 12,
26
+ :light_yellow => 13,
27
+ :light_blue => 14,
28
+ :light_magenta => 15,
29
+ :light_cyan => 16,
30
+ :light_white => 17
31
+ }
32
+
33
+ #
34
+ # Modes Hash
35
+ #
36
+ MODES = {
37
+ :default => 0, # Turn off all attributes
38
+ #:bright => 1, # Set bright mode
39
+ :underline => 4, # Set underline mode
40
+ :blink => 5, # Set blink mode
41
+ :swap => 7, # Exchange foreground and background colors
42
+ :hide => 8 # Hide text (foreground color would be the same as background)
43
+ }
44
+
45
+ protected
46
+
47
+ #
48
+ # Set color values in new string intance
49
+ #
50
+ def set_color_parameters( params )
51
+ if (params.instance_of?(Hash))
52
+ @color = params[:color]
53
+ @background = params[:background]
54
+ @mode = params[:mode]
55
+ @uncolorized = params[:uncolorized]
56
+ self
57
+ else
58
+ nil
59
+ end
60
+ end
61
+
62
+ public
63
+
64
+ #
65
+ # Change color of string
66
+ #
67
+ # Examples:
68
+ #
69
+ # puts "This is blue".colorize( :blue )
70
+ # puts "This is light blue".colorize( :light_blue )
71
+ # puts "This is also blue".colorize( :color => :blue )
72
+ # puts "This is light blue with red background".colorize( :color => :light_blue, :background => :red )
73
+ # puts "This is light blue with red background".colorize( :light_blue ).colorize( :background => :red )
74
+ # puts "This is blue text on red".blue.on_red
75
+ # puts "This is red on blue".colorize( :red ).on_blue
76
+ # puts "This is red on blue and underline".colorize( :red ).on_blue.underline
77
+ # puts "This is blue text on red".blue.on_red.blink
78
+ # puts "This is uncolorized".blue.on_red.uncolorize
79
+ #
80
+ def colorize( params )
81
+ return self unless STDOUT.isatty
82
+
83
+ begin
84
+ require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
85
+ rescue LoadError
86
+ raise 'You must gem install win32console to use colorize on Windows'
87
+ end
88
+
89
+ color_parameters = {}
90
+
91
+ if (params.instance_of?(Hash))
92
+ color_parameters[:color] = COLORS[params[:color]]
93
+ color_parameters[:background] = COLORS[params[:background]]
94
+ color_parameters[:mode] = MODES[params[:mode]]
95
+ elsif (params.instance_of?(Symbol))
96
+ color_parameters[:color] = COLORS[params]
97
+ end
98
+
99
+ color_parameters[:color] ||= @color ||= COLORS[:default]
100
+ color_parameters[:background] ||= @background ||= COLORS[:default]
101
+ color_parameters[:mode] ||= @mode ||= MODES[:default]
102
+
103
+ color_parameters[:uncolorized] ||= @uncolorized ||= self.dup
104
+
105
+ # calculate bright mode
106
+ color_parameters[:color] += 50 if color_parameters[:color] > 10
107
+
108
+ color_parameters[:background] += 50 if color_parameters[:background] > 10
109
+
110
+ "\033[#{color_parameters[:mode]};#{color_parameters[:color]+30};#{color_parameters[:background]+40}m#{color_parameters[:uncolorized]}\033[0m".set_color_parameters( color_parameters )
111
+ end
112
+
113
+ #
114
+ # Return uncolorized string
115
+ #
116
+ def uncolorize
117
+ @uncolorized || self
118
+ end
119
+
120
+ #
121
+ # Return true if sting is colorized
122
+ #
123
+ def colorized?
124
+ !defined?(@uncolorized).nil?
125
+ end
126
+
127
+ #
128
+ # Make some color and on_color methods
129
+ #
130
+ COLORS.each_key do | key |
131
+ next if key == :default
132
+
133
+ define_method key do
134
+ self.colorize( :color => key )
135
+ end
136
+
137
+ define_method "on_#{key}" do
138
+ self.colorize( :background => key )
139
+ end
140
+ end
141
+
142
+ #
143
+ # Methods for modes
144
+ #
145
+ MODES.each_key do | key |
146
+ next if key == :default
147
+
148
+ define_method key do
149
+ self.colorize( :mode => key )
150
+ end
151
+ end
152
+
153
+ class << self
154
+
155
+ #
156
+ # Return array of available modes used by colorize method
157
+ #
158
+ def modes
159
+ keys = []
160
+ MODES.each_key do | key |
161
+ keys << key
162
+ end
163
+ keys
164
+ end
165
+
166
+ #
167
+ # Return array of available colors used by colorize method
168
+ #
169
+ def colors
170
+ keys = []
171
+ COLORS.each_key do | key |
172
+ keys << key
173
+ end
174
+ keys
175
+ end
176
+
177
+ #
178
+ # Display color matrix with color names.
179
+ #
180
+ def color_matrix( txt = "[X]" )
181
+ size = String.colors.length
182
+ String.colors.each do | color |
183
+ String.colors.each do | back |
184
+ print txt.colorize( :color => color, :background => back )
185
+ end
186
+ puts " < #{color}"
187
+ end
188
+ String.colors.reverse.each_with_index do | back, index |
189
+ puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
190
+ end
191
+ ""
192
+ end
193
+ end
194
+ end
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "0.0.28"
2
+ VERSION = "0.0.29"
3
3
  end
@@ -0,0 +1 @@
1
+ app-prototype
data/rails_32/Gemfile CHANGED
@@ -30,6 +30,7 @@ group :test, :development do
30
30
  gem 'rspec-rails'
31
31
  gem 'capybara'
32
32
  gem 'capybara-email'
33
+ gem 'database_cleaner'
33
34
  gem 'factory_girl_rails'
34
35
  gem 'jasminerice'
35
36
  gem 'timecop'
@@ -42,7 +42,7 @@ RSpec.configure do |config|
42
42
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
43
43
  # examples within a transaction, remove the following line or assign false
44
44
  # instead of true.
45
- config.use_transactional_fixtures = true
45
+ config.use_transactional_fixtures = false
46
46
 
47
47
  # If true, the base class of anonymous controllers will be inferred
48
48
  # automatically. This will be the default behavior in future versions of
@@ -60,21 +60,5 @@ RSpec.configure do |config|
60
60
  config.order = "random"
61
61
  end
62
62
 
63
- # Forces all threads to share the same connection. This works on
64
- # Capybara because it starts the web server in a thread.
65
- #
66
- # http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
67
-
68
- class ActiveRecord::Base
69
- mattr_accessor :shared_connection
70
- @@shared_connection = nil
71
-
72
- def self.connection
73
- @@shared_connection || retrieve_connection
74
- end
75
- end
76
-
77
- ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
78
-
79
63
  # Turn down the logging while testing.
80
64
  Rails.logger.level = 4
@@ -0,0 +1,24 @@
1
+ # Good read on using database_cleaner (in lieu of a shared connection):
2
+ # http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
3
+
4
+ RSpec.configure do |config|
5
+ config.before(:suite) do
6
+ DatabaseCleaner.clean_with(:truncation)
7
+ end
8
+
9
+ config.before(:each) do
10
+ DatabaseCleaner.strategy = :transaction
11
+ end
12
+
13
+ config.before(:each, js: true) do
14
+ DatabaseCleaner.strategy = :truncation
15
+ end
16
+
17
+ config.before(:each) do
18
+ DatabaseCleaner.start
19
+ end
20
+
21
+ config.after(:each) do
22
+ DatabaseCleaner.clean
23
+ end
24
+ end
data/rails_40/.env ADDED
@@ -0,0 +1,8 @@
1
+ # Set environment variables needed for development here. These values will be
2
+ # used unless they're already set.
3
+ #
4
+ # http://ddollar.github.com/foreman/#ENVIRONMENT
5
+
6
+ PORT=3000
7
+ UNICORN_WORKERS=1
8
+ UNICORN_BACKLOG=16
@@ -0,0 +1,16 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
data/rails_40/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format Fuubar --color
@@ -0,0 +1 @@
1
+ app-prototype
@@ -0,0 +1 @@
1
+ 2.0.0-p195
data/rails_40/Gemfile ADDED
@@ -0,0 +1,53 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Heroku uses the ruby version to configure your application's runtime.
4
+ ruby '2.0.0'
5
+
6
+ gem 'unicorn'
7
+
8
+ gem 'rails', '~> 4.0.0.rc2'
9
+ gem 'pg'
10
+
11
+ gem 'slim-rails'
12
+ gem 'less-rails'
13
+ gem 'less-rails-bootstrap'
14
+ gem 'jquery-rails'
15
+ gem 'coffee-rails'
16
+ gem 'turbolinks'
17
+ gem 'simple_form', '~> 3.0.0.rc'
18
+ gem 'uglifier'
19
+
20
+ gem 'awesome_print'
21
+
22
+ # Heroku suggests that these gems aren't necessary, but they're required to compile less assets on deploy.
23
+ gem 'therubyracer', platforms: :ruby
24
+ #gem 'libv8'#, '~> 3.11.8'
25
+
26
+ group :test, :development do
27
+ gem 'rspec-rails'
28
+ gem 'capybara'
29
+ #gem 'capybara-email'
30
+ gem 'poltergeist'
31
+ gem 'factory_girl_rails'
32
+ gem 'database_cleaner'
33
+ gem 'fuubar'
34
+ #gem 'jasminerice'
35
+ #gem 'timecop'
36
+ gem 'simplecov'
37
+ #gem 'cane'
38
+ #gem 'morecane'
39
+ #gem 'quiet_assets'
40
+ end
41
+
42
+ group :development do
43
+ gem 'foreman'
44
+ #gem 'launchy'
45
+ gem 'better_errors'
46
+ gem 'binding_of_caller'
47
+ gem 'guard'
48
+ gem 'guard-rspec'
49
+ #gem 'guard-jasmine'
50
+ #gem 'guard-livereload'
51
+ gem 'rb-fsevent'
52
+ gem 'growl'
53
+ end
@@ -0,0 +1,32 @@
1
+ # More info at https://github.com/guard/guard#readme
2
+
3
+ #guard :livereload do
4
+ # watch(%r{app/views/.+\.slim$})
5
+ # watch(%r{app/helpers/.+\.rb})
6
+ # watch(%r{public/.+\.(css|js|html)})
7
+ # watch(%r{config/locales/.+\.yml})
8
+ # # Rails Assets Pipeline
9
+ # watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
10
+ #end
11
+
12
+ guard :rspec do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+
17
+ # Rails example
18
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/(.*)(\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
20
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
21
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
22
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
23
+
24
+ # Capybara request specs
25
+ watch(%r{^app/views/(.+)/.*(\.slim)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
26
+ end
27
+
28
+ #guard :jasmine do
29
+ # watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
30
+ # watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
31
+ # watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" }
32
+ #end
data/rails_40/Procfile ADDED
@@ -0,0 +1,2 @@
1
+ web: bundle exec unicorn -c ./config/unicorn.rb
2
+ #worker: bundle exec rake jobs:work
@@ -0,0 +1,66 @@
1
+ # App Prototype
2
+
3
+ ...
4
+
5
+ Generated with [Raygun](https://github.com/carbonfive/raygun).
6
+
7
+ # Requirements
8
+
9
+ To run the specs or fire up the server, be sure you have these:
10
+
11
+ * Ruby 2.0.0-p195
12
+ * PostgreSQL 9.x with superuser 'postgres' with no password (```createuser -s postgres```)
13
+ * PhantomJS for JavaScript testing (```brew install phantomjs```)
14
+
15
+ # Development
16
+
17
+ ### First Time Setup
18
+
19
+ After cloning, run these commands to install missing gems and prepare the database.
20
+
21
+ $ gem install bundler
22
+ $ bundle update
23
+ $ rake db:setup db:sample_data
24
+
25
+ Note, ```rake db:sample_data``` loads a small set of data for development. Check out ```db/sample_data.rb``` for details.
26
+
27
+ ### Running the Specs
28
+
29
+ To run all ruby and jasmine specs.
30
+
31
+ $ rake
32
+
33
+ Again, with coverage for the ruby specs:
34
+
35
+ $ rake spec:coverage
36
+
37
+ ### Running the Application Locally
38
+
39
+ $ foreman start
40
+ $ open http://0.0.0.0:3000
41
+
42
+ ### Using Guard
43
+
44
+ Guard is configured to run ruby and jasmine specs, and also listen for livereload connections. Growl is used for notifications.
45
+
46
+ $ bundle exec guard
47
+
48
+ ### Using Mailcatcher
49
+
50
+ $ gem install mailcatcher
51
+ $ mailcacher
52
+ $ open http://localhost:1080/
53
+
54
+ Learn more at [mailcatcher.me](http://mailcatcher.me/). And please don't add mailcatcher to the Gemfile.
55
+
56
+ ### Deploying to Heroku
57
+
58
+ Install the heroku toolbelt if you don't already have it (https://toolbelt.heroku.com/).
59
+
60
+ $ heroku apps:create app-prototype
61
+ $ git push heroku master
62
+ $ heroku run rake db:setup
63
+
64
+ # Considerations
65
+
66
+ ...