greased-rails 3.2.3 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +5 -1
- data/Rakefile +2 -0
- data/lib/greased-rails.rb +2 -1
- data/lib/greased.rb +7 -7
- data/lib/greased/applicator.rb +20 -0
- data/lib/greased/rails.rb +0 -1
- data/lib/greased/rails/engine.rb +4 -113
- data/lib/greased/rails/settings.rb +63 -0
- data/lib/greased/rails/variables.rb +64 -0
- data/lib/greased/rails/version.rb +1 -1
- data/tasks/greased.rake +3 -9
- metadata +13 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 271073f9cee40b3a5f3f98444e9f370364ceeeda
|
4
|
+
data.tar.gz: a57a9ee7113bc461de7de486313dadd806d0ad49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d319dd7474e1ac23199ba4bb23eb2a39aeb4d9008c6f1a81cc3c9d8b3b29cc4f4e32d21c1967b1a2f9dfcdfc84be2082fa6b0527d254529b8f9e4c346bf550f
|
7
|
+
data.tar.gz: 2fd8fadfb0c52e4b29db1430e587fbc44691d4a3c11e4d0800b12519c2e4f34065b59746f94db84c52b78981e8116b521c5a9a452e6f719711f3f3c26030d363
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Greased Rails
|
1
|
+
# Greased Rails [![Dependency Status](https://gemnasium.com/joelvh/greased-rails.png)](https://gemnasium.com/joelvh/greased-rails)
|
2
2
|
|
3
3
|
Reusable default application settings, environment variables, and deployment tasks.
|
4
4
|
|
@@ -10,6 +10,10 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
gem 'greased-rails'
|
12
12
|
|
13
|
+
To automatically load environment variables and settings, require the the railties:
|
14
|
+
|
15
|
+
gem 'greased-rails', require: %w{greased/rails/variables greased/rails/settings}
|
16
|
+
|
13
17
|
And then execute:
|
14
18
|
|
15
19
|
$ bundle
|
data/Rakefile
CHANGED
data/lib/greased-rails.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
require "greased"
|
2
|
+
require 'greased/rails/version'
|
data/lib/greased.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
require "greased/loggable"
|
3
3
|
|
4
4
|
module Greased
|
5
5
|
extend Loggable
|
@@ -31,10 +31,10 @@ module Greased
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
require "greased/applicator"
|
35
|
+
require "greased/options"
|
36
|
+
require "greased/method_caller"
|
37
|
+
require "greased/setting"
|
38
|
+
require "greased/settings"
|
39
39
|
|
40
|
-
|
40
|
+
require "greased/rails" if defined? ::Rails
|
data/lib/greased/applicator.rb
CHANGED
@@ -49,6 +49,26 @@ module Greased
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
# Apply variables to `ENV` constant.
|
53
|
+
#
|
54
|
+
# @param options [Hash] Options for setting `ENV` variables.
|
55
|
+
# @option options [Boolean] :overwrite Whether to overwrite
|
56
|
+
# existing values in `ENV`
|
57
|
+
# @return [Hash] Returns a list of variables that were applied
|
58
|
+
# (unless the variable existed and the :overwrite option
|
59
|
+
# was not specified)
|
60
|
+
def apply_variables_to_environment!(options = {})
|
61
|
+
variables_to_apply = variables.except("RACK_ENV", "RAILS_ENV")
|
62
|
+
|
63
|
+
variables_to_apply.each do |key, value|
|
64
|
+
if !ENV.has_key?(key.to_s) || options[:overwrite] == true
|
65
|
+
ENV[key.to_s] = value.to_s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
variables_to_apply
|
70
|
+
end
|
71
|
+
|
52
72
|
def settings(options = {})
|
53
73
|
options = @options.merge(:env => env).merge(options)
|
54
74
|
# get settings for application environment
|
data/lib/greased/rails.rb
CHANGED
data/lib/greased/rails/engine.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
#require 'greased-rails'
|
2
|
-
require 'rails'
|
2
|
+
#require 'rails'
|
3
3
|
|
4
4
|
module Greased
|
5
5
|
module Rails
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
|
8
|
-
Greased.logger.level = Logger::DEBUG if ::Rails.env.development?
|
9
|
-
|
10
|
-
# Config defaults
|
11
|
-
#config.greased_options =
|
12
|
-
#config.greased_applicator =
|
13
|
-
|
14
8
|
# Load rake tasks
|
15
9
|
rake_tasks do
|
10
|
+
|
11
|
+
Greased.logger.level = Logger::DEBUG if ::Rails.env.development?
|
12
|
+
|
16
13
|
path = Greased.file_path(File.dirname(__FILE__), '../../../tasks/')
|
17
14
|
|
18
15
|
Dir["#{path}/*.rake"].each do |filename|
|
@@ -20,112 +17,6 @@ module Greased
|
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
|
-
#http://guides.rubyonrails.org/configuring.html
|
24
|
-
#before_configuration
|
25
|
-
#before_initialize - before initialization
|
26
|
-
#to_prepare - after railties and application initializers, before eager loading and middleware (on each request in dev)
|
27
|
-
#before_eager_load - default behavior in production
|
28
|
-
#after_initialize - after application initializes - BEFORE application initializers
|
29
|
-
|
30
|
-
#app.config.before_configuration
|
31
|
-
#:load_environment_hook
|
32
|
-
config.before_configuration do |application|
|
33
|
-
|
34
|
-
options = Options.find(::Rails.root)
|
35
|
-
applicator = Applicator.new(application, options)
|
36
|
-
variables = applicator.variables.except("RACK_ENV", "RAILS_ENV")
|
37
|
-
|
38
|
-
variables.each do |key, value|
|
39
|
-
ENV[key.to_s] = value.to_s
|
40
|
-
end
|
41
|
-
|
42
|
-
if ::Rails.env.development?
|
43
|
-
|
44
|
-
Greased.logger.debug " "
|
45
|
-
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
46
|
-
Greased.logger.debug "# #"
|
47
|
-
Greased.logger.debug "# ... loaded options ... #"
|
48
|
-
Greased.logger.debug "# #"
|
49
|
-
Greased.logger.debug "#####################################################################"
|
50
|
-
Greased.logger.debug " "
|
51
|
-
|
52
|
-
pp options
|
53
|
-
|
54
|
-
Greased.logger.debug " "
|
55
|
-
Greased.logger.debug "#####################################################################"
|
56
|
-
Greased.logger.debug " "
|
57
|
-
|
58
|
-
##########################
|
59
|
-
|
60
|
-
Greased.logger.debug " "
|
61
|
-
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
62
|
-
Greased.logger.debug "# #"
|
63
|
-
Greased.logger.debug "# ... loading environment variables ... #"
|
64
|
-
Greased.logger.debug "# #"
|
65
|
-
Greased.logger.debug "#####################################################################"
|
66
|
-
Greased.logger.debug " "
|
67
|
-
|
68
|
-
applicator.list_env.map.collect do |var|
|
69
|
-
Greased.logger.debug " #{var}"
|
70
|
-
end
|
71
|
-
|
72
|
-
Greased.logger.debug " "
|
73
|
-
Greased.logger.debug "#####################################################################"
|
74
|
-
Greased.logger.debug " "
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
# config.before_configuration {|app| Greased.logger.debug "BEFORE CONFIGURATION"}
|
80
|
-
#
|
81
|
-
# config.before_initialize {|app| Greased.logger.debug "BEFORE INITIALIZE"}
|
82
|
-
#
|
83
|
-
# config.to_prepare {|app| Greased.logger.debug "TO PREPARE"}
|
84
|
-
#
|
85
|
-
# config.before_eager_load {|app| Greased.logger.debug "BEFORE EAGER LOAD"}
|
86
|
-
#
|
87
|
-
# config.after_initialize {|app| Greased.logger.debug "AFTER INITIALIZE"}
|
88
|
-
#
|
89
|
-
# hooks = [
|
90
|
-
# :load_environment_hook, :load_active_support, :preload_frameworks, :initialize_logger, :initialize_cache, :set_clear_dependencies_hook,
|
91
|
-
# :initialize_dependency_mechanism, :bootstrap_hook, "i18n.callbacks", :set_load_path, :set_autoload_paths, :add_routing_paths,
|
92
|
-
# :add_locales, :add_view_paths, :load_environment_config, :append_asset_paths, :prepend_helpers_path, :load_config_initializers,
|
93
|
-
# :engines_blank_point, :add_generator_templates, :ensure_autoload_once_paths_as_subset, :add_to_prepare_blocks, :add_builtin_route,
|
94
|
-
# :build_middleware_stack, :eager_load!, :finisher_hook, :set_routes_reloader, :disable_dependency_loading
|
95
|
-
# ]
|
96
|
-
#
|
97
|
-
# hooks.each do |hook_name|
|
98
|
-
# initializer("greased.before.#{hook_name}", :before => hook_name, :group => :all) {|a| Greased.logger.debug "BEFORE #{hook_name}".upcase}
|
99
|
-
# end
|
100
|
-
|
101
|
-
# RUNS BEFORE ENVIRONMENT CONFIGS ARE LOADED!
|
102
|
-
#app.config.before_initialize
|
103
|
-
config.before_configuration do |application|
|
104
|
-
|
105
|
-
options = Options.find(::Rails.root)
|
106
|
-
applicator = Applicator.new(application, options)
|
107
|
-
|
108
|
-
applicator.settings.apply!
|
109
|
-
|
110
|
-
if ::Rails.env.development?
|
111
|
-
Greased.logger.debug " "
|
112
|
-
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
113
|
-
Greased.logger.debug "# #"
|
114
|
-
Greased.logger.debug "# ... loading application settings ... #"
|
115
|
-
Greased.logger.debug "# #"
|
116
|
-
Greased.logger.debug "#####################################################################"
|
117
|
-
Greased.logger.debug " "
|
118
|
-
|
119
|
-
applicator.settings.list.map(&:strip).map{|setting| setting.split("\n")}.flatten.each do |line|
|
120
|
-
Greased.logger.debug " #{line}"
|
121
|
-
end
|
122
|
-
|
123
|
-
Greased.logger.debug " "
|
124
|
-
Greased.logger.debug "#####################################################################"
|
125
|
-
Greased.logger.debug " "
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
20
|
end
|
130
21
|
end
|
131
22
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#require 'greased-rails'
|
2
|
+
#require 'rails'
|
3
|
+
require 'greased'
|
4
|
+
|
5
|
+
module Greased
|
6
|
+
module Rails
|
7
|
+
class Settings < ::Rails::Engine
|
8
|
+
|
9
|
+
# config.before_configuration {|app| Greased.logger.debug "BEFORE CONFIGURATION"}
|
10
|
+
#
|
11
|
+
# config.before_initialize {|app| Greased.logger.debug "BEFORE INITIALIZE"}
|
12
|
+
#
|
13
|
+
# config.to_prepare {|app| Greased.logger.debug "TO PREPARE"}
|
14
|
+
#
|
15
|
+
# config.before_eager_load {|app| Greased.logger.debug "BEFORE EAGER LOAD"}
|
16
|
+
#
|
17
|
+
# config.after_initialize {|app| Greased.logger.debug "AFTER INITIALIZE"}
|
18
|
+
#
|
19
|
+
# hooks = [
|
20
|
+
# :load_environment_hook, :load_active_support, :preload_frameworks, :initialize_logger, :initialize_cache, :set_clear_dependencies_hook,
|
21
|
+
# :initialize_dependency_mechanism, :bootstrap_hook, "i18n.callbacks", :set_load_path, :set_autoload_paths, :add_routing_paths,
|
22
|
+
# :add_locales, :add_view_paths, :load_environment_config, :append_asset_paths, :prepend_helpers_path, :load_config_initializers,
|
23
|
+
# :engines_blank_point, :add_generator_templates, :ensure_autoload_once_paths_as_subset, :add_to_prepare_blocks, :add_builtin_route,
|
24
|
+
# :build_middleware_stack, :eager_load!, :finisher_hook, :set_routes_reloader, :disable_dependency_loading
|
25
|
+
# ]
|
26
|
+
#
|
27
|
+
# hooks.each do |hook_name|
|
28
|
+
# initializer("greased.before.#{hook_name}", :before => hook_name, :group => :all) {|a| Greased.logger.debug "BEFORE #{hook_name}".upcase}
|
29
|
+
# end
|
30
|
+
|
31
|
+
# RUNS BEFORE ENVIRONMENT CONFIGS ARE LOADED!
|
32
|
+
#app.config.before_initialize
|
33
|
+
config.before_configuration do |application|
|
34
|
+
|
35
|
+
Greased.logger.level = Logger::DEBUG if ::Rails.env.development?
|
36
|
+
|
37
|
+
options = Options.find(::Rails.root)
|
38
|
+
applicator = Applicator.new(application, options)
|
39
|
+
|
40
|
+
applicator.settings.apply!
|
41
|
+
|
42
|
+
if ::Rails.env.development?
|
43
|
+
Greased.logger.debug " "
|
44
|
+
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
45
|
+
Greased.logger.debug "# #"
|
46
|
+
Greased.logger.debug "# ... loading application settings ... #"
|
47
|
+
Greased.logger.debug "# #"
|
48
|
+
Greased.logger.debug "#####################################################################"
|
49
|
+
Greased.logger.debug " "
|
50
|
+
|
51
|
+
applicator.settings.list.map(&:strip).map{|setting| setting.split("\n")}.flatten.each do |line|
|
52
|
+
Greased.logger.debug " #{line}"
|
53
|
+
end
|
54
|
+
|
55
|
+
Greased.logger.debug " "
|
56
|
+
Greased.logger.debug "#####################################################################"
|
57
|
+
Greased.logger.debug " "
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#require 'greased-rails'
|
2
|
+
#require 'rails'
|
3
|
+
require 'greased'
|
4
|
+
|
5
|
+
module Greased
|
6
|
+
module Rails
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
|
9
|
+
#http://guides.rubyonrails.org/configuring.html
|
10
|
+
#before_configuration
|
11
|
+
#before_initialize - before initialization
|
12
|
+
#to_prepare - after railties and application initializers, before eager loading and middleware (on each request in dev)
|
13
|
+
#before_eager_load - default behavior in production
|
14
|
+
#after_initialize - after application initializes - BEFORE application initializers
|
15
|
+
|
16
|
+
#app.config.before_configuration
|
17
|
+
#:load_environment_hook
|
18
|
+
config.before_configuration do |application|
|
19
|
+
|
20
|
+
Greased.logger.level = Logger::DEBUG if ::Rails.env.development?
|
21
|
+
|
22
|
+
options = Options.find(::Rails.root)
|
23
|
+
applicator = Applicator.new(application, options)
|
24
|
+
|
25
|
+
applicator.apply_variables_to_environment!(overwrite: false)
|
26
|
+
|
27
|
+
if ::Rails.env.development?
|
28
|
+
|
29
|
+
Greased.logger.debug " "
|
30
|
+
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
31
|
+
Greased.logger.debug "# #"
|
32
|
+
Greased.logger.debug "# ... loaded options ... #"
|
33
|
+
Greased.logger.debug "# #"
|
34
|
+
Greased.logger.debug "#####################################################################"
|
35
|
+
Greased.logger.debug " "
|
36
|
+
|
37
|
+
Greased.logger.debug " "
|
38
|
+
Greased.logger.debug "#####################################################################"
|
39
|
+
Greased.logger.debug " "
|
40
|
+
|
41
|
+
##########################
|
42
|
+
|
43
|
+
Greased.logger.debug " "
|
44
|
+
Greased.logger.debug "## GREASED [#{applicator.env.upcase}] #{'#' * (55 - applicator.env.size)}"
|
45
|
+
Greased.logger.debug "# #"
|
46
|
+
Greased.logger.debug "# ... loading environment variables ... #"
|
47
|
+
Greased.logger.debug "# #"
|
48
|
+
Greased.logger.debug "#####################################################################"
|
49
|
+
Greased.logger.debug " "
|
50
|
+
|
51
|
+
applicator.list_env.map.collect do |var|
|
52
|
+
Greased.logger.debug " #{var}"
|
53
|
+
end
|
54
|
+
|
55
|
+
Greased.logger.debug " "
|
56
|
+
Greased.logger.debug "#####################################################################"
|
57
|
+
Greased.logger.debug " "
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/tasks/greased.rake
CHANGED
@@ -2,8 +2,8 @@ require 'greased-rails'
|
|
2
2
|
|
3
3
|
namespace :greased do
|
4
4
|
namespace :env do
|
5
|
-
task :dump
|
6
|
-
options
|
5
|
+
task :dump do
|
6
|
+
options = Greased::Options.find(Rails.root)
|
7
7
|
applicator = Greased::Applicator.new(Rails.application, options)
|
8
8
|
|
9
9
|
Greased.logger.debug ""
|
@@ -14,7 +14,7 @@ namespace :greased do
|
|
14
14
|
Greased.logger.debug "#####################################################################"
|
15
15
|
Greased.logger.debug ""
|
16
16
|
|
17
|
-
environments =
|
17
|
+
environments = %w{test development staging production}
|
18
18
|
longest = environments.map(&:size).max
|
19
19
|
|
20
20
|
environments.each do |env|
|
@@ -30,10 +30,4 @@ namespace :greased do
|
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
namespace :heroku do
|
35
|
-
task :deploy, [:env] => [:environment] do |t, args|
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
33
|
end
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greased-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
5
|
-
prerelease:
|
4
|
+
version: 3.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joel Van Horn
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.2.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.2.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: railties
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 3.2.0
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 3.2.0
|
46
41
|
description: Reusable default application settings, environment variables, and deployment
|
@@ -66,6 +61,8 @@ files:
|
|
66
61
|
- lib/greased/options.rb
|
67
62
|
- lib/greased/rails.rb
|
68
63
|
- lib/greased/rails/engine.rb
|
64
|
+
- lib/greased/rails/settings.rb
|
65
|
+
- lib/greased/rails/variables.rb
|
69
66
|
- lib/greased/rails/version.rb
|
70
67
|
- lib/greased/setting.rb
|
71
68
|
- lib/greased/settings.rb
|
@@ -77,34 +74,27 @@ files:
|
|
77
74
|
- templates/greased_variables.yml
|
78
75
|
homepage: http://github.com/joelvh/greased-rails
|
79
76
|
licenses: []
|
77
|
+
metadata: {}
|
80
78
|
post_install_message:
|
81
79
|
rdoc_options: []
|
82
80
|
require_paths:
|
83
81
|
- lib
|
84
82
|
- tasks
|
85
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
84
|
requirements:
|
88
|
-
- -
|
85
|
+
- - '>='
|
89
86
|
- !ruby/object:Gem::Version
|
90
87
|
version: '0'
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
hash: 2340121733539967068
|
94
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
89
|
requirements:
|
97
|
-
- -
|
90
|
+
- - '>='
|
98
91
|
- !ruby/object:Gem::Version
|
99
92
|
version: '0'
|
100
|
-
segments:
|
101
|
-
- 0
|
102
|
-
hash: 2340121733539967068
|
103
93
|
requirements: []
|
104
94
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
95
|
+
rubygems_version: 2.1.5
|
106
96
|
signing_key:
|
107
|
-
specification_version:
|
97
|
+
specification_version: 4
|
108
98
|
summary: Replicate common Rails application settings and environment variables using
|
109
99
|
templates. Handy deployment tasks make managing your environments easier.
|
110
100
|
test_files: []
|