bearonrails 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a0c39d4988e2e9e45e126ec557f211252f0eb19
4
- data.tar.gz: 5caa57e31539ff3b00adeebf3d50b6e62eafec29
3
+ metadata.gz: 0ab9b0cc218afb82e132197cf4d762f32e65184d
4
+ data.tar.gz: 8ea90704fac6e625c04cd47e304401180d17beae
5
5
  SHA512:
6
- metadata.gz: e0a85eea5229996a12e4e1527b0368bbae458feb441a5d1b7d8b886613caad730f47894c7aabe8636c20fec537fbb9ccea6168788f9e8d4198942639595ba46a
7
- data.tar.gz: d85ada2a623d59cffc0f16f53ce4122d1284bf2e02820ee5e00de2a84b395da1829371cd2493d2622bfaee1fee6a57a6e3e806894fb6a5aec375d41604a3b772
6
+ metadata.gz: 28b36dfee3ae5faced2580eaca83709a39678a48718c007cb4b802a45f9b7e0eb894c70b15c70069e942d59a4103469184285704d7fd48a202ebde6574fb4a6e
7
+ data.tar.gz: 971d2eb6a96b8cf0d06e64aba0850ba1c12ebdbcc1202b8406830fb9c11aa13fc0b07a48b14136731efca272b3df5449c8182123c5d872006ea15989a39e2bc9
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Bearonrails
2
2
 
3
+ [![RubyGems][gem_version_badge]][ruby_gems]
4
+ [![RubyGems][gem_downloads_badge]][ruby_gems]
5
+
3
6
  Bearonrails is the base Rails application generator.(For Rails 4.2+)
4
7
 
5
8
  ## Installation
@@ -12,31 +15,77 @@ Then run:
12
15
 
13
16
  $ bearonrails project_name
14
17
 
18
+ ## New Relic
19
+
20
+ For New Relic, edit `.env`, set New Relic License key to `NEW_RELIC_LICENSE_KEY`
21
+
22
+ ```shell
23
+ NEW_RELIC_APP_NAME=change-this-to-your-app-name
24
+ NEW_RELIC_LICENSE_KEY=change-this-to-your-new-relic-license-key
25
+
26
+ ```
27
+
28
+ ## Rubocop
29
+
30
+ For code style, edit `.rubocop.yml` to customize coding style rules. See sample(https://github.com/bbatsov/rubocop/blob/master/config/default.yml).
31
+
32
+ You could integrate your editor with rubocop, see [rubocop editor-integration](https://github.com/bbatsov/rubocop#editor-integration).
33
+
34
+ ## Dotenv
35
+
36
+ Use `.env` to manage environment varibales. And load environment varibales set in `.env` file when Rails Application start.
37
+
38
+ See `config/application.rb`
39
+
40
+ ```
41
+ # Added this line
42
+ Dotenv.load
43
+ ```
44
+
15
45
  ## Gems
16
46
 
17
- * [pry-rails](https://github.com/rweng/pry-rails)
18
- * [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug)
19
- * [awesome_print](https://github.com/michaeldv/awesome_print)
20
- * [hirb](https://github.com/cldwalker/hirb)
21
- * [hirb-unicode](https://github.com/miaout17/hirb-unicode)
22
- * [better_errors](https://github.com/charliesome/better_errors)
23
- * [binding_of_caller](https://github.com/banister/binding_of_caller)
47
+ #### Rails console
48
+
49
+ * [awesome_rails_console](https://github.com/michaeldv/awesome_print)
50
+ * [pry-rails](https://github.com/rweng/pry-rails)
51
+ * [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug)
52
+ * [awesome_print](https://github.com/michaeldv/awesome_print)
53
+ * [hirb](https://github.com/cldwalker/hirb)
54
+ * [hirb-unicode](https://github.com/miaout17/hirb-unicode)
55
+
56
+ #### Developing
57
+
24
58
  * [quiet_assets](https://github.com/evrone/quiet_assets)
25
59
  * [capistrano-rails](https://github.com/capistrano/rails/)
26
60
  * [capistrano-bundler](https://github.com/capistrano/bundler/)
61
+
62
+ #### Coding Style
63
+
27
64
  * [rubocop](https://github.com/bbatsov/rubocop)
28
65
  * [brakeman](https://github.com/presidentbeef/brakeman)
66
+
67
+ #### Testing
68
+
29
69
  * [rspec-rails](https://github.com/rspec/rspec-rails)
30
70
  * [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner)
31
71
  * [factory_girl_rails](https://github.com/thoughtbot/factory_girl_rails)
32
72
  * [faker](https://github.com/stympy/faker)
33
73
 
74
+ #### Environment
75
+
76
+ * [dotenv](https://github.com/bkeepers/dotenv)
77
+
78
+ #### Metric
79
+
80
+ * [newrelic_rpm](https://github.com/newrelic/rpm)
81
+
34
82
  ## Reference:
35
83
 
36
84
  [xdite/bootstrappers](https://github.com/xdite/bootstrappers)
37
85
 
38
86
  [超棒的 rails console 設定](http://toyroom.bruceli.net/tw/2014/08/13/awesome-rails-console-customization-using-pry.html)
39
87
 
88
+ [Rails Application Template Guide](http://guides.rubyonrails.org/rails_application_templates.html)
40
89
 
41
90
  ## MIT License
42
91
 
data/bin/bearonrails CHANGED
File without changes
@@ -24,6 +24,26 @@ module Bearonrails
24
24
  copy_file '.rubocop.yml', '.rubocop.yml'
25
25
  end
26
26
 
27
+ def add_new_relic_config
28
+ copy_file 'config/newrelic.yml', 'config/newrelic.yml'
29
+
30
+ replace_in_file(
31
+ '.env',
32
+ /change-this-to-your-app-name/m,
33
+ "#{app_name}"
34
+ )
35
+ end
36
+
37
+ def add_dot_env
38
+ copy_file '.env', '.env'
39
+
40
+ inject_into_file(
41
+ 'config/application.rb',
42
+ "Dotenv.load\n\n",
43
+ before: /^module/
44
+ )
45
+ end
46
+
27
47
  def install_rspec
28
48
  run 'bundle exec rails g rspec:install'
29
49
  end
@@ -46,14 +66,6 @@ module Bearonrails
46
66
  )
47
67
  end
48
68
 
49
- def add_pryrc
50
- copy_file '.pryrc', '.pryrc'
51
- end
52
-
53
- def add_pry_config
54
- copy_file 'config/initializers/pry.rb', 'config/initializers/pry.rb'
55
- end
56
-
57
69
  private
58
70
 
59
71
  def replace_in_file(relative_path, find, replace)
@@ -16,7 +16,7 @@ module Bearonrails
16
16
  invoke :customize_gemfile
17
17
  invoke :install_rspec
18
18
  invoke :add_rubocop_config
19
- invoke :add_pry_config
19
+ invoke :add_new_relic_config
20
20
  invoke :remove_routes_comment_lines
21
21
  invoke :init_git
22
22
  end
@@ -35,6 +35,11 @@ module Bearonrails
35
35
  def customize_gemfile
36
36
  build :add_custom_gems
37
37
  bundle_command 'install'
38
+
39
+ # skip origin `bundle install` step
40
+ new_options = options.dup
41
+ options = new_options
42
+ options.merge!(skip_bundle: true)
38
43
  end
39
44
 
40
45
  def add_rubocop_config
@@ -42,10 +47,10 @@ module Bearonrails
42
47
  build :add_rubocop_config
43
48
  end
44
49
 
45
- def add_pry_config
46
- say 'Add pry config'
47
- build :add_pryrc
48
- build :add_pry_config
50
+ def add_new_relic_config
51
+ say 'Add New Relic config'
52
+ build :add_dot_env
53
+ build :add_new_relic_config
49
54
  end
50
55
 
51
56
  def install_rspec
@@ -1,4 +1,4 @@
1
1
  #
2
2
  module Bearonrails
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.0'
4
4
  end
data/templates/.env ADDED
@@ -0,0 +1,2 @@
1
+ NEW_RELIC_APP_NAME=change-this-to-your-app-name
2
+ NEW_RELIC_LICENSE_KEY=change-this-to-your-new-relic-license-key
@@ -1,26 +1,26 @@
1
1
 
2
- gem 'pry-rails'
3
- gem 'pry-byebug'
4
- gem 'awesome_print', :require => false
5
-
6
- group :development, :test do
7
- gem 'hirb', :require => false
8
- gem 'hirb-unicode', :require => false
9
- end
10
-
11
2
  group :development do
12
- gem 'better_errors'
13
- gem 'binding_of_caller'
14
3
  gem 'quiet_assets'
4
+
15
5
  gem 'capistrano-rails'
16
6
  gem 'capistrano-bundler'
7
+
17
8
  gem 'rubocop', require: false
18
9
  gem 'brakeman', require: false
19
10
  end
20
11
 
12
+ # use rspec to test
21
13
  group :test do
22
14
  gem 'rspec-rails'
23
15
  gem 'database_cleaner'
24
16
  gem 'factory_girl_rails'
25
17
  gem 'faker'
26
18
  end
19
+
20
+ # environment
21
+ gem 'dotenv'
22
+
23
+ # new relic agent
24
+ gem 'newrelic_rpm'
25
+
26
+ gem 'awesome_rails_console'
@@ -0,0 +1,221 @@
1
+ #
2
+ # This file configures the New Relic Agent. New Relic monitors Ruby, Java,
3
+ # .NET, PHP, Python and Node applications with deep visibility and low
4
+ # overhead. For more information, visit www.newrelic.com.
5
+
6
+
7
+ # Here are the settings that are common to all environments
8
+ common: &default_settings
9
+ # ============================== LICENSE KEY ===============================
10
+
11
+ # You must specify the license key associated with your New Relic
12
+ # account. This key binds your Agent's data to your account in the
13
+ # New Relic service.
14
+ license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
15
+
16
+ # Agent Enabled (Ruby/Rails Only)
17
+ # Use this setting to force the agent to run or not run.
18
+ # Default is 'auto' which means the agent will install and run only
19
+ # if a valid dispatcher such as Mongrel is running. This prevents
20
+ # it from running with Rake or the console. Set to false to
21
+ # completely turn the agent off regardless of the other settings.
22
+ # Valid values are true, false and auto.
23
+ #
24
+ # agent_enabled: auto
25
+
26
+ # Application Name Set this to be the name of your application as
27
+ # you'd like it show up in New Relic. The service will then auto-map
28
+ # instances of your application into an "application" on your
29
+ # dashboard page. If you want to map this instance into multiple
30
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
31
+ # separated list of up to three distinct names, or a yaml list.
32
+ # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
33
+ # Production, Staging, etc)
34
+ #
35
+ # Example:
36
+ #
37
+ # app_name:
38
+ # - Ajax Service
39
+ # - All Services
40
+ #
41
+ # Caution: If you change this name, a new application will appear in the New
42
+ # Relic user interface with the new name, and data will stop reporting to the
43
+ # app with the old name.
44
+ #
45
+ # See https://newrelic.com/docs/site/renaming-applications for more details
46
+ # on renaming your New Relic applications.
47
+ #
48
+ app_name: <%= ENV['NEW_RELIC_APP_NAME'] %>
49
+
50
+ # When "true", the agent collects performance data about your
51
+ # application and reports this data to the New Relic service at
52
+ # newrelic.com. This global switch is normally overridden for each
53
+ # environment below. (formerly called 'enabled')
54
+ monitor_mode: true
55
+
56
+ # Developer mode should be off in every environment but
57
+ # development as it has very high overhead in memory.
58
+ developer_mode: false
59
+
60
+ # The newrelic agent generates its own log file to keep its logging
61
+ # information separate from that of your application. Specify its
62
+ # log level here.
63
+ log_level: info
64
+
65
+ # Optionally set the path to the log file This is expanded from the
66
+ # root directory (may be relative or absolute, e.g. 'log/' or
67
+ # '/var/log/') The agent will attempt to create this directory if it
68
+ # does not exist.
69
+ # log_file_path: 'log'
70
+
71
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
72
+ # log_file_name: 'newrelic_agent.log'
73
+
74
+ # The newrelic agent communicates with the service via https by default. This
75
+ # prevents eavesdropping on the performance metrics transmitted by the agent.
76
+ # The encryption required by SSL introduces a nominal amount of CPU overhead,
77
+ # which is performed asynchronously in a background thread. If you'd prefer
78
+ # to send your metrics over http uncomment the following line.
79
+ # ssl: false
80
+
81
+ #============================== Browser Monitoring ===============================
82
+ # New Relic Real User Monitoring gives you insight into the performance real users are
83
+ # experiencing with your website. This is accomplished by measuring the time it takes for
84
+ # your users' browsers to download and render your web pages by injecting a small amount
85
+ # of JavaScript code into the header and footer of each page.
86
+ browser_monitoring:
87
+ # By default the agent automatically injects the monitoring JavaScript
88
+ # into web pages. Set this attribute to false to turn off this behavior.
89
+ auto_instrument: true
90
+
91
+ # Proxy settings for connecting to the New Relic server.
92
+ #
93
+ # If a proxy is used, the host setting is required. Other settings
94
+ # are optional. Default port is 8080.
95
+ #
96
+ # proxy_host: hostname
97
+ # proxy_port: 8080
98
+ # proxy_user:
99
+ # proxy_pass:
100
+
101
+ # The agent can optionally log all data it sends to New Relic servers to a
102
+ # separate log file for human inspection and auditing purposes. To enable this
103
+ # feature, change 'enabled' below to true.
104
+ # See: https://newrelic.com/docs/ruby/audit-log
105
+ audit_log:
106
+ enabled: false
107
+
108
+ # Tells transaction tracer and error collector (when enabled)
109
+ # whether or not to capture HTTP params. When true, frameworks can
110
+ # exclude HTTP parameters from being captured.
111
+ # Rails: the RoR filter_parameter_logging excludes parameters
112
+ # Java: create a config setting called "ignored_params" and set it to
113
+ # a comma separated list of HTTP parameter names.
114
+ # ex: ignored_params: credit_card, ssn, password
115
+ capture_params: false
116
+
117
+ # Transaction tracer captures deep information about slow
118
+ # transactions and sends this to the New Relic service once a
119
+ # minute. Included in the transaction is the exact call sequence of
120
+ # the transactions including any SQL statements issued.
121
+ transaction_tracer:
122
+
123
+ # Transaction tracer is enabled by default. Set this to false to
124
+ # turn it off. This feature is only available at the Professional
125
+ # and above product levels.
126
+ enabled: true
127
+
128
+ # Threshold in seconds for when to collect a transaction
129
+ # trace. When the response time of a controller action exceeds
130
+ # this threshold, a transaction trace will be recorded and sent to
131
+ # New Relic. Valid values are any float value, or (default) "apdex_f",
132
+ # which will use the threshold for an dissatisfying Apdex
133
+ # controller action - four times the Apdex T value.
134
+ transaction_threshold: apdex_f
135
+
136
+ # When transaction tracer is on, SQL statements can optionally be
137
+ # recorded. The recorder has three modes, "off" which sends no
138
+ # SQL, "raw" which sends the SQL statement in its original form,
139
+ # and "obfuscated", which strips out numeric and string literals.
140
+ record_sql: obfuscated
141
+
142
+ # Threshold in seconds for when to collect stack trace for a SQL
143
+ # call. In other words, when SQL statements exceed this threshold,
144
+ # then capture and send to New Relic the current stack trace. This is
145
+ # helpful for pinpointing where long SQL calls originate from.
146
+ stack_trace_threshold: 0.500
147
+
148
+ # Determines whether the agent will capture query plans for slow
149
+ # SQL queries. Only supported in mysql and postgres. Should be
150
+ # set to false when using other adapters.
151
+ # explain_enabled: true
152
+
153
+ # Threshold for query execution time below which query plans will
154
+ # not be captured. Relevant only when `explain_enabled` is true.
155
+ # explain_threshold: 0.5
156
+
157
+ # Error collector captures information about uncaught exceptions and
158
+ # sends them to New Relic for viewing
159
+ error_collector:
160
+
161
+ # Error collector is enabled by default. Set this to false to turn
162
+ # it off. This feature is only available at the Professional and above
163
+ # product levels.
164
+ enabled: true
165
+
166
+ # To stop specific errors from reporting to New Relic, set this property
167
+ # to comma-separated values. Default is to ignore routing errors,
168
+ # which are how 404's get triggered.
169
+ ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
170
+
171
+ # If you're interested in capturing memcache keys as though they
172
+ # were SQL uncomment this flag. Note that this does increase
173
+ # overhead slightly on every memcached call, and can have security
174
+ # implications if your memcached keys are sensitive
175
+ # capture_memcache_keys: true
176
+
177
+ # Application Environments
178
+ # ------------------------------------------
179
+ # Environment-specific settings are in this section.
180
+ # For Rails applications, RAILS_ENV is used to determine the environment.
181
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
182
+ # the environment.
183
+
184
+ # NOTE if your application has other named environments, you should
185
+ # provide newrelic configuration settings for these environments here.
186
+
187
+ development:
188
+ <<: *default_settings
189
+ # Turn on communication to New Relic service in development mode
190
+ monitor_mode: true
191
+ app_name: <%= ENV['NEW_RELIC_APP_NAME'] %> (Development)
192
+
193
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
194
+ # present performance information on the last 100 transactions you have
195
+ # executed since starting the mongrel.
196
+ # NOTE: There is substantial overhead when running in developer mode.
197
+ # Do not use for production or load testing.
198
+ developer_mode: true
199
+
200
+ test:
201
+ <<: *default_settings
202
+ # It almost never makes sense to turn on the agent when running
203
+ # unit, functional or integration tests or the like.
204
+ monitor_mode: false
205
+
206
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
207
+ # testing shows an average performance impact of < 5 ms per
208
+ # transaction, you can leave this on all the time without
209
+ # incurring any user-visible performance degradation.
210
+ production:
211
+ <<: *default_settings
212
+ monitor_mode: true
213
+ app_name: <%= ENV['NEW_RELIC_APP_NAME'] %> (Production)
214
+
215
+ # Many applications have a staging environment which behaves
216
+ # identically to production. Support for that environment is provided
217
+ # here. By default, the staging environment has the agent turned on.
218
+ staging:
219
+ <<: *default_settings
220
+ monitor_mode: true
221
+ app_name: <%= ENV['NEW_RELIC_APP_NAME'] %> (Staging)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearonrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - timfanda35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,10 +50,10 @@ files:
50
50
  - lib/bearonrails/app_builder.rb
51
51
  - lib/bearonrails/generators/app_generator.rb
52
52
  - lib/bearonrails/version.rb
53
- - templates/.pryrc
53
+ - templates/.env
54
54
  - templates/.rubocop.yml
55
55
  - templates/Gemfile_additions
56
- - templates/config/initializers/pry.rb
56
+ - templates/config/newrelic.yml
57
57
  - templates/spec/rails_helper_addon
58
58
  - templates/tasks/dev.rake
59
59
  homepage: https://github.com/timfanda35/bearonrails
data/templates/.pryrc DELETED
@@ -1,21 +0,0 @@
1
- require "awesome_print"
2
- AwesomePrint.pry!
3
-
4
- begin
5
- require "hirb"
6
- require "hirb-unicode"
7
- extend Hirb::Console
8
- rescue LoadError => e
9
- end
10
-
11
- if defined?(PryByebug)
12
- Pry.commands.alias_command 'c', 'continue'
13
- Pry.commands.alias_command 's', 'step'
14
- Pry.commands.alias_command 'n', 'next'
15
- Pry.commands.alias_command 'f', 'finish'
16
- end
17
-
18
- # Hit Enter to repeat last command
19
- Pry::Commands.command /^$/, "repeat last command" do
20
- _pry_.run_command Pry.history.to_a.last
21
- end
@@ -1,24 +0,0 @@
1
- ## config/initializers/pry.rb
2
- ## encoding: utf-8
3
- ## 預設的 prompt_name 是 pry,下面這行會把 prompt_name 變成該 project 的名稱 (自動抓)
4
- Pry.config.prompt_name = Rails.application.class.parent_name.underscore.dasherize
5
-
6
- unless Rails.env.development?
7
- old_prompt = Pry.config.prompt
8
-
9
- if Rails.env.production?
10
- # 這邊本來應該是 Pry::Helpers::Text.red(Rails.env.upcase)
11
- # 相當於 "\e[0;31m#{Rails.env.upcase}\e[0m"
12
- # 但因為一個 readline 引起的 bug 導致輸入游標錯位,因此需加上 \001 \002 來跳過此問題,下同
13
- # 此問題的討論串在 https://github.com/pry/pry/issues/493
14
- env = "\001\e[0;31m\002#{Rails.env.upcase}\001\e[0m\002" # 紅色 的 env 名稱
15
- else
16
- env = "\001\e[0;33m\002#{Rails.env.upcase}\001\e[0m\002" # 黃色 的 env 名稱
17
- end
18
-
19
- # 替換 pry prompt 的方法在 https://github.com/pry/pry/wiki/Customization-and-configuration#Config_prompt 有教學
20
- Pry.config.prompt = [
21
- proc { |*a| "#{env} #{old_prompt.first.call(*a)}" },
22
- proc { |*a| "#{env} #{old_prompt.second.call(*a)}" }
23
- ]
24
- end