rs_yettings 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/README.md +186 -0
  2. data/Rakefile +38 -0
  3. data/lib/tasks/yettings.rake +17 -0
  4. data/lib/yettings.rb +79 -0
  5. data/lib/yettings/base.rb +41 -0
  6. data/lib/yettings/encryption.rb +124 -0
  7. data/lib/yettings/railtie.rb +15 -0
  8. data/lib/yettings/version.rb +3 -0
  9. data/spec/dummy/Guardfile +228 -0
  10. data/spec/dummy/README.rdoc +261 -0
  11. data/spec/dummy/Rakefile +7 -0
  12. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  13. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  15. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  16. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/spec/dummy/config.ru +4 -0
  18. data/spec/dummy/config/application.rb +59 -0
  19. data/spec/dummy/config/boot.rb +10 -0
  20. data/spec/dummy/config/database.yml +25 -0
  21. data/spec/dummy/config/environment.rb +5 -0
  22. data/spec/dummy/config/environments/development.rb +37 -0
  23. data/spec/dummy/config/environments/production.rb +67 -0
  24. data/spec/dummy/config/environments/test.rb +37 -0
  25. data/spec/dummy/config/ignored.yml +17 -0
  26. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/spec/dummy/config/initializers/inflections.rb +15 -0
  28. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  29. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  30. data/spec/dummy/config/initializers/session_store.rb +8 -0
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  32. data/spec/dummy/config/locales/en.yml +5 -0
  33. data/spec/dummy/config/routes.rb +58 -0
  34. data/spec/dummy/config/yetting.yml +17 -0
  35. data/spec/dummy/config/yetting.yml.pub +0 -0
  36. data/spec/dummy/config/yettings/blank.yml +0 -0
  37. data/spec/dummy/config/yettings/defaults.yml +6 -0
  38. data/spec/dummy/config/yettings/hendrix.yml +11 -0
  39. data/spec/dummy/config/yettings/jimi.yml +11 -0
  40. data/spec/dummy/config/yettings/secret.yml.pub +1 -0
  41. data/spec/dummy/db/test.sqlite3 +0 -0
  42. data/spec/dummy/log/development.log +1 -0
  43. data/spec/dummy/log/test.log +141 -0
  44. data/spec/dummy/public/404.html +26 -0
  45. data/spec/dummy/public/422.html +26 -0
  46. data/spec/dummy/public/500.html +25 -0
  47. data/spec/dummy/public/favicon.ico +0 -0
  48. data/spec/dummy/script/rails +6 -0
  49. data/spec/spec_helper.rb +28 -0
  50. data/spec/yettings/base_spec.rb +66 -0
  51. data/spec/yettings/encryption_spec.rb +104 -0
  52. data/spec/yettings_spec.rb +90 -0
  53. metadata +320 -0
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe Yettings do
4
+ YETTINGS_DIR = "#{Rails.root}/config/yettings"
5
+ YETTING_FILE = "#{Rails.root}/config/yetting.yml"
6
+ IGNORED_YETTING_FILE = "#{Rails.root}/config/ignored.yml"
7
+ BLANK_YETTING_FILE = "#{Rails.root}/config/yettings/blank.yml"
8
+
9
+ it "should load yettings in the rails app" do
10
+ assert defined?(Yettings)
11
+ end
12
+
13
+ describe ".setup!" do
14
+ it "sets setup public yettings classes" do
15
+ Yettings.setup!
16
+ assert defined?(BlankYetting)
17
+ assert defined?(JimiYetting)
18
+ assert defined?(HendrixYetting)
19
+ assert defined?(DefaultsYetting)
20
+ end
21
+
22
+ it "sets up private yetting classes" do
23
+ Yettings.setup!
24
+ assert defined?(SecretYetting)
25
+ end
26
+ end
27
+
28
+ describe ".create_yetting_class" do
29
+ it "creates a yetting class from a file" do
30
+ Yettings.create_yetting_class(IGNORED_YETTING_FILE)
31
+ assert defined?(IgnoredYetting)
32
+ end
33
+ end
34
+
35
+ describe ".klass_name" do
36
+ it "should return Yetting if file is base yetting" do
37
+ Yettings.klass_name(YETTING_FILE).should eq "Yetting"
38
+ end
39
+
40
+ it "should return SomeYetting" do
41
+ Yettings.klass_name("#{YETTINGS_DIR}/some.yml").should eq "SomeYetting"
42
+ end
43
+
44
+ it "should raise an error if the class is already defined" do
45
+ AlreadyDefinedConstantYetting = Class.new
46
+ expect { Yettings.klass_name 'already_defined_constant.yml' }.
47
+ to raise_error Yettings::NameConflictError
48
+ end
49
+
50
+ it "should not raise an error if the class is a descendant of Base" do
51
+ AnotherAlreadyDefinedConstantYetting = Class.new Yettings::Base
52
+ expect { Yettings.klass_name 'another_already_defined_constant.yml' }.
53
+ to_not raise_error
54
+ end
55
+ end
56
+
57
+ describe ".find_yml_files" do
58
+ it "finds only main yml file if no others exist" do
59
+ FileUtils.mv(YETTINGS_DIR,"#{YETTINGS_DIR}_tmp")
60
+ begin
61
+ Yettings.find_yml_files.should eq ["#{Rails.root}/config/yetting.yml"]
62
+ ensure
63
+ FileUtils.mv("#{YETTINGS_DIR}_tmp",YETTINGS_DIR)
64
+ end
65
+ end
66
+
67
+ it "finds main and 3 yettings dir files" do
68
+ Yettings.find_yml_files.should eq ["#{Rails.root}/config/yetting.yml",
69
+ "#{YETTINGS_DIR}/blank.yml",
70
+ "#{YETTINGS_DIR}/defaults.yml",
71
+ "#{YETTINGS_DIR}/hendrix.yml",
72
+ "#{YETTINGS_DIR}/jimi.yml",
73
+ "#{YETTINGS_DIR}/secret.yml.pub"]
74
+ end
75
+
76
+ it "finds 3 yettings dir files if there is no main file" do
77
+ FileUtils.mv("#{YETTING_FILE}","#{YETTING_FILE}_tmp")
78
+ begin
79
+ yml_files = Yettings.find_yml_files
80
+ yml_files.should eq ["#{YETTINGS_DIR}/blank.yml",
81
+ "#{YETTINGS_DIR}/defaults.yml",
82
+ "#{YETTINGS_DIR}/hendrix.yml",
83
+ "#{YETTINGS_DIR}/jimi.yml",
84
+ "#{YETTINGS_DIR}/secret.yml.pub"]
85
+ ensure
86
+ FileUtils.mv("#{YETTING_FILE}_tmp","#{YETTING_FILE}")
87
+ end
88
+ end
89
+ end
90
+ end
metadata ADDED
@@ -0,0 +1,320 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rs_yettings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mc-2
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-23 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: '0'
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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: encrypted_strings
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
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: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sqlite3
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard-rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-spork
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec-rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: factory_girl_rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: shoulda-matchers
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: growl
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: spork
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ description: ! 'Yettings uses encrypted YML files that allow you to safely store sensitive
191
+ configuration data such as API keys and passwords in your repository. Yettings
192
+ makes these key/values available by creating a class and instance methods. Ex:
193
+ Yetting.some_setting'
194
+ email:
195
+ - john.mcaliley@gmail.com
196
+ executables: []
197
+ extensions: []
198
+ extra_rdoc_files: []
199
+ files:
200
+ - lib/tasks/yettings.rake
201
+ - lib/yettings/base.rb
202
+ - lib/yettings/encryption.rb
203
+ - lib/yettings/railtie.rb
204
+ - lib/yettings/version.rb
205
+ - lib/yettings.rb
206
+ - Rakefile
207
+ - README.md
208
+ - spec/dummy/app/assets/javascripts/application.js
209
+ - spec/dummy/app/assets/stylesheets/application.css
210
+ - spec/dummy/app/controllers/application_controller.rb
211
+ - spec/dummy/app/helpers/application_helper.rb
212
+ - spec/dummy/app/views/layouts/application.html.erb
213
+ - spec/dummy/config/application.rb
214
+ - spec/dummy/config/boot.rb
215
+ - spec/dummy/config/database.yml
216
+ - spec/dummy/config/environment.rb
217
+ - spec/dummy/config/environments/development.rb
218
+ - spec/dummy/config/environments/production.rb
219
+ - spec/dummy/config/environments/test.rb
220
+ - spec/dummy/config/ignored.yml
221
+ - spec/dummy/config/initializers/backtrace_silencers.rb
222
+ - spec/dummy/config/initializers/inflections.rb
223
+ - spec/dummy/config/initializers/mime_types.rb
224
+ - spec/dummy/config/initializers/secret_token.rb
225
+ - spec/dummy/config/initializers/session_store.rb
226
+ - spec/dummy/config/initializers/wrap_parameters.rb
227
+ - spec/dummy/config/locales/en.yml
228
+ - spec/dummy/config/routes.rb
229
+ - spec/dummy/config/yetting.yml
230
+ - spec/dummy/config/yetting.yml.pub
231
+ - spec/dummy/config/yettings/blank.yml
232
+ - spec/dummy/config/yettings/defaults.yml
233
+ - spec/dummy/config/yettings/hendrix.yml
234
+ - spec/dummy/config/yettings/jimi.yml
235
+ - spec/dummy/config/yettings/secret.yml.pub
236
+ - spec/dummy/config.ru
237
+ - spec/dummy/db/test.sqlite3
238
+ - spec/dummy/Guardfile
239
+ - spec/dummy/log/development.log
240
+ - spec/dummy/log/test.log
241
+ - spec/dummy/public/404.html
242
+ - spec/dummy/public/422.html
243
+ - spec/dummy/public/500.html
244
+ - spec/dummy/public/favicon.ico
245
+ - spec/dummy/Rakefile
246
+ - spec/dummy/README.rdoc
247
+ - spec/dummy/script/rails
248
+ - spec/spec_helper.rb
249
+ - spec/yettings/base_spec.rb
250
+ - spec/yettings/encryption_spec.rb
251
+ - spec/yettings_spec.rb
252
+ homepage:
253
+ licenses: []
254
+ post_install_message:
255
+ rdoc_options: []
256
+ require_paths:
257
+ - lib
258
+ required_ruby_version: !ruby/object:Gem::Requirement
259
+ none: false
260
+ requirements:
261
+ - - ! '>='
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ requirements: []
271
+ rubyforge_project:
272
+ rubygems_version: 1.8.25
273
+ signing_key:
274
+ specification_version: 3
275
+ summary: encrypted YAML settings/constants for your rails app
276
+ test_files:
277
+ - spec/dummy/app/assets/javascripts/application.js
278
+ - spec/dummy/app/assets/stylesheets/application.css
279
+ - spec/dummy/app/controllers/application_controller.rb
280
+ - spec/dummy/app/helpers/application_helper.rb
281
+ - spec/dummy/app/views/layouts/application.html.erb
282
+ - spec/dummy/config/application.rb
283
+ - spec/dummy/config/boot.rb
284
+ - spec/dummy/config/database.yml
285
+ - spec/dummy/config/environment.rb
286
+ - spec/dummy/config/environments/development.rb
287
+ - spec/dummy/config/environments/production.rb
288
+ - spec/dummy/config/environments/test.rb
289
+ - spec/dummy/config/ignored.yml
290
+ - spec/dummy/config/initializers/backtrace_silencers.rb
291
+ - spec/dummy/config/initializers/inflections.rb
292
+ - spec/dummy/config/initializers/mime_types.rb
293
+ - spec/dummy/config/initializers/secret_token.rb
294
+ - spec/dummy/config/initializers/session_store.rb
295
+ - spec/dummy/config/initializers/wrap_parameters.rb
296
+ - spec/dummy/config/locales/en.yml
297
+ - spec/dummy/config/routes.rb
298
+ - spec/dummy/config/yetting.yml
299
+ - spec/dummy/config/yetting.yml.pub
300
+ - spec/dummy/config/yettings/blank.yml
301
+ - spec/dummy/config/yettings/defaults.yml
302
+ - spec/dummy/config/yettings/hendrix.yml
303
+ - spec/dummy/config/yettings/jimi.yml
304
+ - spec/dummy/config/yettings/secret.yml.pub
305
+ - spec/dummy/config.ru
306
+ - spec/dummy/db/test.sqlite3
307
+ - spec/dummy/Guardfile
308
+ - spec/dummy/log/development.log
309
+ - spec/dummy/log/test.log
310
+ - spec/dummy/public/404.html
311
+ - spec/dummy/public/422.html
312
+ - spec/dummy/public/500.html
313
+ - spec/dummy/public/favicon.ico
314
+ - spec/dummy/Rakefile
315
+ - spec/dummy/README.rdoc
316
+ - spec/dummy/script/rails
317
+ - spec/spec_helper.rb
318
+ - spec/yettings/base_spec.rb
319
+ - spec/yettings/encryption_spec.rb
320
+ - spec/yettings_spec.rb