rails_admin_settings 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ rails_admin_settings
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p392
@@ -18,6 +18,7 @@ module RailsAdminSettings
18
18
 
19
19
  field :key, type: String
20
20
  field :raw, type: String, default: ''
21
+ field :label
21
22
 
22
23
  include RailsAdminSettings::RequireHelpers
23
24
  include RailsAdminSettings::Processing
@@ -33,6 +34,10 @@ module RailsAdminSettings
33
34
  enabled
34
35
  end
35
36
 
37
+ before_save do
38
+ self.label = self.key unless self.label.present?
39
+ end
40
+
36
41
  index(key: 1)
37
42
 
38
43
  if Object.const_defined?('RailsAdmin')
@@ -41,4 +46,4 @@ module RailsAdminSettings
41
46
  puts "[rails_admin_settings] Rails Admin not detected -- put this gem after rails_admin in gemfile"
42
47
  end
43
48
  end
44
- end
49
+ end
@@ -13,7 +13,8 @@ ru:
13
13
 
14
14
  attributes:
15
15
  rails_admin_settings/setting:
16
- key: Название
16
+ label: Название
17
+ key: Ключ
17
18
  raw: Значение
18
19
  type: Тип
19
20
 
@@ -6,7 +6,7 @@ module RailsAdminSettings
6
6
  navigation_label I18n.t('admin.settings.label')
7
7
 
8
8
  object_label_method do
9
- :key
9
+ :label
10
10
  end
11
11
 
12
12
  list do
@@ -15,14 +15,14 @@ module RailsAdminSettings
15
15
  else
16
16
  field :enabled
17
17
  end
18
- field :key
18
+ field :label
19
19
  field :raw
20
20
  field :type
21
21
  end
22
22
 
23
23
  edit do
24
24
  field :enabled
25
- field :key do
25
+ field :label do
26
26
  read_only true
27
27
  help false
28
28
  end
@@ -168,5 +168,9 @@ class Settings
168
168
  end
169
169
  @@settings[key]
170
170
  end
171
+
172
+ def label key
173
+ get(key).label
174
+ end
171
175
  end
172
- end
176
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSettings
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "mongoid", '~> 3.1'
21
+ spec.add_runtime_dependency "mongoid", ">= 3.1"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake", "~> 10.0.3"
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Settings label' do
6
+
7
+ it "should have label" do
8
+ label = "E-Mail"
9
+ Settings.email(label: label, default: "my@mail.ru")
10
+ Settings.label(:email).should == label
11
+ end
12
+
13
+ it "should properly set label as key if blank" do
14
+ Settings.email(default: "my@mail.ru")
15
+ Settings.label(:email).should == 'email'
16
+ end
17
+
18
+ end
@@ -56,4 +56,5 @@ describe Settings do
56
56
  Settings.enabled?(:phone, type: 'phone').should eq true
57
57
  Settings.get(:phone).type.should eq 'phone'
58
58
  end
59
+
59
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.1'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.1'
30
30
  - !ruby/object:Gem::Dependency
@@ -244,7 +244,8 @@ extra_rdoc_files: []
244
244
  files:
245
245
  - .gitignore
246
246
  - .rspec
247
- - .rvmrc
247
+ - .ruby-gemset
248
+ - .ruby-version
248
249
  - .travis.yml
249
250
  - Gemfile
250
251
  - LICENSE.txt
@@ -270,6 +271,7 @@ files:
270
271
  - spec/advanced_usage_spec.rb
271
272
  - spec/database_trickery_spec.rb
272
273
  - spec/factories/setting.rb
274
+ - spec/label_spec.rb
273
275
  - spec/model_spec.rb
274
276
  - spec/settings_spec.rb
275
277
  - spec/spec_helper.rb
@@ -292,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
294
  version: '0'
293
295
  segments:
294
296
  - 0
295
- hash: -1867951047541267235
297
+ hash: 1108480110300401227
296
298
  required_rubygems_version: !ruby/object:Gem::Requirement
297
299
  none: false
298
300
  requirements:
@@ -301,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
303
  version: '0'
302
304
  segments:
303
305
  - 0
304
- hash: -1867951047541267235
306
+ hash: 1108480110300401227
305
307
  requirements: []
306
308
  rubyforge_project:
307
309
  rubygems_version: 1.8.25
@@ -312,6 +314,7 @@ test_files:
312
314
  - spec/advanced_usage_spec.rb
313
315
  - spec/database_trickery_spec.rb
314
316
  - spec/factories/setting.rb
317
+ - spec/label_spec.rb
315
318
  - spec/model_spec.rb
316
319
  - spec/settings_spec.rb
317
320
  - spec/spec_helper.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3-p392@rails_admin_settings --create