rails_admin_settings 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +2 -1
  4. data/CHANGELOG.md +11 -0
  5. data/app/models/rails_admin_settings/setting.rb +27 -5
  6. data/app/views/rails_admin/main/_setting_value.html.haml +1 -1
  7. data/config/locales/{en.rails_admin_settings.yml → en.yml} +0 -0
  8. data/config/locales/{ru.rails_admin_settings.yml → ru.yml} +20 -20
  9. data/lib/rails_admin_settings/dumper.rb +12 -0
  10. data/lib/rails_admin_settings/engine.rb +3 -0
  11. data/lib/rails_admin_settings/fallback.rb +19 -0
  12. data/lib/rails_admin_settings/hex_color_validator.rb +1 -1
  13. data/lib/rails_admin_settings/namespaced.rb +201 -0
  14. data/lib/rails_admin_settings/rails_admin_config.rb +3 -6
  15. data/lib/rails_admin_settings/railtie.rb +7 -0
  16. data/lib/rails_admin_settings/settings.rb +63 -165
  17. data/lib/rails_admin_settings/tasks.rb +25 -0
  18. data/lib/rails_admin_settings/types.rb +15 -1
  19. data/lib/rails_admin_settings/validation.rb +2 -4
  20. data/lib/rails_admin_settings/version.rb +1 -1
  21. data/lib/rails_admin_settings.rb +4 -0
  22. data/rails_admin_settings.gemspec +8 -7
  23. data/spec/carrierwave_spec.rb +7 -2
  24. data/spec/database_trickery_spec.rb +5 -7
  25. data/spec/defaults_spec.rb +53 -0
  26. data/spec/enabling_spec.rb +29 -0
  27. data/spec/label_spec.rb +2 -2
  28. data/spec/namespaced_spec.rb +41 -0
  29. data/spec/paperclip_spec.rb +5 -0
  30. data/spec/settings_spec.rb +13 -4
  31. data/spec/spec_helper.rb +4 -0
  32. data/spec/support/defaults.yml +15 -0
  33. data/spec/support/defaults_w_file.yml +19 -0
  34. data/spec/support/mongoid.yml +1 -1
  35. data/spec/types_spec.rb +12 -9
  36. metadata +49 -19
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ require 'rubygems'
5
5
  require 'simplecov'
6
6
  SimpleCov.start
7
7
 
8
+ require 'pry'
8
9
  require 'bundler/setup'
9
10
  require 'active_support/core_ext'
10
11
  require 'mongoid'
@@ -22,6 +23,9 @@ if ENV['UPLOADS'] == 'carrierwave'
22
23
  end
23
24
  end
24
25
 
26
+ I18n.enforce_available_locales = true
27
+ I18n.load_path << File.join(File.dirname(__FILE__), "..", "config", "locales", "en.yml")
28
+
25
29
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
26
30
  require f
27
31
  end
@@ -0,0 +1,15 @@
1
+ main:
2
+ footer:
3
+ type: html
4
+ value: 'test <b></b>'
5
+
6
+ phone:
7
+ type: 'phone'
8
+ value: '906 1111111'
9
+
10
+ disabled:
11
+ enabled: false
12
+
13
+ other:
14
+ footer:
15
+ value: 'zzz'
@@ -0,0 +1,19 @@
1
+ main:
2
+ footer:
3
+ type: html
4
+ value: 'test <b></b>'
5
+
6
+ phone:
7
+ type: 'phone'
8
+ value: '906 1111111'
9
+
10
+ disabled:
11
+ enabled: false
12
+
13
+ other:
14
+ footer:
15
+ value: 'zzz'
16
+
17
+ img:
18
+ type: 'image'
19
+ value: 'spec/support/1024x768.gif'
@@ -1,7 +1,7 @@
1
1
  test:
2
2
  sessions:
3
3
  default:
4
- database: mongoid-history
4
+ database: rails_admin_settings
5
5
  hosts:
6
6
  - localhost:27017
7
7
  options:
data/spec/types_spec.rb CHANGED
@@ -2,25 +2,25 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'Settings advanced usage' do
6
- it 'support html type' do
5
+ describe 'Settings types' do
6
+ it 'html' do
7
7
  Settings.get(:email, type: 'html', default: 'test@example.com').to_s.should eq 'test@example.com'
8
8
  end
9
9
 
10
- it 'support integer type' do
10
+ it 'integer' do
11
11
  Settings.get(:testint, type: 'integer').value.should eq 0
12
12
  Settings.get(:testint, default: 5, type: 'integer').value.should eq 0
13
13
  Settings.get(:testint2, default: 5, type: 'integer').value.should eq 5
14
14
  Settings.testint2.should eq 5
15
15
  end
16
16
 
17
- it 'supports yaml type' do
17
+ it 'yaml' do
18
18
  Settings.set(:data, '[one, two, three]', type: 'yaml')
19
19
  Settings.get(:data).raw.should eq '[one, two, three]'
20
20
  Settings.data.should eq ['one', 'two', 'three']
21
21
  end
22
22
 
23
- it 'supports phone type' do
23
+ it 'phone' do
24
24
  Settings.set(:tphone, '906 111 11 11', type: 'phone')
25
25
  Settings.get(:tphone).val.class.name.should eq 'RussianPhone::Number'
26
26
  Settings.tphone.class.name.should eq 'RussianPhone::Number'
@@ -30,14 +30,14 @@ describe 'Settings advanced usage' do
30
30
  Settings.get(:tphone).val.formatted_subscriber.should eq '111-11-11'
31
31
  end
32
32
 
33
- it 'sets defaults for phone type' do
33
+ it 'defaults for phone' do
34
34
  Settings.dphone(type: 'phone')
35
35
  Settings.get(:dphone).phone_type?.should be_true
36
36
  Settings.dphone.formatted_area.should eq ''
37
37
  Settings.dphone.formatted_subscriber.should eq ''
38
38
  end
39
39
 
40
- it 'validates emails with email type' do
40
+ it 'email validates' do
41
41
  Settings.eml(type: 'email')
42
42
  Settings.get(:eml).email_type?.should be_true
43
43
  expect { Settings.eml = '1' }.to raise_error
@@ -45,7 +45,7 @@ describe 'Settings advanced usage' do
45
45
  Settings.eml.should eq 'test@example.com'
46
46
  end
47
47
 
48
- it 'processes urls with url type' do
48
+ it 'url processing' do
49
49
  Settings.url(type: 'url')
50
50
  Settings.get(:url).url_type?.should be_true
51
51
  Settings.get(:url).color_type?.should be_false
@@ -53,11 +53,14 @@ describe 'Settings advanced usage' do
53
53
  Settings.url.should eq 'http://test.ru'
54
54
  end
55
55
 
56
- it 'supports color type' do
56
+ it 'color' do
57
57
  Settings.col(type: 'color')
58
58
  Settings.get(:col).color_type?.should be_true
59
59
  expect { Settings.col = 'test'}.to raise_error
60
60
  Settings.col = 'ffffff'
61
61
  Settings.col.should eq 'ffffff'
62
+ expect {
63
+ Settings.col = 'zzzzzz'
64
+ }.to raise_error
62
65
  end
63
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -44,98 +44,98 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 10.0.3
47
+ version: 10.1.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 10.0.3
54
+ version: 10.1.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 2.13.0
61
+ version: 2.14.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 2.13.0
68
+ version: 2.14.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mongoid-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 1.7.0
75
+ version: 1.10.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 1.7.0
82
+ version: 1.10.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: 0.7.1
89
+ version: 0.8.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 0.7.1
96
+ version: 0.8.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: database_cleaner
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: 0.9.1
103
+ version: 1.2.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: 0.9.1
110
+ version: 1.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: factory_girl
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 4.2.0
117
+ version: 4.3.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: 4.2.0
124
+ version: 4.3.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: safe_yaml
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: 0.8.6
131
+ version: 1.0.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
- version: 0.8.6
138
+ version: 1.0.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: russian_phone
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - '>='
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: pry
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - '>='
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
237
251
  description: Mongoid / RailsAdmin App Settings management
238
252
  email:
239
253
  - glebtv@gmail.com
@@ -246,24 +260,30 @@ files:
246
260
  - .ruby-gemset
247
261
  - .ruby-version
248
262
  - .travis.yml
263
+ - CHANGELOG.md
249
264
  - Gemfile
250
265
  - LICENSE.txt
251
266
  - README.md
252
267
  - Rakefile
253
268
  - app/models/rails_admin_settings/setting.rb
254
269
  - app/views/rails_admin/main/_setting_value.html.haml
255
- - config/locales/en.rails_admin_settings.yml
256
- - config/locales/ru.rails_admin_settings.yml
270
+ - config/locales/en.yml
271
+ - config/locales/ru.yml
257
272
  - gemfiles/mongoid-3.1.gemfile
258
273
  - gemfiles/mongoid-4.0.gemfile
259
274
  - lib/rails_admin_settings.rb
275
+ - lib/rails_admin_settings/dumper.rb
260
276
  - lib/rails_admin_settings/engine.rb
277
+ - lib/rails_admin_settings/fallback.rb
261
278
  - lib/rails_admin_settings/hex_color_validator.rb
279
+ - lib/rails_admin_settings/namespaced.rb
262
280
  - lib/rails_admin_settings/processing.rb
263
281
  - lib/rails_admin_settings/rails_admin_config.rb
282
+ - lib/rails_admin_settings/railtie.rb
264
283
  - lib/rails_admin_settings/require_helpers.rb
265
284
  - lib/rails_admin_settings/settings.rb
266
285
  - lib/rails_admin_settings/storage/carrierwave.rb
286
+ - lib/rails_admin_settings/tasks.rb
267
287
  - lib/rails_admin_settings/types.rb
268
288
  - lib/rails_admin_settings/uploads.rb
269
289
  - lib/rails_admin_settings/validation.rb
@@ -272,14 +292,19 @@ files:
272
292
  - spec/advanced_usage_spec.rb
273
293
  - spec/carrierwave_spec.rb
274
294
  - spec/database_trickery_spec.rb
295
+ - spec/defaults_spec.rb
296
+ - spec/enabling_spec.rb
275
297
  - spec/factories/setting.rb
276
298
  - spec/label_spec.rb
277
299
  - spec/model_spec.rb
300
+ - spec/namespaced_spec.rb
278
301
  - spec/paperclip_spec.rb
279
302
  - spec/settings_spec.rb
280
303
  - spec/spec_helper.rb
281
304
  - spec/support/1024x768.gif
282
305
  - spec/support/database_cleaner.rb
306
+ - spec/support/defaults.yml
307
+ - spec/support/defaults_w_file.yml
283
308
  - spec/support/mongoid.rb
284
309
  - spec/support/mongoid.yml
285
310
  - spec/types_spec.rb
@@ -303,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
328
  version: '0'
304
329
  requirements: []
305
330
  rubyforge_project:
306
- rubygems_version: 2.1.10
331
+ rubygems_version: 2.1.11
307
332
  signing_key:
308
333
  specification_version: 4
309
334
  summary: Setting for Rails app with mongoid and RailsAdmin
@@ -311,14 +336,19 @@ test_files:
311
336
  - spec/advanced_usage_spec.rb
312
337
  - spec/carrierwave_spec.rb
313
338
  - spec/database_trickery_spec.rb
339
+ - spec/defaults_spec.rb
340
+ - spec/enabling_spec.rb
314
341
  - spec/factories/setting.rb
315
342
  - spec/label_spec.rb
316
343
  - spec/model_spec.rb
344
+ - spec/namespaced_spec.rb
317
345
  - spec/paperclip_spec.rb
318
346
  - spec/settings_spec.rb
319
347
  - spec/spec_helper.rb
320
348
  - spec/support/1024x768.gif
321
349
  - spec/support/database_cleaner.rb
350
+ - spec/support/defaults.yml
351
+ - spec/support/defaults_w_file.yml
322
352
  - spec/support/mongoid.rb
323
353
  - spec/support/mongoid.yml
324
354
  - spec/types_spec.rb