raygun 0.0.2

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 (58) hide show
  1. data/.gitignore +17 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +63 -0
  6. data/Rakefile +1 -0
  7. data/TODO.md +24 -0
  8. data/bin/raygun +11 -0
  9. data/lib/raygun/actions.rb +26 -0
  10. data/lib/raygun/app_builder.rb +283 -0
  11. data/lib/raygun/generators/app_generator.rb +182 -0
  12. data/lib/raygun/version.rb +3 -0
  13. data/marvin.jpg +0 -0
  14. data/raygun.gemspec +25 -0
  15. data/templates/Gemfile_customized +32 -0
  16. data/templates/README.md.erb +31 -0
  17. data/templates/_app/assets/stylesheets/_footer.less +30 -0
  18. data/templates/_app/assets/stylesheets/application.css.less +8 -0
  19. data/templates/_app/controllers/application_controller.rb +14 -0
  20. data/templates/_app/controllers/password_resets_controller.rb +38 -0
  21. data/templates/_app/controllers/registrations_controller.rb +27 -0
  22. data/templates/_app/controllers/user_sessions_controller.rb +25 -0
  23. data/templates/_app/helpers/application_helper.rb +11 -0
  24. data/templates/_app/mailers/user_mailer.rb +22 -0
  25. data/templates/_app/models/user.rb +17 -0
  26. data/templates/_app/models/user_session.rb +6 -0
  27. data/templates/_app/views/layouts/application.html.slim.erb +36 -0
  28. data/templates/_app/views/password_resets/edit.html.slim +16 -0
  29. data/templates/_app/views/password_resets/new.html.slim +11 -0
  30. data/templates/_app/views/registrations/new.html.slim +14 -0
  31. data/templates/_app/views/user_mailer/activation_needed_email.html.erb +17 -0
  32. data/templates/_app/views/user_mailer/activation_needed_email.text.erb +9 -0
  33. data/templates/_app/views/user_mailer/activation_success_email.html.erb +17 -0
  34. data/templates/_app/views/user_mailer/activation_success_email.text.erb +9 -0
  35. data/templates/_app/views/user_mailer/reset_password_email.html.erb +16 -0
  36. data/templates/_app/views/user_mailer/reset_password_email.text.erb +8 -0
  37. data/templates/_app/views/user_sessions/new.html.slim +13 -0
  38. data/templates/_config/database.yml.erb +13 -0
  39. data/templates/_db/sample_data.rb +17 -0
  40. data/templates/_lib/email_validator.rb +9 -0
  41. data/templates/_lib/tasks/db.rake +7 -0
  42. data/templates/_lib/templates/rspec/scaffold/controller_spec.rb +152 -0
  43. data/templates/_lib/templates/slim/scaffold/_form.html.slim +13 -0
  44. data/templates/_lib/templates/slim/scaffold/edit.html.slim +5 -0
  45. data/templates/_lib/templates/slim/scaffold/index.html.slim +27 -0
  46. data/templates/_lib/templates/slim/scaffold/new.html.slim +4 -0
  47. data/templates/_lib/templates/slim/scaffold/show.html.slim +15 -0
  48. data/templates/_public/index.html.erb +41 -0
  49. data/templates/_spec/factories/users.rb +7 -0
  50. data/templates/_spec/mailers/user_mailer_spec.rb +48 -0
  51. data/templates/_spec/models/user_spec.rb +29 -0
  52. data/templates/_spec/requests/user_sessions_spec.rb +29 -0
  53. data/templates/_spec/support/accept_values.rb +55 -0
  54. data/templates/_spec/support/factory_girl.rb +3 -0
  55. data/templates/_spec/support/sorcery.rb +3 -0
  56. data/templates/_spec/support/user_sessions_request_helper.rb +21 -0
  57. data/templates/rvmrc.erb +1 -0
  58. metadata +168 -0
@@ -0,0 +1,13 @@
1
+ = simple_form_for(@<%= singular_table_name %>) do |f|
2
+ = f.error_notification
3
+
4
+ .form-inputs
5
+ <%- attributes.each_with_index do |attribute, i| -%>
6
+ = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> <%= ", autofocus:true" if i == 0 %>
7
+ <%- end -%>
8
+
9
+ .form-actions
10
+ = f.button :submit, class: 'btn btn-primary'
11
+ '
12
+ = link_to 'Back', <%= index_helper %>_path, class: 'btn'
13
+
@@ -0,0 +1,5 @@
1
+ .page-header
2
+ h1 Editing <%= singular_table_name %>
3
+
4
+ == render 'form'
5
+
@@ -0,0 +1,27 @@
1
+ div.page-header
2
+ h1 Listing <%= plural_table_name %>
3
+
4
+ table.table.table-striped
5
+ thead
6
+ tr
7
+ th ID
8
+ <% attributes.each do |attribute| -%>
9
+ th <%= attribute.human_name %>
10
+ <% end -%>
11
+ th Actions
12
+
13
+ tbody
14
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
+ tr
16
+ td= link_to <%= singular_table_name %>.id, <%= singular_table_name %>_path(<%= singular_table_name %>)
17
+ <% attributes.each do |attribute| -%>
18
+ td= <%= singular_table_name %>.<%= attribute.name %>
19
+ <% end -%>
20
+ td
21
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'btn btn-mini'
22
+ '
23
+ = link_to 'Destroy', <%= singular_table_name %>_path(<%= singular_table_name %>), method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-mini btn-danger'
24
+
25
+ br
26
+
27
+ = link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, class: 'btn btn-primary'
@@ -0,0 +1,4 @@
1
+ .page-header
2
+ h1 Create <%= singular_table_name %>
3
+
4
+ == render 'form'
@@ -0,0 +1,15 @@
1
+ .page-header
2
+ h1 <%= singular_table_name %>
3
+
4
+ <% attributes.each do |attribute| -%>
5
+ p
6
+ strong <%= attribute.human_name %>:
7
+ = @<%= singular_table_name %>.<%= attribute.name %>
8
+ <% end -%>
9
+
10
+ = link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn'
11
+ '
12
+ = link_to 'Back', <%= index_helper %>_path, class: 'btn'
13
+ '
14
+ = link_to 'Destroy', <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-danger'
15
+
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= app_name.capitalize %></title>
5
+ <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css"/>
6
+ <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
7
+ <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
8
+ <script src="/assets/application.js?body=1" type="text/javascript"></script>
9
+ </head>
10
+ <body>
11
+ <div class="wrapper">
12
+ <div class="container">
13
+ <header class="navbar navbar-fixed-top">
14
+ <nav class="navbar-inner">
15
+ <div class="container">
16
+ <div class="brand"><%= app_name.capitalize %></div>
17
+ <ul class="nav pull-right">
18
+ <li><a href="/sign_in">Sign in</a></li>
19
+ </ul>
20
+ </div>
21
+ </nav>
22
+ </header>
23
+
24
+ <div class="hero-unit">
25
+ <h1>Hello, world!</h1>
26
+
27
+ <p>Welcome to your newly generated rails application...</p>
28
+ <p>Meander around the code to see what's been done for you. Many small, and a few not-so-small, customizations have been made.</p>
29
+ <p>Custom generator templates create views that are bootstrap compatible and specs that are factory-aware and follow best practices.</p>
30
+ <p>This application also includes authentication and an example of authorization (sign in as user@example.com / password).</p>
31
+
32
+ <p><a class="btn btn-primary btn-large" href="sign_in">Sign in</a></p>
33
+ </div>
34
+ </div>
35
+ <div class="push"></div>
36
+ </div>
37
+ <footer>
38
+ <div class="container"><p>&copy; 2012 All rights reserved.</p></div>
39
+ </footer>
40
+ </body>
41
+ </html>
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :user do
3
+ sequence(:email) { |n| "person#{n}@example.com" }
4
+ name 'Tom Middleton'
5
+ password 'password'
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ require "spec_helper"
2
+
3
+ describe UserMailer do
4
+ let(:user) { build_stubbed(:user) }
5
+
6
+ describe "activation_needed_email" do
7
+ let(:mail) { UserMailer.activation_needed_email(user) }
8
+
9
+ it "renders the headers" do
10
+ mail.subject.should eq("Welcome to My Awesome Site!")
11
+ mail.to.should eq([user.email])
12
+ mail.from.should eq(['notifications@example.com'])
13
+ end
14
+
15
+ it "renders the body" do
16
+ mail.body.encoded.should match("Welcome to")
17
+ end
18
+ end
19
+
20
+ describe "activation_success_email" do
21
+ let(:mail) { UserMailer.activation_success_email(user) }
22
+
23
+ it "renders the headers" do
24
+ mail.subject.should eq("Your account has been activated!")
25
+ mail.to.should eq([user.email])
26
+ mail.from.should eq(['notifications@example.com'])
27
+ end
28
+
29
+ it "renders the body" do
30
+ mail.body.encoded.should match("You have successfully activated")
31
+ end
32
+ end
33
+
34
+ describe "reset_password_email" do
35
+ let(:mail) { UserMailer.reset_password_email(user) }
36
+
37
+ it "renders the headers" do
38
+ mail.subject.should eq("Password reset requested")
39
+ mail.to.should eq([user.email])
40
+ mail.from.should eq(['notifications@example.com'])
41
+ end
42
+
43
+ it "renders the body" do
44
+ mail.body.encoded.should match("You have requested to reset your password.")
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+ describe "validations" do
5
+
6
+ subject { build(:user) }
7
+
8
+ describe "name" do
9
+ it "is required" do
10
+ subject.should_not accept_values(:email, nil, '')
11
+ end
12
+
13
+ it "should be less than 30 characters"
14
+ end
15
+
16
+ describe "email" do
17
+ it "is required" do
18
+ subject.should_not accept_values(:email, nil, '', ' ')
19
+ end
20
+
21
+ it "must be properly formatted" do
22
+ subject.should accept_values(:email, 'a@b.com', 'a@b.c.com')
23
+ subject.should_not accept_values(:email, 'a@b', 'a.b.com')
24
+ end
25
+
26
+ it "must be unique"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ feature "User Sessions" do
4
+ include Capybara::DSL # Remove once https://github.com/jnicklas/capybara/pull/809 is resolved.
5
+
6
+ background do
7
+ @user = create(:user)
8
+ @user.activate!
9
+ end
10
+
11
+ scenario "Sign in with valid credentials" do
12
+ sign_in(@user.email, 'password')
13
+
14
+ find('.alert').should have_content("Successfully signed in")
15
+ end
16
+
17
+ scenario "Sign in with an invalid email" do
18
+ sign_in('this is not valid', 'password')
19
+
20
+ find('.alert').should have_content("Sign in failed")
21
+ end
22
+
23
+ scenario "Sign in with an invalid password" do
24
+ sign_in(@user.email, 'this is not valid')
25
+
26
+ find('.alert').should have_content("Sign in failed")
27
+ end
28
+
29
+ end
@@ -0,0 +1,55 @@
1
+ # Based on https://github.com/bogdan/accept_values_for
2
+
3
+ def accept_values(attribute, *values)
4
+ AcceptValues.new(attribute, *values)
5
+ end
6
+
7
+ class AcceptValues #:nodoc:
8
+
9
+ def initialize(attribute, *values)
10
+ @attribute = attribute
11
+ @values = values
12
+ end
13
+
14
+ def matches?(model)
15
+ @model = model
16
+ #return false unless model.is_a?(ActiveRecord::Base)
17
+ @values.each do |value|
18
+ model.send("#{@attribute}=", value)
19
+ model.valid?
20
+ if model.errors[@attribute].present?
21
+ @failed_value = value
22
+ return false
23
+ end
24
+ end
25
+ true
26
+ end
27
+
28
+ def does_not_match?(model)
29
+ @model = model
30
+ #return false unless model.is_a?(ActiveRecord::Base)
31
+ @values.each do |value|
32
+ model.send("#{@attribute}=", value)
33
+ model.valid?
34
+ unless model.errors[@attribute].present?
35
+ @failed_value = value
36
+ return false
37
+ end
38
+ end
39
+ true
40
+ end
41
+
42
+ def failure_message_for_should
43
+ result = "expected #{@model.class.name} to accept value #{@failed_value.inspect} for #{@attribute.inspect}\n"
44
+ result += 'Errors: ' + @model.errors[@attribute].join(', ') if @model.respond_to?(:errors)
45
+ result
46
+ end
47
+
48
+ def failure_message_for_should_not
49
+ "expected #{@model.class.name} to reject value #{@failed_value.inspect} for #{@attribute.inspect} attribute"
50
+ end
51
+
52
+ def description
53
+ "accept values #{@values.map(&:inspect).join(', ')} for #{@attribute.inspect}"
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Sorcery::TestHelpers::Rails
3
+ end
@@ -0,0 +1,21 @@
1
+ module UserSessionsRequestHelper
2
+
3
+ def sign_in(email, password)
4
+ visit sign_in_path
5
+
6
+ within('#new_user_session') do
7
+ fill_in 'Email', with: email
8
+ fill_in 'Password', with: password
9
+ click_on 'Sign In'
10
+ end
11
+ end
12
+
13
+ def sign_out(user = @current_user)
14
+ # TODO
15
+ end
16
+
17
+ end
18
+
19
+ RSpec.configure do |config|
20
+ config.include UserSessionsRequestHelper, type: :request
21
+ end
@@ -0,0 +1 @@
1
+ rvm use <%= rvm_ruby %>@<%= app_name %> --create
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: raygun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christian Nelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '1.2'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rvm
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.11.3.5
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.11.3.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: hash_syntax
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ description: Carbon Five Rails application generator
79
+ email:
80
+ - christian@carbonfive.com
81
+ executables:
82
+ - raygun
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - .rvmrc
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - TODO.md
93
+ - bin/raygun
94
+ - lib/raygun/actions.rb
95
+ - lib/raygun/app_builder.rb
96
+ - lib/raygun/generators/app_generator.rb
97
+ - lib/raygun/version.rb
98
+ - marvin.jpg
99
+ - raygun.gemspec
100
+ - templates/Gemfile_customized
101
+ - templates/README.md.erb
102
+ - templates/_app/assets/stylesheets/_footer.less
103
+ - templates/_app/assets/stylesheets/application.css.less
104
+ - templates/_app/controllers/application_controller.rb
105
+ - templates/_app/controllers/password_resets_controller.rb
106
+ - templates/_app/controllers/registrations_controller.rb
107
+ - templates/_app/controllers/user_sessions_controller.rb
108
+ - templates/_app/helpers/application_helper.rb
109
+ - templates/_app/mailers/user_mailer.rb
110
+ - templates/_app/models/user.rb
111
+ - templates/_app/models/user_session.rb
112
+ - templates/_app/views/layouts/application.html.slim.erb
113
+ - templates/_app/views/password_resets/edit.html.slim
114
+ - templates/_app/views/password_resets/new.html.slim
115
+ - templates/_app/views/registrations/new.html.slim
116
+ - templates/_app/views/user_mailer/activation_needed_email.html.erb
117
+ - templates/_app/views/user_mailer/activation_needed_email.text.erb
118
+ - templates/_app/views/user_mailer/activation_success_email.html.erb
119
+ - templates/_app/views/user_mailer/activation_success_email.text.erb
120
+ - templates/_app/views/user_mailer/reset_password_email.html.erb
121
+ - templates/_app/views/user_mailer/reset_password_email.text.erb
122
+ - templates/_app/views/user_sessions/new.html.slim
123
+ - templates/_config/database.yml.erb
124
+ - templates/_db/sample_data.rb
125
+ - templates/_lib/email_validator.rb
126
+ - templates/_lib/tasks/db.rake
127
+ - templates/_lib/templates/rspec/scaffold/controller_spec.rb
128
+ - templates/_lib/templates/slim/scaffold/_form.html.slim
129
+ - templates/_lib/templates/slim/scaffold/edit.html.slim
130
+ - templates/_lib/templates/slim/scaffold/index.html.slim
131
+ - templates/_lib/templates/slim/scaffold/new.html.slim
132
+ - templates/_lib/templates/slim/scaffold/show.html.slim
133
+ - templates/_public/index.html.erb
134
+ - templates/_spec/factories/users.rb
135
+ - templates/_spec/mailers/user_mailer_spec.rb
136
+ - templates/_spec/models/user_spec.rb
137
+ - templates/_spec/requests/user_sessions_spec.rb
138
+ - templates/_spec/support/accept_values.rb
139
+ - templates/_spec/support/factory_girl.rb
140
+ - templates/_spec/support/sorcery.rb
141
+ - templates/_spec/support/user_sessions_request_helper.rb
142
+ - templates/rvmrc.erb
143
+ homepage: https://github.com/carbonfive/raygun
144
+ licenses: []
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 1.8.24
164
+ signing_key:
165
+ specification_version: 3
166
+ summary: Generates and customizes Rails applications with Carbon Five best practices
167
+ baked in.
168
+ test_files: []