mongoid-preferences 0.0.1 → 0.0.2
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.
- data/{CHANGELOG.rdoc → CHANGELOG} +0 -0
- data/README.md +1 -0
- data/lib/{mongoid → mongoid-preferences}/preferences/preferenceable.rb +3 -2
- data/lib/{mongoid → mongoid-preferences}/preferences/version.rb +1 -1
- data/lib/mongoid-preferences/preferences.rb +18 -0
- data/lib/mongoid-preferences.rb +1 -1
- data/mongoid-preferences.gemspec +2 -2
- data/spec/models_preferences/{dummy/default_preferences.yml → dummy.yml} +0 -0
- data/spec/mongoid-preferences_spec.rb +1 -2
- metadata +10 -10
- data/lib/mongoid/preferences.rb +0 -21
File without changes
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](http://badge.fury.io/rb/mongoid-preferences)
|
1
2
|
[](https://travis-ci.org/matito/mongoid-preferences)
|
2
3
|
[](https://codeclimate.com/github/matito/mongoid-preferences)
|
3
4
|
[](https://coveralls.io/r/matito/mongoid-preferences)
|
@@ -11,7 +11,7 @@ module Mongoid
|
|
11
11
|
|
12
12
|
# Returns all the preferences
|
13
13
|
def preferences
|
14
|
-
@
|
14
|
+
@_prefs ||= merged_preferences
|
15
15
|
end
|
16
16
|
|
17
17
|
# Returns the value of preference or nil if the preference is not found
|
@@ -62,7 +62,8 @@ module Mongoid
|
|
62
62
|
def default_preferences
|
63
63
|
return self.class.class_variable_get :@@default_preferences if self.class.class_variable_defined? :@@default_preferences
|
64
64
|
|
65
|
-
default_preferences_path = File.join(Preferences.model_preferences_path, "#{self.class.name.downcase}
|
65
|
+
default_preferences_path = File.join(Preferences.model_preferences_path, "#{self.class.name.downcase}.yml")
|
66
|
+
|
66
67
|
if File.exist?(default_preferences_path)
|
67
68
|
self.class.class_variable_set :@@default_preferences, HashWithIndifferentAccess.new(YAML.load_file(default_preferences_path)) # for access with symbols
|
68
69
|
else
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mongoid-preferences/preferences/preferenceable'
|
2
|
+
require 'mongoid-preferences/preferences/version'
|
3
|
+
|
4
|
+
module Mongoid
|
5
|
+
module Preferences
|
6
|
+
include ActiveSupport::Configurable
|
7
|
+
config_accessor :model_preferences_path
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
###
|
12
|
+
# Use this code into an initializer for configure the path of preferences yaml
|
13
|
+
##
|
14
|
+
|
15
|
+
#Mongoid::Preferences.configure do |config|
|
16
|
+
# # set default preferences path
|
17
|
+
# config.model_preferences_path = Rails.root.join('app','models_preferences')
|
18
|
+
#end
|
data/lib/mongoid-preferences.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'mongoid/preferences'
|
1
|
+
require 'mongoid-preferences/preferences'
|
data/mongoid-preferences.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/mongoid/preferences/version', __FILE__)
|
2
|
+
require File.expand_path('../lib/mongoid-preferences/preferences/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Mattia Toso"]
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency('rake', '~> 10.0')
|
21
21
|
gem.add_development_dependency('rspec', '~> 2.12')
|
22
22
|
gem.add_development_dependency('yard', '~> 0.8')
|
23
|
-
gem.add_development_dependency('mongoid-rspec', '~> 1.
|
23
|
+
gem.add_development_dependency('mongoid-rspec', '~> 1.4.4')
|
24
24
|
gem.add_development_dependency('database_cleaner', '~> 1.0')
|
25
25
|
gem.add_development_dependency('redcarpet', '~> 2.2')
|
26
26
|
gem.add_development_dependency('json', '~> 1.7.7')
|
File without changes
|
@@ -5,8 +5,7 @@ describe Mongoid::Preferences::Preferenceable do
|
|
5
5
|
let(:file_default_preferences_hash) {
|
6
6
|
HashWithIndifferentAccess.new( YAML.load_file(File.join(File.dirname(__FILE__),
|
7
7
|
'models_preferences',
|
8
|
-
'dummy'
|
9
|
-
'default_preferences.yml')))
|
8
|
+
'dummy.yml')))
|
10
9
|
}
|
11
10
|
|
12
11
|
let(:view_preferences_hash) { file_default_preferences_hash[:view][:preferences] }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-preferences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 1.4.4
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 1.4.4
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: database_cleaner
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,18 +149,18 @@ files:
|
|
149
149
|
- .gitignore
|
150
150
|
- .rspec
|
151
151
|
- .travis.yml
|
152
|
-
- CHANGELOG
|
152
|
+
- CHANGELOG
|
153
153
|
- Gemfile
|
154
154
|
- LICENSE
|
155
155
|
- README.md
|
156
156
|
- Rakefile
|
157
157
|
- lib/mongoid-preferences.rb
|
158
|
-
- lib/mongoid/preferences.rb
|
159
|
-
- lib/mongoid/preferences/preferenceable.rb
|
160
|
-
- lib/mongoid/preferences/version.rb
|
158
|
+
- lib/mongoid-preferences/preferences.rb
|
159
|
+
- lib/mongoid-preferences/preferences/preferenceable.rb
|
160
|
+
- lib/mongoid-preferences/preferences/version.rb
|
161
161
|
- mongoid-preferences.gemspec
|
162
162
|
- spec/models/dummy.rb
|
163
|
-
- spec/models_preferences/dummy
|
163
|
+
- spec/models_preferences/dummy.yml
|
164
164
|
- spec/mongoid-preferences_spec.rb
|
165
165
|
- spec/spec_helper.rb
|
166
166
|
homepage: https://github.com/matito/mongoid-preferences.git
|
@@ -189,7 +189,7 @@ specification_version: 3
|
|
189
189
|
summary: Add preferences hash to Mongoid model
|
190
190
|
test_files:
|
191
191
|
- spec/models/dummy.rb
|
192
|
-
- spec/models_preferences/dummy
|
192
|
+
- spec/models_preferences/dummy.yml
|
193
193
|
- spec/mongoid-preferences_spec.rb
|
194
194
|
- spec/spec_helper.rb
|
195
195
|
has_rdoc:
|
data/lib/mongoid/preferences.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Mongoid
|
2
|
-
module Preferences
|
3
|
-
|
4
|
-
require 'mongoid/preferences/preferenceable'
|
5
|
-
require 'mongoid/preferences/version'
|
6
|
-
|
7
|
-
include ActiveSupport::Configurable
|
8
|
-
|
9
|
-
config_accessor :model_preferences_path do
|
10
|
-
# default model preferences path
|
11
|
-
Rails.root.join('app','models_preferences')
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
#Mongoid::Preferences.configure do |config|
|
16
|
-
# # set default preferences path
|
17
|
-
# config.model_preferences_path = Rails.root.join('app','models_preferences')
|
18
|
-
#end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|