onotole 1.0.17 → 1.1.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: 29f7121f3678b16024d4c63c4c5d524a2dec2c9b
4
- data.tar.gz: cb1ebda44477cfabce626e99e413814c44b3a95b
3
+ metadata.gz: 68a3157ab702129ca0c8d08a375737a13438f9a9
4
+ data.tar.gz: 0cd75e6d0032cdd98a9fef728f41de62c6f621a1
5
5
  SHA512:
6
- metadata.gz: e888f6a97e17fb5cd78c436005d86c7b03ffd137ae05d255c1ce0f6757bf9fb2cc5bf7e3780a587fc4a78eafbb40ea652015b7beac2173e009b5d634b170b9c2
7
- data.tar.gz: e2d5d94444b6316009574172ef63914c6eade8b5392c1a7f95ad9cb0f6d8f50cd0f97f1d322795a8f7a7527c7da7340b326592f4c9f7d56a0e9f42cfb53eb926
6
+ metadata.gz: 3c9447a725d61a612fb3e197a455a8f95438e24ec36a4765cb6e9f234f3fdaa839053d224daf14989bb7d76011f7b39178edc7c62c465779ebadbc8f07de133c
7
+ data.tar.gz: e4d1fbd54f3c5da017a960cdcb80ff138d2079286475fed5d51cdc3495954c9531cd971a90bf140592d7da95d05d552b1bacbcebca612d7b63d1b7743dc828e7
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  source 'https://rubygems.org'
3
3
 
4
- gem 'rubycritic', require: false, group: :development
5
-
6
4
  gemspec
data/README.md CHANGED
@@ -210,6 +210,15 @@ And testing gems like:
210
210
  RSpec matchers
211
211
  * [Timecop](https://github.com/ferndopolis/timecop-console) for testing time
212
212
 
213
+ ## ENV Variables
214
+
215
+ All variables are stored in `.env` file and calls with project name prefix. It
216
+ made for avoid name space problems with placing more than 1 of Onotole created
217
+ app on 1 server. Onotole prefix all `env` variables with `#{app_name}` and now
218
+ you will not have any problems with export variables in production. With this
219
+ thick you can easy use ENV export tool or just put ENV variables in `.bashrc`
220
+ without name space conflicts.
221
+
213
222
  ## Other goodies
214
223
 
215
224
  Onotole also comes with:
@@ -221,8 +230,8 @@ Onotole also comes with:
221
230
  * A [low database connection pool limit][pool]
222
231
  * [Safe binstubs][binstub]
223
232
  * [t() and l() in specs without prefixing with I18n][i18n]
224
- * An automatically-created `SECRET_KEY_BASE` environment variable in all
225
- environments
233
+ * An automatically-created `#{APP_NAME}_SECRET_KEY_BASE` environment variable in
234
+ all environments
226
235
  * The analytics adapter [Segment][segment] (and therefore config for Google
227
236
  Analytics, Intercom, Facebook Ads, Twitter Ads, etc.)
228
237
  * Check existing of app DB and ask about continuation if base persisted
@@ -42,7 +42,7 @@ module Onotole
42
42
  def set_heroku_rails_secrets
43
43
  %w(staging production).each do |environment|
44
44
  run_toolbelt_command(
45
- "config:add SECRET_KEY_BASE=#{generate_secret}",
45
+ "config:add #{app_builder.app_name.dasherize.upcase}_SECRET_KEY_BASE=#{generate_secret}",
46
46
  environment
47
47
  )
48
48
  end
@@ -93,7 +93,7 @@ module Onotole
93
93
  end
94
94
 
95
95
  def configure_puma
96
- copy_file 'puma.rb', 'config/puma.rb'
96
+ template 'puma.rb.erb', 'config/puma.rb'
97
97
  end
98
98
 
99
99
  # def rvm_bundler_stubs_install
@@ -9,11 +9,12 @@ module Onotole
9
9
  def setup_asset_host
10
10
  replace_in_file 'config/environments/production.rb',
11
11
  "# config.action_controller.asset_host = 'http://assets.example.com'",
12
- 'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
12
+ "config.action_controller.asset_host = ENV.fetch('#{app_name.upcase}_ASSET_HOST',"\
13
+ " ENV.fetch('#{app_name.upcase}_APPLICATION_HOST'))"
13
14
 
14
15
  replace_in_file 'config/initializers/assets.rb',
15
16
  "config.assets.version = '1.0'",
16
- 'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
17
+ "config.assets.version = (ENV['#{app_name.upcase}_ASSETS_VERSION'] || '1.0')"
17
18
 
18
19
  inject_into_file(
19
20
  'config/environments/production.rb',
@@ -30,7 +30,7 @@ module Onotole
30
30
  end
31
31
 
32
32
  def set_up_forego
33
- copy_file 'Procfile', 'Procfile'
33
+ template 'Procfile.erb', 'Procfile', force: true
34
34
  end
35
35
 
36
36
  def setup_staging_environment
@@ -48,7 +48,11 @@ end
48
48
  end
49
49
 
50
50
  def setup_secret_token
51
- template 'secrets.yml', 'config/secrets.yml', force: true
51
+ copy_file 'secrets.yml', 'config/secrets.yml', force: true
52
+ # strange bug with ERB in ERB. solved this way
53
+ replace_in_file 'config/secrets.yml',
54
+ "<%= ENV['SECRET_KEY_BASE'] %>",
55
+ "<%= ENV['#{app_name.upcase}_SECRET_KEY_BASE'] %>"
52
56
  end
53
57
 
54
58
  def disallow_wrapping_parameters
@@ -103,6 +107,7 @@ end
103
107
 
104
108
  def copy_dotfiles
105
109
  directory 'dotfiles', '.', force: true
110
+ template 'dotenv.erb', '.env'
106
111
  end
107
112
 
108
113
  def setup_spring
@@ -161,11 +166,11 @@ end
161
166
  config = <<-RUBY
162
167
 
163
168
  if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
164
- ENV["APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
169
+ ENV["#{app_name.upcase}_APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
165
170
  end
166
171
 
167
172
  # Ensure requests are only served from one, canonical host name
168
- config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
173
+ config.middleware.use Rack::CanonicalHost, ENV.fetch("#{app_name.upcase}_APPLICATION_HOST")
169
174
  RUBY
170
175
 
171
176
  inject_into_file(
@@ -4,7 +4,7 @@ module Onotole
4
4
  def configure_action_mailer
5
5
  action_mailer_host 'development', %("localhost:3000")
6
6
  action_mailer_host 'test', %("www.example.com")
7
- action_mailer_host 'production', %{ENV.fetch("APPLICATION_HOST")}
7
+ action_mailer_host 'production', %{ENV.fetch("#{app_name.upcase}_APPLICATION_HOST")}
8
8
  end
9
9
 
10
10
  def configure_action_mailer_in_specs
@@ -12,7 +12,7 @@ module Onotole
12
12
  end
13
13
 
14
14
  def configure_smtp
15
- copy_file 'smtp.rb', 'config/smtp.rb'
15
+ template 'smtp.rb.erb', 'config/smtp.rb', force: true
16
16
 
17
17
  prepend_file 'config/environments/production.rb',
18
18
  %{require Rails.root.join("config/smtp")\n}
@@ -2,5 +2,5 @@
2
2
  module Onotole
3
3
  RAILS_VERSION = '~> 4.2.0'
4
4
  RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
5
- VERSION = '1.0.17'
5
+ VERSION = '1.1.0'
6
6
  end
@@ -34,17 +34,13 @@ module Onotole
34
34
  Heroku.new(app_builder).set_heroku_rails_secrets
35
35
 
36
36
  expect(app_builder).to(
37
- have_configured_var('staging', 'SECRET_KEY_BASE')
37
+ have_configured_var('staging', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
38
38
  )
39
39
  expect(app_builder).to(
40
- have_configured_var('production', 'SECRET_KEY_BASE')
40
+ have_configured_var('production', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
41
41
  )
42
42
  end
43
43
 
44
- def app_name
45
- OnotoleTestHelpers::APP_NAME
46
- end
47
-
48
44
  def have_configured_var(remote_name, var)
49
45
  have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
50
46
  end
@@ -17,11 +17,8 @@ RSpec.describe 'Heroku' do
17
17
  )
18
18
  expect(FakeHeroku).to have_created_app_for('staging')
19
19
  expect(FakeHeroku).to have_created_app_for('production')
20
- expect(FakeHeroku).to have_configured_vars('staging', 'SECRET_KEY_BASE')
21
- expect(FakeHeroku).to have_configured_vars(
22
- 'production',
23
- 'SECRET_KEY_BASE'
24
- )
20
+ expect(FakeHeroku).to have_configured_vars('staging', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
21
+ expect(FakeHeroku).to have_configured_vars('production', "#{app_name.dasherize.upcase}_SECRET_KEY_BASE")
25
22
  expect(FakeHeroku).to have_setup_pipeline_for(app_name)
26
23
 
27
24
  bin_setup_path = "#{project_path}/bin/setup"
@@ -46,7 +46,7 @@ RSpec.describe 'Suspend a new project with default configuration' do
46
46
  end
47
47
 
48
48
  it 'loads secret_key_base from env' do
49
- expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
49
+ expect(secrets_file).to match /secret_key_base: <%= ENV\[('|")#{app_name.upcase}_SECRET_KEY_BASE('|")\] %>/
50
50
  end
51
51
 
52
52
  it 'adds bin/setup file' do
@@ -119,7 +119,7 @@ RSpec.describe 'Suspend a new project with default configuration' do
119
119
 
120
120
  it 'uses APPLICATION_HOST, not HOST in the production config' do
121
121
  prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
122
- expect(prod_env_file).to match(/("|')APPLICATION_HOST("|')/)
122
+ expect(prod_env_file).to match /("|')#{app_name.upcase}_APPLICATION_HOST("|')/
123
123
  expect(prod_env_file).not_to match(/("|')HOST("|')/)
124
124
  end
125
125
 
@@ -42,6 +42,10 @@ module OnotoleTestHelpers
42
42
  @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
43
43
  end
44
44
 
45
+ def app_name
46
+ OnotoleTestHelpers::APP_NAME
47
+ end
48
+
45
49
  private
46
50
 
47
51
  def tmp_path
@@ -0,0 +1,2 @@
1
+ web: bundle exec puma -p $4: <%= "#{app_name.upcase}_PORT" %> -C ./config/puma.rb
2
+ worker: bundle exec rake jobs:work
@@ -14,22 +14,22 @@
14
14
  "RAILS_ENV":{
15
15
  "required":true
16
16
  },
17
- "SECRET_KEY_BASE":{
17
+ "<%= "#{app_name.upcase}_SECRET_KEY_BASE" %>":{
18
18
  "generator":"secret"
19
19
  },
20
- "SMTP_ADDRESS":{
20
+ "<%= "#{app_name.upcase}_SMTP_ADDRESS" %>":{
21
21
  "required":true
22
22
  },
23
- "SMTP_DOMAIN":{
23
+ "<%= "#{app_name.upcase}_SMTP_DOMAIN" %>":{
24
24
  "required":true
25
25
  },
26
- "SMTP_PASSWORD":{
26
+ "<%= "#{app_name.upcase}_SMTP_PASSWORD" %>":{
27
27
  "required":true
28
28
  },
29
- "SMTP_USERNAME":{
29
+ "<%= "#{app_name.upcase}_SMTP_USERNAME" %>":{
30
30
  "required":true
31
31
  },
32
- "WEB_CONCURRENCY":{
32
+ "<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>":{
33
33
  "required":true
34
34
  }
35
35
  },
@@ -0,0 +1,13 @@
1
+ # https://github.com/ddollar/forego
2
+ <%= "#{app_name.upcase}_ASSET_HOST=localhost:3000" %>
3
+ <%= "#{app_name.upcase}_APPLICATION_HOST=localhost:3000" %>
4
+ <%= "#{app_name.upcase}_PORT=3000" %>
5
+ RACK_ENV=development
6
+ <%= "#{app_name.upcase}_SECRET_KEY_BASE=development_secret" %>
7
+ EXECJS_RUNTIME=Node
8
+ <%= "#{app_name.upcase}_SMTP_ADDRESS=smtp.example.com" %>
9
+ <%= "#{app_name.upcase}_SMTP_DOMAIN=example.com" %>
10
+ <%= "#{app_name.upcase}_SMTP_PASSWORD=password" %>
11
+ <%= "#{app_name.upcase}_SMTP_USERNAME=username" %>
12
+ <%= "#{app_name.upcase}_WEB_CONCURRENCY=1" %>
13
+ <%= "#{app_name.upcase}_MAX_THREADS=16" %>
@@ -3,7 +3,7 @@
3
3
 
4
4
  # The environment variable WEB_CONCURRENCY may be set to a default value based
5
5
  # on dyno size. To manually configure this value use heroku config:set
6
- # WEB_CONCURRENCY.
6
+ # #{app_name}_WEB_CONCURRENCY.
7
7
  #
8
8
  # Increasing the number of workers will increase the amount of resting memory
9
9
  # your dynos use. Increasing the number of threads will increase the amount of
@@ -13,8 +13,8 @@
13
13
  # Starting with a low number of workers and threads provides adequate
14
14
  # performance for most applications, even under load, while maintaining a low
15
15
  # risk of overusing memory.
16
- workers Integer(ENV.fetch('WEB_CONCURRENCY', 2))
17
- threads_count = Integer(ENV.fetch('MAX_THREADS', 2))
16
+ workers Integer(ENV.fetch('<%= "#{app_name.upcase}_WEB_CONCURRENCY" %>', 2))
17
+ threads_count = Integer(ENV.fetch('<%= "#{app_name.upcase}_MAX_THREADS" %>', 2))
18
18
  threads(2, threads_count)
19
19
 
20
20
  preload_app!
@@ -1,5 +1,5 @@
1
1
  default: &default
2
- secret_key_base: <%%= ENV["SECRET_KEY_BASE"] %>
2
+ secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
3
3
 
4
4
  development:
5
5
  <<: *default
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ SMTP_SETTINGS = {
3
+ address: ENV.fetch(<%= "#{app_name.upcase}_SMTP_ADDRESS" %>), # example: "smtp.sendgrid.net"
4
+ authentication: :plain,
5
+ domain: ENV.fetch(<%= "#{app_name.upcase}_SMTP_DOMAIN" %>), # example: "heroku.com"
6
+ enable_starttls_auto: true,
7
+ password: ENV.fetch(<%= "#{app_name.upcase}_SMTP_PASSWORD" %>),
8
+ port: '587',
9
+ user_name: ENV.fetch(<%= "#{app_name.upcase}_SMTP_USERNAME" %>)
10
+ }.freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onotole
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kvokka
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-04 00:00:00.000000000 Z
12
+ date: 2016-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -111,7 +111,7 @@ files:
111
111
  - spec/support/fake_heroku.rb
112
112
  - spec/support/onotole.rb
113
113
  - templates/Gemfile.erb
114
- - templates/Procfile
114
+ - templates/Procfile.erb
115
115
  - templates/README.md.erb
116
116
  - templates/_analytics.html.erb
117
117
  - templates/_flashes.html.erb
@@ -139,8 +139,8 @@ files:
139
139
  - templates/devise.ru.yml
140
140
  - templates/devise_rspec.rb
141
141
  - templates/disable_xml_params.rb
142
+ - templates/dotenv.erb
142
143
  - templates/dotfiles/.ctags
143
- - templates/dotfiles/.env
144
144
  - templates/dotfiles/.rspec
145
145
  - templates/errors.rb
146
146
  - templates/factories.rb
@@ -156,12 +156,12 @@ files:
156
156
  - templates/onotole_layout.html.erb.erb
157
157
  - templates/onotole_overcommit.yml
158
158
  - templates/postgresql_database.yml.erb
159
- - templates/puma.rb
159
+ - templates/puma.rb.erb
160
160
  - templates/rails_helper.rb
161
161
  - templates/rubocop.yml
162
162
  - templates/secrets.yml
163
163
  - templates/shoulda_matchers_config_rspec.rb
164
- - templates/smtp.rb
164
+ - templates/smtp.rb.erb
165
165
  - templates/spec_helper.rb
166
166
  - templates/staging.rb
167
167
  - templates/tinymce.yml
@@ -1,2 +0,0 @@
1
- web: bundle exec puma -p $PORT -C ./config/puma.rb
2
- worker: bundle exec rake jobs:work
@@ -1,13 +0,0 @@
1
- # https://github.com/ddollar/forego
2
- ASSET_HOST=localhost:3000
3
- APPLICATION_HOST=localhost:3000
4
- PORT=3000
5
- RACK_ENV=development
6
- SECRET_KEY_BASE=development_secret
7
- EXECJS_RUNTIME=Node
8
- SMTP_ADDRESS=smtp.example.com
9
- SMTP_DOMAIN=example.com
10
- SMTP_PASSWORD=password
11
- SMTP_USERNAME=username
12
- WEB_CONCURRENCY=1
13
- MAX_THREADS=16
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- SMTP_SETTINGS = {
3
- address: ENV.fetch('SMTP_ADDRESS'), # example: "smtp.sendgrid.net"
4
- authentication: :plain,
5
- domain: ENV.fetch('SMTP_DOMAIN'), # example: "heroku.com"
6
- enable_starttls_auto: true,
7
- password: ENV.fetch('SMTP_PASSWORD'),
8
- port: '587',
9
- user_name: ENV.fetch('SMTP_USERNAME')
10
- }.freeze