setting_accessors 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e10e1f1db74ffd1a88c6cda07070ee743347be2
4
- data.tar.gz: bb11685605adb3eb565543d9282b76c133609529
3
+ metadata.gz: 6ba51cce908ff75943938e86e01d1aed48b0ccf6
4
+ data.tar.gz: 7d164c7545cb6adfa0741b8dabf3b4a7bfae5a74
5
5
  SHA512:
6
- metadata.gz: 4cf233138c9ea194ce51cf154a136030ef7d835fa089f968d2ba6ffdd47b33b191357496e6627a3f56b3d4d9713e678b922d34e6843249f92f859d5c12c9b1c2
7
- data.tar.gz: df955321287251309b6a5f2ef6dd24e0701b3218423eb365dbf5e5156e4cea031526fa6ce3b5478b9b69dda030f9067807331d34888dcce2363cacf34a8c0c90
6
+ metadata.gz: ee4917d83045b732589124c938999204b8458859707119faa78d7c2aa3626d4f0949d1cf34afc4d994dda2f4740ceefe4679ff2aec004e7f0382bc2a1c6f1cf7
7
+ data.tar.gz: 3feb815f194119f2817314c3b6b01880083132eae3972dff75b9ae38c821ae1ee9a4bf105d5105294af7b84ad6c901508a0804f132e5562b0e7a46779bd0ac1f
data/.gitignore CHANGED
@@ -21,8 +21,8 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
 
24
- #Rubymine
25
- .idea
24
+ # RVM
25
+ .ruby-version
26
26
 
27
27
  #Dummy Application
28
28
  test/dummy/log
data/.travis.yml CHANGED
@@ -5,6 +5,9 @@ rvm:
5
5
  - 2.2
6
6
  - 2.3.1
7
7
 
8
+ env:
9
+ - DISABLE_DATABASE_ENVIRONMENT_CHECK=1
10
+
8
11
  before_install: 'gem install bundler'
9
12
  script: 'bundle exec rake'
10
13
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0
4
+
5
+ * Fixed a bug that caused setting accessors not being initialized when being called as part of a rake task chain (#6)
@@ -36,20 +36,11 @@ module SettingAccessors::Integration
36
36
  # setting and return +nil+ if none was specified previously.
37
37
  #
38
38
  def setting_accessor(setting_name, options = {})
39
- #If the database table does not yet exist,
40
- return unless self.table_exists?
41
-
42
39
  fallback = options.delete(:fallback)
43
40
 
44
41
  SettingAccessors::Internal.set_class_setting(self, setting_name, options)
45
42
 
46
- setting_type = SettingAccessors::Internal.setting_value_type(setting_name, self.new).to_sym
47
-
48
- #Create a virtual column in the models column hash.
49
- #This is currently not absolutely necessary, but will become important once
50
- #Time etc. are supported. Otherwise, Rails won't be able to e.g. automatically
51
- #create multi-param fields in forms.
52
- self.columns_hash[setting_name.to_s] = OpenStruct.new(type: setting_type)
43
+ setting_type = SettingAccessors::Internal.setting_value_type(setting_name, self).to_sym
53
44
 
54
45
  #Add the setting's name to the list of setting_accessors for this class
55
46
  SettingAccessors::Internal.add_setting_accessor_name(self, setting_name)
@@ -76,8 +76,12 @@ module SettingAccessors
76
76
  # - If it's a setting defined in a setting_accessor call, the information is taken from this call
77
77
  # - Otherwise, an empty hash is returned
78
78
  #
79
- def self.setting_data(setting_name, assignable = nil)
80
- (assignable && self.get_class_setting(assignable.class, setting_name)) ||
79
+ def self.setting_data(setting_name, assignable_class = nil)
80
+ # As a convenience function (and to keep the existing code working),
81
+ # it is possible to provide a class or an instance of said class
82
+ assignable_class &&= assignable_class.class unless assignable_class.is_a?(Class)
83
+
84
+ (assignable_class && self.get_class_setting(assignable_class, setting_name)) ||
81
85
  self.global_config[setting_name.to_s] ||
82
86
  {}
83
87
  end
@@ -1,3 +1,3 @@
1
1
  module SettingAccessors
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
Binary file
data/test/test_helper.rb CHANGED
@@ -18,6 +18,14 @@ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
18
18
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
19
19
  end
20
20
 
21
+ # configure shoulda matchers
22
+ Shoulda::Matchers.configure do |config|
23
+ config.integrate do |with|
24
+ with.test_framework :minitest
25
+ with.library :rails
26
+ end
27
+ end
28
+
21
29
  # For generators
22
30
  require "rails/generators/test_case"
23
31
  require "generators/setting_accessors/install_generator"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: setting_accessors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Exner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-13 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -126,6 +126,7 @@ files:
126
126
  - ".codeclimate.yml"
127
127
  - ".gitignore"
128
128
  - ".travis.yml"
129
+ - CHANGELOG.md
129
130
  - Gemfile
130
131
  - LICENSE.txt
131
132
  - README.md
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  version: '0'
225
226
  requirements: []
226
227
  rubyforge_project:
227
- rubygems_version: 2.6.9
228
+ rubygems_version: 2.6.14
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: A global key-value-store and virtual model columns