giga-clean-kit 0.0.1

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 (44) hide show
  1. checksums.yaml +7 -0
  2. data/figaro-1.3.0/CHANGELOG.md +129 -0
  3. data/figaro-1.3.0/CONTRIBUTING.md +48 -0
  4. data/figaro-1.3.0/Gemfile +12 -0
  5. data/figaro-1.3.0/LICENSE.txt +22 -0
  6. data/figaro-1.3.0/README.md +351 -0
  7. data/figaro-1.3.0/Rakefile +6 -0
  8. data/figaro-1.3.0/bin/figaro +5 -0
  9. data/figaro-1.3.0/figaro.gemspec +25 -0
  10. data/figaro-1.3.0/gemfiles/rails52.gemfile +11 -0
  11. data/figaro-1.3.0/gemfiles/rails60.gemfile +14 -0
  12. data/figaro-1.3.0/gemfiles/rails61.gemfile +14 -0
  13. data/figaro-1.3.0/gemfiles/rails70.gemfile +14 -0
  14. data/figaro-1.3.0/gemfiles/rails71.gemfile +11 -0
  15. data/figaro-1.3.0/gemfiles/rails72.gemfile +11 -0
  16. data/figaro-1.3.0/gemfiles/rails80.gemfile +11 -0
  17. data/figaro-1.3.0/lib/figaro/application.rb +91 -0
  18. data/figaro-1.3.0/lib/figaro/cli/heroku_set.rb +33 -0
  19. data/figaro-1.3.0/lib/figaro/cli/install/application.yml +11 -0
  20. data/figaro-1.3.0/lib/figaro/cli/install.rb +32 -0
  21. data/figaro-1.3.0/lib/figaro/cli/task.rb +37 -0
  22. data/figaro-1.3.0/lib/figaro/cli.rb +42 -0
  23. data/figaro-1.3.0/lib/figaro/env.rb +45 -0
  24. data/figaro-1.3.0/lib/figaro/error.rb +17 -0
  25. data/figaro-1.3.0/lib/figaro/rails/application.rb +21 -0
  26. data/figaro-1.3.0/lib/figaro/rails/railtie.rb +9 -0
  27. data/figaro-1.3.0/lib/figaro/rails/tasks.rake +6 -0
  28. data/figaro-1.3.0/lib/figaro/rails.rb +9 -0
  29. data/figaro-1.3.0/lib/figaro.rb +180 -0
  30. data/figaro-1.3.0/spec/figaro/application_spec.rb +262 -0
  31. data/figaro-1.3.0/spec/figaro/cli/heroku_set_spec.rb +67 -0
  32. data/figaro-1.3.0/spec/figaro/cli/install_spec.rb +49 -0
  33. data/figaro-1.3.0/spec/figaro/env_spec.rb +195 -0
  34. data/figaro-1.3.0/spec/figaro/rails/application_spec.rb +41 -0
  35. data/figaro-1.3.0/spec/figaro_spec.rb +99 -0
  36. data/figaro-1.3.0/spec/rails_spec.rb +59 -0
  37. data/figaro-1.3.0/spec/spec_helper.rb +8 -0
  38. data/figaro-1.3.0/spec/support/aruba.rb +18 -0
  39. data/figaro-1.3.0/spec/support/bin/heroku +5 -0
  40. data/figaro-1.3.0/spec/support/command_helpers.rb +17 -0
  41. data/figaro-1.3.0/spec/support/command_interceptor.rb +33 -0
  42. data/figaro-1.3.0/spec/support/reset.rb +13 -0
  43. data/giga-clean-kit.gemspec +11 -0
  44. metadata +82 -0
@@ -0,0 +1,262 @@
1
+ require "tempfile"
2
+
3
+ module Figaro
4
+ describe Application do
5
+ before do
6
+ allow_any_instance_of(Application).to receive(:default_path) { "/path/to/app/config/application.yml" }
7
+ allow_any_instance_of(Application).to receive(:default_environment) { "development" }
8
+ end
9
+
10
+ describe "#path" do
11
+ it "uses the default" do
12
+ application = Application.new
13
+
14
+ expect(application.path).to eq("/path/to/app/config/application.yml")
15
+ end
16
+
17
+ it "is configurable via initialization" do
18
+ application = Application.new(path: "/app/env.yml")
19
+
20
+ expect(application.path).to eq("/app/env.yml")
21
+ end
22
+
23
+ it "is configurable via setter" do
24
+ application = Application.new
25
+ application.path = "/app/env.yml"
26
+
27
+ expect(application.path).to eq("/app/env.yml")
28
+ end
29
+
30
+ it "casts to string" do
31
+ application = Application.new(path: Pathname.new("/app/env.yml"))
32
+
33
+ expect(application.path).to eq("/app/env.yml")
34
+ expect(application.environment).not_to be_a(Pathname)
35
+ end
36
+
37
+ it "follows a changing default" do
38
+ application = Application.new
39
+
40
+ expect {
41
+ allow(application).to receive(:default_path) { "/app/env.yml" }
42
+ }.to change {
43
+ application.path
44
+ }.from("/path/to/app/config/application.yml").to("/app/env.yml")
45
+ end
46
+ end
47
+
48
+ describe "#environment" do
49
+ it "uses the default" do
50
+ application = Application.new
51
+
52
+ expect(application.environment).to eq("development")
53
+ end
54
+
55
+ it "is configurable via initialization" do
56
+ application = Application.new(environment: "test")
57
+
58
+ expect(application.environment).to eq("test")
59
+ end
60
+
61
+ it "is configurable via setter" do
62
+ application = Application.new
63
+ application.environment = "test"
64
+
65
+ expect(application.environment).to eq("test")
66
+ end
67
+
68
+ it "casts to string" do
69
+ application = Application.new(environment: :test)
70
+
71
+ expect(application.environment).to eq("test")
72
+ expect(application.environment).not_to be_a(Symbol)
73
+ end
74
+
75
+ it "respects nil" do
76
+ application = Application.new(environment: nil)
77
+
78
+ expect(application.environment).to eq(nil)
79
+ end
80
+
81
+ it "follows a changing default" do
82
+ application = Application.new
83
+
84
+ expect {
85
+ allow(application).to receive(:default_environment) { "test" }
86
+ }.to change {
87
+ application.environment
88
+ }.from("development").to("test")
89
+ end
90
+ end
91
+
92
+ describe "#configuration" do
93
+ def yaml_to_path(yaml)
94
+ Tempfile.open("figaro") do |file|
95
+ file.write(yaml)
96
+ file.path
97
+ end
98
+ end
99
+
100
+ it "loads values from YAML" do
101
+ application = Application.new(path: yaml_to_path(<<-YAML))
102
+ foo: bar
103
+ YAML
104
+
105
+ expect(application.configuration).to eq("foo" => "bar")
106
+ end
107
+
108
+ it "merges environment-specific values" do
109
+ application = Application.new(path: yaml_to_path(<<-YAML), environment: "test")
110
+ foo: bar
111
+ test:
112
+ foo: baz
113
+ YAML
114
+
115
+ expect(application.configuration).to eq("foo" => "baz")
116
+ end
117
+
118
+ it "drops unused environment-specific values" do
119
+ application = Application.new(path: yaml_to_path(<<-YAML), environment: "test")
120
+ foo: bar
121
+ test:
122
+ foo: baz
123
+ production:
124
+ foo: bad
125
+ YAML
126
+
127
+ expect(application.configuration).to eq("foo" => "baz")
128
+ end
129
+
130
+ it "is empty when no YAML file is present" do
131
+ application = Application.new(path: "/path/to/nowhere")
132
+
133
+ expect(application.configuration).to eq({})
134
+ end
135
+
136
+ it "is empty when the YAML file is blank" do
137
+ application = Application.new(path: yaml_to_path(""))
138
+
139
+ expect(application.configuration).to eq({})
140
+ end
141
+
142
+ it "is empty when the YAML file contains only comments" do
143
+ application = Application.new(path: yaml_to_path(<<-YAML))
144
+ # Comment
145
+ YAML
146
+
147
+ expect(application.configuration).to eq({})
148
+ end
149
+
150
+ it "processes ERB" do
151
+ application = Application.new(path: yaml_to_path(<<-YAML))
152
+ foo: <%= "bar".upcase %>
153
+ YAML
154
+
155
+ expect(application.configuration).to eq("foo" => "BAR")
156
+ end
157
+
158
+ it "handles an empty environment block" do
159
+ application = Application.new(path: yaml_to_path("development:"))
160
+
161
+ expect {
162
+ application.configuration
163
+ }.not_to raise_error
164
+ end
165
+
166
+ it "follows a changing default path" do
167
+ path_1 = yaml_to_path("foo: bar")
168
+ path_2 = yaml_to_path("foo: baz")
169
+
170
+ application = Application.new
171
+ allow(application).to receive(:default_path) { path_1 }
172
+
173
+ expect {
174
+ allow(application).to receive(:default_path) { path_2 }
175
+ }.to change {
176
+ application.configuration
177
+ }.from("foo" => "bar").to("foo" => "baz")
178
+ end
179
+
180
+ it "follows a changing default environment" do
181
+ application = Application.new(path: yaml_to_path(<<-YAML))
182
+ foo: bar
183
+ test:
184
+ foo: baz
185
+ YAML
186
+ allow(application).to receive(:default_environment) { "development" }
187
+
188
+ expect {
189
+ allow(application).to receive(:default_environment) { "test" }
190
+ }.to change {
191
+ application.configuration
192
+ }.from("foo" => "bar").to("foo" => "baz")
193
+ end
194
+ end
195
+
196
+ describe "#load" do
197
+ let!(:application) { Application.new }
198
+
199
+ before do
200
+ allow(application).to receive(:configuration) { { "foo" => "bar" } }
201
+ end
202
+
203
+ it "merges values into ENV" do
204
+ expect {
205
+ application.load
206
+ }.to change {
207
+ ::ENV["foo"]
208
+ }.from(nil).to("bar")
209
+ end
210
+
211
+ it "skips keys (and warns) that have already been set externally" do
212
+ ::ENV["foo"] = "baz"
213
+
214
+ expect(application).to receive(:warn)
215
+
216
+ expect {
217
+ application.load
218
+ }.not_to change {
219
+ ::ENV["foo"]
220
+ }
221
+ end
222
+
223
+ it "sets keys that have already been set internally" do
224
+ application.load
225
+
226
+ allow(application).to receive(:configuration) { { "foo" => "baz" } }
227
+
228
+ expect {
229
+ application.load
230
+ }.to change {
231
+ ::ENV["foo"]
232
+ }.from("bar").to("baz")
233
+ end
234
+
235
+ it "warns when a key isn't a string" do
236
+ allow(application).to receive(:configuration) { { foo: "bar" } }
237
+
238
+ expect(application).to receive(:warn)
239
+
240
+ application.load
241
+ end
242
+
243
+ it "warns when a value isn't a string" do
244
+ allow(application).to receive(:configuration) { { "foo" => ["bar"] } }
245
+
246
+ expect(application).to receive(:warn)
247
+
248
+ application.load
249
+ end
250
+
251
+ it "allows nil values" do
252
+ allow(application).to receive(:configuration) { { "foo" => nil } }
253
+
254
+ expect {
255
+ application.load
256
+ }.not_to change {
257
+ ::ENV["foo"]
258
+ }
259
+ end
260
+ end
261
+ end
262
+ end
@@ -0,0 +1,67 @@
1
+ describe "figaro heroku:set" do
2
+ before do
3
+ create_directory("example")
4
+ cd("example")
5
+ write_file("config/application.yml", "foo: bar")
6
+ end
7
+
8
+ it "sends Figaro configuration to Heroku" do
9
+ run_command_and_stop("figaro heroku:set")
10
+
11
+ command = commands.last
12
+ expect(command.name).to eq("heroku")
13
+ expect(command.args).to eq(["config:set", "foo=bar"])
14
+ end
15
+
16
+ it "respects path" do
17
+ write_file("env.yml", "foo: bar")
18
+
19
+ run_command_and_stop("figaro heroku:set -p env.yml")
20
+
21
+ command = commands.last
22
+ expect(command.name).to eq("heroku")
23
+ expect(command.args).to eq(["config:set", "foo=bar"])
24
+ end
25
+
26
+ it "respects environment" do
27
+ overwrite_file("config/application.yml", <<-EOF)
28
+ foo: bar
29
+ test:
30
+ foo: baz
31
+ EOF
32
+
33
+ run_command_and_stop("figaro heroku:set -e test")
34
+
35
+ command = commands.last
36
+ expect(command.name).to eq("heroku")
37
+ expect(command.args).to eq(["config:set", "foo=baz"])
38
+ end
39
+
40
+ it "targets a specific Heroku app" do
41
+ run_command_and_stop("figaro heroku:set -a foo-bar-app")
42
+
43
+ command = commands.last
44
+ expect(command.name).to eq("heroku")
45
+ expect(command.args.shift).to eq("config:set")
46
+ expect(command.args).to match_array(["foo=bar", "--app=foo-bar-app"])
47
+ end
48
+
49
+ it "targets a specific Heroku git remote" do
50
+ run_command_and_stop("figaro heroku:set -r production")
51
+
52
+ command = commands.last
53
+ expect(command.name).to eq("heroku")
54
+ expect(command.args.shift).to eq("config:set")
55
+ expect(command.args).to match_array(["foo=bar", "--remote=production"])
56
+ end
57
+
58
+ it "handles values with special characters" do
59
+ overwrite_file("config/application.yml", "foo: bar baz")
60
+
61
+ run_command_and_stop("figaro heroku:set")
62
+
63
+ command = commands.last
64
+ expect(command.name).to eq("heroku")
65
+ expect(command.args).to eq(["config:set", "foo=bar baz"])
66
+ end
67
+ end
@@ -0,0 +1,49 @@
1
+ describe "figaro install" do
2
+ before do
3
+ create_directory("example")
4
+ cd("example")
5
+ end
6
+
7
+ it "creates a configuration file" do
8
+ run_command_and_stop("figaro install")
9
+
10
+ expect("config/application.yml").to be_an_existing_file
11
+ end
12
+
13
+ it "respects path" do
14
+ run_command_and_stop("figaro install -p env.yml")
15
+
16
+ expect("env.yml").to be_an_existing_file
17
+ end
18
+
19
+ context "with a .gitignore file" do
20
+ before do
21
+ write_file(".gitignore", <<-EOF)
22
+ /foo
23
+ /bar
24
+ EOF
25
+ end
26
+
27
+ it "Git-ignores the configuration file if applicable" do
28
+ run_command_and_stop("figaro install")
29
+
30
+ expect(".gitignore").to have_file_content(%r(^/foo$))
31
+ expect(".gitignore").to have_file_content(%r(^/bar$))
32
+ expect(".gitignore").to have_file_content(%r(^/config/application\.yml$))
33
+ end
34
+
35
+ it "respects path" do
36
+ run_command_and_stop("figaro install -p env.yml")
37
+
38
+ expect(".gitignore").to have_file_content(%r(^/env\.yml$))
39
+ end
40
+ end
41
+
42
+ context "without a .gitignore file" do
43
+ it "doesn't generate a new .gitignore file" do
44
+ run_command_and_stop("figaro install")
45
+
46
+ expect(".gitignore").not_to be_an_existing_file
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,195 @@
1
+ describe Figaro::ENV do
2
+ subject(:env) { Figaro::ENV }
3
+
4
+ before do
5
+ ::ENV["HELLO"] = "world"
6
+ ::ENV["foo"] = "bar"
7
+ end
8
+
9
+ describe "#method_missing" do
10
+ context "plain methods" do
11
+ it "makes ENV values accessible as lowercase methods" do
12
+ expect(env.hello).to eq("world")
13
+ expect(env.foo).to eq("bar")
14
+ end
15
+
16
+ it "makes ENV values accessible as uppercase methods" do
17
+ expect(env.HELLO).to eq("world")
18
+ expect(env.FOO).to eq("bar")
19
+ end
20
+
21
+ it "makes ENV values accessible as mixed-case methods" do
22
+ expect(env.Hello).to eq("world")
23
+ expect(env.fOO).to eq("bar")
24
+ end
25
+
26
+ it "returns nil if no ENV key matches" do
27
+ expect(env.goodbye).to eq(nil)
28
+ end
29
+
30
+ it "respects a stubbed plain method" do
31
+ allow(env).to receive(:bar) { "baz" }
32
+ expect(env.bar).to eq("baz")
33
+ end
34
+ end
35
+
36
+ context "bang methods" do
37
+ it "makes ENV values accessible as lowercase methods" do
38
+ expect(env.hello!).to eq("world")
39
+ expect(env.foo!).to eq("bar")
40
+ end
41
+
42
+ it "makes ENV values accessible as uppercase methods" do
43
+ expect(env.HELLO!).to eq("world")
44
+ expect(env.FOO!).to eq("bar")
45
+ end
46
+
47
+ it "makes ENV values accessible as mixed-case methods" do
48
+ expect(env.Hello!).to eq("world")
49
+ expect(env.fOO!).to eq("bar")
50
+ end
51
+
52
+ it "raises an error if no ENV key matches" do
53
+ expect { env.goodbye! }.to raise_error(Figaro::MissingKey)
54
+ end
55
+
56
+ it "respects a stubbed plain method" do
57
+ allow(env).to receive(:bar) { "baz" }
58
+ expect { expect(env.bar!).to eq("baz") }.not_to raise_error
59
+ end
60
+ end
61
+
62
+ context "boolean methods" do
63
+ it "returns true for accessible, lowercase methods" do
64
+ expect(env.hello?).to eq(true)
65
+ expect(env.foo?).to eq(true)
66
+ end
67
+
68
+ it "returns true for accessible, uppercase methods" do
69
+ expect(env.HELLO?).to eq(true)
70
+ expect(env.FOO?).to eq(true)
71
+ end
72
+
73
+ it "returns true for accessible, mixed-case methods" do
74
+ expect(env.Hello?).to eq(true)
75
+ expect(env.fOO?).to eq(true)
76
+ end
77
+
78
+ it "returns false if no ENV key matches" do
79
+ expect(env.goodbye?).to eq(false)
80
+ end
81
+
82
+ it "respects a stubbed plain method" do
83
+ allow(env).to receive(:bar) { "baz" }
84
+ expect(env.bar?).to eq(true)
85
+ end
86
+ end
87
+
88
+ context "setter methods" do
89
+ it "raises an error for accessible, lowercase methods" do
90
+ expect { env.hello = "world" }.to raise_error(NoMethodError)
91
+ expect { env.foo = "bar" }.to raise_error(NoMethodError)
92
+ end
93
+
94
+ it "raises an error for accessible, uppercase methods" do
95
+ expect { env.HELLO = "world" }.to raise_error(NoMethodError)
96
+ expect { env.FOO = "bar" }.to raise_error(NoMethodError)
97
+ end
98
+
99
+ it "raises an error for accessible, mixed-case methods" do
100
+ expect { env.Hello = "world" }.to raise_error(NoMethodError)
101
+ expect { env.fOO = "bar" }.to raise_error(NoMethodError)
102
+ end
103
+
104
+ it "raises an error if no ENV key matches" do
105
+ expect { env.goodbye = "world" }.to raise_error(NoMethodError)
106
+ end
107
+ end
108
+ end
109
+
110
+ describe "#respond_to?" do
111
+ context "plain methods" do
112
+ it "returns true for accessible, lowercase methods" do
113
+ expect(env.respond_to?(:hello)).to eq(true)
114
+ expect(env.respond_to?(:foo)).to eq(true)
115
+ end
116
+
117
+ it "returns true for accessible uppercase methods" do
118
+ expect(env.respond_to?(:HELLO)).to eq(true)
119
+ expect(env.respond_to?(:FOO)).to eq(true)
120
+ end
121
+
122
+ it "returns true for accessible mixed-case methods" do
123
+ expect(env.respond_to?(:Hello)).to eq(true)
124
+ expect(env.respond_to?(:fOO)).to eq(true)
125
+ end
126
+
127
+ it "returns true if no ENV key matches" do
128
+ expect(env.respond_to?(:baz)).to eq(true)
129
+ end
130
+ end
131
+
132
+ context "bang methods" do
133
+ it "returns true for accessible, lowercase methods" do
134
+ expect(env.respond_to?(:hello!)).to eq(true)
135
+ expect(env.respond_to?(:foo!)).to eq(true)
136
+ end
137
+
138
+ it "returns true for accessible uppercase methods" do
139
+ expect(env.respond_to?(:HELLO!)).to eq(true)
140
+ expect(env.respond_to?(:FOO!)).to eq(true)
141
+ end
142
+
143
+ it "returns true for accessible mixed-case methods" do
144
+ expect(env.respond_to?(:Hello!)).to eq(true)
145
+ expect(env.respond_to?(:fOO!)).to eq(true)
146
+ end
147
+
148
+ it "returns false if no ENV key matches" do
149
+ expect(env.respond_to?(:baz!)).to eq(false)
150
+ end
151
+ end
152
+
153
+ context "boolean methods" do
154
+ it "returns true for accessible, lowercase methods" do
155
+ expect(env.respond_to?(:hello?)).to eq(true)
156
+ expect(env.respond_to?(:foo?)).to eq(true)
157
+ end
158
+
159
+ it "returns true for accessible uppercase methods" do
160
+ expect(env.respond_to?(:HELLO?)).to eq(true)
161
+ expect(env.respond_to?(:FOO?)).to eq(true)
162
+ end
163
+
164
+ it "returns true for accessible mixed-case methods" do
165
+ expect(env.respond_to?(:Hello?)).to eq(true)
166
+ expect(env.respond_to?(:fOO?)).to eq(true)
167
+ end
168
+
169
+ it "returns true if no ENV key matches" do
170
+ expect(env.respond_to?(:baz?)).to eq(true)
171
+ end
172
+ end
173
+
174
+ context "setter methods" do
175
+ it "returns false for accessible, lowercase methods" do
176
+ expect(env.respond_to?(:hello=)).to eq(false)
177
+ expect(env.respond_to?(:foo=)).to eq(false)
178
+ end
179
+
180
+ it "returns false for accessible uppercase methods" do
181
+ expect(env.respond_to?(:HELLO=)).to eq(false)
182
+ expect(env.respond_to?(:FOO=)).to eq(false)
183
+ end
184
+
185
+ it "returns false for accessible mixed-case methods" do
186
+ expect(env.respond_to?(:Hello=)).to eq(false)
187
+ expect(env.respond_to?(:fOO=)).to eq(false)
188
+ end
189
+
190
+ it "returns false if no ENV key matches" do
191
+ expect(env.respond_to?(:baz=)).to eq(false)
192
+ end
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,41 @@
1
+ module Figaro
2
+ module Rails
3
+ describe Application do
4
+ describe "#default_path" do
5
+ let!(:application) { Application.new }
6
+
7
+ it "defaults to config/application.yml in Rails.root" do
8
+ allow(::Rails).to receive(:root) { Pathname.new("/path/to/app") }
9
+
10
+ expect {
11
+ allow(::Rails).to receive(:root) { Pathname.new("/app") }
12
+ }.to change {
13
+ application.send(:default_path).to_s
14
+ }.from("/path/to/app/config/application.yml").to("/app/config/application.yml")
15
+ end
16
+
17
+ it "raises an error when Rails.root isn't set yet" do
18
+ allow(::Rails).to receive(:root) { nil }
19
+
20
+ expect {
21
+ application.send(:default_path)
22
+ }.to raise_error(RailsNotInitialized)
23
+ end
24
+ end
25
+
26
+ describe "#default_environment" do
27
+ let!(:application) { Application.new }
28
+
29
+ it "defaults to Rails.env" do
30
+ allow(::Rails).to receive(:env) { "development" }
31
+
32
+ expect {
33
+ allow(::Rails).to receive(:env) { "test" }
34
+ }.to change {
35
+ application.send(:default_environment).to_s
36
+ }.from("development").to("test")
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end