active_hash_fields 0.1.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 +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +85 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +48 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/active_hash_fields.gemspec +70 -0
- data/db/database.yml +4 -0
- data/db/migrations/1_create_dummy.rb +9 -0
- data/db/schema.rb +19 -0
- data/db/test.sqlite3 +0 -0
- data/lib/active_hash_fields.rb +88 -0
- data/spec/lib/active_hash_fields_spec.rb +47 -0
- data/spec/spec_helper.rb +18 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 69fa18f40e4f324b1357b1461e45b135258e383a
|
4
|
+
data.tar.gz: a052a4c6c1f55bd403452aa7579fc82d73d08e36
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f0ea59e94bac76a890c5e21160e8f1e351f6bc51b586049c3e82775068891c26eb77083c05d264a8c796af53c0d2efa1682a533dbf139982579ea19baa1d11d
|
7
|
+
data.tar.gz: 221f1b3be52508a91ea4aa5d7df389cb1bab8c0afbad4ba9a064f869c2180c43edb0cbb689480219b4f1dbab07c30d2419cfa8fa6e350aeda2a4ee5aae857ec5
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/technicalpickles/jeweler
|
3
|
+
revision: f7e0a55a207d83f56637dd8fbabf26a803410faf
|
4
|
+
specs:
|
5
|
+
jeweler (1.8.7)
|
6
|
+
builder
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
github_api (= 0.10.1)
|
10
|
+
highline (>= 1.6.15)
|
11
|
+
nokogiri (= 1.5.10)
|
12
|
+
rake
|
13
|
+
rdoc
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: http://rubygems.org/
|
17
|
+
specs:
|
18
|
+
activemodel (3.2.14)
|
19
|
+
activesupport (= 3.2.14)
|
20
|
+
builder (~> 3.0.0)
|
21
|
+
activerecord (3.2.14)
|
22
|
+
activemodel (= 3.2.14)
|
23
|
+
activesupport (= 3.2.14)
|
24
|
+
arel (~> 3.0.2)
|
25
|
+
tzinfo (~> 0.3.29)
|
26
|
+
activesupport (3.2.14)
|
27
|
+
i18n (~> 0.6, >= 0.6.4)
|
28
|
+
multi_json (~> 1.0)
|
29
|
+
addressable (2.3.5)
|
30
|
+
arel (3.0.2)
|
31
|
+
builder (3.0.4)
|
32
|
+
diff-lcs (1.2.4)
|
33
|
+
faraday (0.8.8)
|
34
|
+
multipart-post (~> 1.2.0)
|
35
|
+
git (1.2.6)
|
36
|
+
github_api (0.10.1)
|
37
|
+
addressable
|
38
|
+
faraday (~> 0.8.1)
|
39
|
+
hashie (>= 1.2)
|
40
|
+
multi_json (~> 1.4)
|
41
|
+
nokogiri (~> 1.5.2)
|
42
|
+
oauth2
|
43
|
+
hashie (2.0.5)
|
44
|
+
highline (1.6.19)
|
45
|
+
httpauth (0.2.0)
|
46
|
+
i18n (0.6.5)
|
47
|
+
json (1.8.0)
|
48
|
+
jwt (0.1.8)
|
49
|
+
multi_json (>= 1.5)
|
50
|
+
multi_json (1.8.0)
|
51
|
+
multi_xml (0.5.5)
|
52
|
+
multipart-post (1.2.0)
|
53
|
+
nokogiri (1.5.10)
|
54
|
+
oauth2 (0.9.2)
|
55
|
+
faraday (~> 0.8)
|
56
|
+
httpauth (~> 0.2)
|
57
|
+
jwt (~> 0.1.4)
|
58
|
+
multi_json (~> 1.0)
|
59
|
+
multi_xml (~> 0.5)
|
60
|
+
rack (~> 1.2)
|
61
|
+
rack (1.5.2)
|
62
|
+
rake (10.1.0)
|
63
|
+
rdoc (3.12.2)
|
64
|
+
json (~> 1.4)
|
65
|
+
rspec (2.14.1)
|
66
|
+
rspec-core (~> 2.14.0)
|
67
|
+
rspec-expectations (~> 2.14.0)
|
68
|
+
rspec-mocks (~> 2.14.0)
|
69
|
+
rspec-core (2.14.5)
|
70
|
+
rspec-expectations (2.14.3)
|
71
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
72
|
+
rspec-mocks (2.14.3)
|
73
|
+
sqlite3 (1.3.8)
|
74
|
+
tzinfo (0.3.37)
|
75
|
+
|
76
|
+
PLATFORMS
|
77
|
+
ruby
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
activerecord (~> 3.2.0)
|
81
|
+
bundler (~> 1.0)
|
82
|
+
jeweler!
|
83
|
+
rdoc (~> 3.12)
|
84
|
+
rspec
|
85
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Roman Snitko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
active_hash_fields
|
2
|
+
======
|
3
|
+
|
4
|
+
*An ActiveRecord extension to add serialized hash fields that act like objects*
|
5
|
+
|
6
|
+
Usecase
|
7
|
+
------------------------
|
8
|
+
A `User` should be able to set various notification options for various events. For example, he may want to receive an email notification when someone leaves a comment for his blog post, but not when someone replies with a comment to his comment.
|
9
|
+
|
10
|
+
This can usually be solved by either creating an additional associated model like `NotificationSettings` or by creating numerous fields in the `User` model itself. Not quite efficient either way.
|
11
|
+
|
12
|
+
Usage
|
13
|
+
------------------------
|
14
|
+
|
15
|
+
Here's the solution:
|
16
|
+
|
17
|
+
class User < ActiveRecord::Base
|
18
|
+
|
19
|
+
active_hash_fields :notitications,
|
20
|
+
comments_to_my_posts: true,
|
21
|
+
comments_to_my_comments: false,
|
22
|
+
someone_friended_me: true,
|
23
|
+
new_private_message: true
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
Now you can do things like:
|
29
|
+
|
30
|
+
# Default values are the ones set in the model,
|
31
|
+
# here we just redefine one
|
32
|
+
user = User.new(notifications: { comments_to_my_posts: false })
|
33
|
+
|
34
|
+
user.notifications.comments_to_my_posts # => false
|
35
|
+
user.notifications.new_private_message # => true
|
36
|
+
|
37
|
+
|
38
|
+
IMPORTANT NOTE
|
39
|
+
if you don't set a default value for the field, it will be ignore, that is:
|
40
|
+
|
41
|
+
user.notifications.some_non_existent_field = true
|
42
|
+
user.notifications.some_non_existent_field # => nil
|
43
|
+
|
44
|
+
|
45
|
+
INSTALLATION
|
46
|
+
------------
|
47
|
+
|
48
|
+
gem install active_hash_fields
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
19
|
+
gem.name = "active_hash_fields"
|
20
|
+
gem.homepage = "http://github.com/snitko/active_hash_fields"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{Adds nested fields to an AR model}
|
23
|
+
gem.description = %Q{Adds nested fields to an AR model stored in a serialized field as hash}
|
24
|
+
gem.email = "roman.snitko@gmail.com"
|
25
|
+
gem.authors = ["Roman Snitko"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rdoc/task'
|
31
|
+
Rake::RDocTask.new do |rdoc|
|
32
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
33
|
+
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "active_hash_fields #{version}"
|
36
|
+
rdoc.rdoc_files.include('README*')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
38
|
+
end
|
39
|
+
|
40
|
+
dbconfig = YAML::load(File.open('db/database.yml'))
|
41
|
+
ActiveRecord::Base.establish_connection(dbconfig)
|
42
|
+
|
43
|
+
namespace :db do
|
44
|
+
|
45
|
+
task :migrate do
|
46
|
+
ActiveRecord::Migration.verbose = true
|
47
|
+
ActiveRecord::Migrator.migrate File.dirname(__FILE__) + '/db/migrations', ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
48
|
+
ActiveRecord::SchemaDumper.dump ActiveRecord::Base.connection, File.open(File.dirname(__FILE__) + '/db/schema.rb', 'w')
|
49
|
+
end
|
50
|
+
|
51
|
+
task :rollback do
|
52
|
+
ActiveRecord::Migration.verbose = true
|
53
|
+
ActiveRecord::Migrator.down File.dirname(__FILE__) + '/db/migrations', ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
54
|
+
ActiveRecord::SchemaDumper.dump ActiveRecord::Base.connection, File.open(File.dirname(__FILE__) + '/db/schema.rb', 'w')
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "active_hash_fields"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Roman Snitko"]
|
12
|
+
s.date = "2013-09-27"
|
13
|
+
s.description = "Adds nested fields to an AR model stored in a serialized field as hash"
|
14
|
+
s.email = "roman.snitko@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.markdown",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"active_hash_fields.gemspec",
|
29
|
+
"db/database.yml",
|
30
|
+
"db/migrations/1_create_dummy.rb",
|
31
|
+
"db/schema.rb",
|
32
|
+
"db/test.sqlite3",
|
33
|
+
"lib/active_hash_fields.rb",
|
34
|
+
"spec/lib/active_hash_fields_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/snitko/active_hash_fields"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = "2.0.3"
|
41
|
+
s.summary = "Adds nested fields to an AR model"
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 4
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 3.2.0"])
|
48
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
51
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<activerecord>, ["~> 3.2.0"])
|
55
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<activerecord>, ["~> 3.2.0"])
|
63
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
64
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
66
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
67
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
data/db/database.yml
ADDED
data/db/schema.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended to check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(:version => 1) do
|
14
|
+
|
15
|
+
create_table "dummies", :force => true do |t|
|
16
|
+
t.text "notifications"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/db/test.sqlite3
ADDED
Binary file
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module ActiveHashFields
|
2
|
+
|
3
|
+
class HashAsObject
|
4
|
+
|
5
|
+
attr_reader :hash
|
6
|
+
|
7
|
+
def initialize(hash, defaults={})
|
8
|
+
hash ||= {}
|
9
|
+
defaults.stringify_keys!; hash.stringify_keys!
|
10
|
+
@hash = defaults.merge(hash)
|
11
|
+
@hash.each { |k,v| @hash[k] = self.class.convert_to_boolean(v) }
|
12
|
+
@hash.delete_if { |k,v| defaults[k].nil? }
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(name, *args, &blk)
|
16
|
+
name = name.to_s
|
17
|
+
if @hash
|
18
|
+
if @hash.has_key?(name)
|
19
|
+
return @hash[name]
|
20
|
+
elsif name.match(/=$/)
|
21
|
+
k = name.sub(/=$/, "")
|
22
|
+
if @hash.has_key?(k)
|
23
|
+
@hash[k] = self.class.convert_to_boolean(args[0])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
return @hash.send(name, *args, &blk)
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.convert_to_boolean(v)
|
33
|
+
if (v == "1" || v == "true" || v == true)
|
34
|
+
true
|
35
|
+
elsif v == "0" || v == "false" || v == false
|
36
|
+
false
|
37
|
+
else
|
38
|
+
v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
module ClassMethods
|
46
|
+
|
47
|
+
def hash_field_as_object(field_name, defaults={})
|
48
|
+
self.class_eval do
|
49
|
+
|
50
|
+
serialize field_name
|
51
|
+
|
52
|
+
after_initialize "initialize_empty_hash_for_#{field_name}", field_name
|
53
|
+
before_validation "write_hash_to_#{field_name}"
|
54
|
+
|
55
|
+
define_method field_name do
|
56
|
+
@hash_as_object_attrs[field_name] ||= HashAsObject.new(read_attribute(field_name), defaults)
|
57
|
+
end
|
58
|
+
|
59
|
+
define_method "#{field_name}=" do |hash|
|
60
|
+
send("initialize_empty_hash_for_#{field_name}")
|
61
|
+
@hash_as_object_attrs[field_name] = HashAsObject.new(hash, defaults)
|
62
|
+
@hash_as_object_attrs
|
63
|
+
end
|
64
|
+
|
65
|
+
define_method "write_hash_to_#{field_name}" do
|
66
|
+
write_attribute field_name, @hash_as_object_attrs[field_name].hash
|
67
|
+
end
|
68
|
+
|
69
|
+
define_method "initialize_empty_hash_for_#{field_name}" do
|
70
|
+
@hash_as_object_attrs ||= {}
|
71
|
+
#write_attribute(field_name, defaults) if read_attribute(field_name).nil?
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
module ActiveRecordExtension
|
80
|
+
def active_hash_fields(field_name, defaults={})
|
81
|
+
self.extend ActiveHashFields::ClassMethods
|
82
|
+
hash_field_as_object(field_name, defaults)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
ActiveRecord::Base.extend ActiveHashFields::ActiveRecordExtension
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Dummy < ActiveRecord::Base
|
4
|
+
active_hash_fields :notifications,
|
5
|
+
hello: false,
|
6
|
+
hi: false,
|
7
|
+
some_boolean_value: false,
|
8
|
+
answers_to_my_questions: true,
|
9
|
+
news: false
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ActiveHashFields do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
@dummy = Dummy.create()
|
16
|
+
@dummy.notifications = { "hello" => "hello", "hi" => "hi", "some_boolean_value" => "1" }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "gets hash values by calling methods on a field" do
|
20
|
+
@dummy.notifications.hello.should == "hello"
|
21
|
+
@dummy.notifications.hi.should == "hi"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "converts 0 and 1 strings to boolean values" do
|
25
|
+
@dummy.valid?
|
26
|
+
@dummy.notifications.some_boolean_value.should be_true
|
27
|
+
@dummy.notifications.some_boolean_value = "0"
|
28
|
+
@dummy.notifications.some_boolean_value.should be_false
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sets default values to the hash as soon as object is initialized" do
|
32
|
+
user1 = Dummy.new(notifications: { news: false } )
|
33
|
+
user2 = Dummy.new
|
34
|
+
user3 = Dummy.create(notifications: { news: "true" })
|
35
|
+
user1.notifications.should_not be_nil
|
36
|
+
user2.notifications.should_not be_nil
|
37
|
+
user3.notifications.news.should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "removes hash elements that are not listed in default values" do
|
41
|
+
@dummy.notifications = { "nonexistent_key" => true }
|
42
|
+
@dummy.notifications.nonexistent_key.should be_nil
|
43
|
+
@dummy.notifications.nonexistent_key = true
|
44
|
+
@dummy.notifications.nonexistent_key.should be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
# Remove this line if you don't want RSpec's should and should_not
|
3
|
+
# methods or matchers
|
4
|
+
require 'rspec/expectations'
|
5
|
+
config.include RSpec::Matchers
|
6
|
+
|
7
|
+
# == Mock Framework
|
8
|
+
config.mock_with :rspec
|
9
|
+
|
10
|
+
require 'active_record'
|
11
|
+
require File.dirname(__FILE__) + '/../lib/active_hash_fields'
|
12
|
+
|
13
|
+
config.before(:suite) do
|
14
|
+
dbconfig = YAML::load(File.open(File.dirname(__FILE__) + '/../db/database.yml'))
|
15
|
+
ActiveRecord::Base.establish_connection(dbconfig)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_hash_fields
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roman Snitko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Adds nested fields to an AR model stored in a serialized field as hash
|
98
|
+
email: roman.snitko@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files:
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.markdown
|
104
|
+
files:
|
105
|
+
- .document
|
106
|
+
- .rspec
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.markdown
|
111
|
+
- Rakefile
|
112
|
+
- VERSION
|
113
|
+
- active_hash_fields.gemspec
|
114
|
+
- db/database.yml
|
115
|
+
- db/migrations/1_create_dummy.rb
|
116
|
+
- db/schema.rb
|
117
|
+
- db/test.sqlite3
|
118
|
+
- lib/active_hash_fields.rb
|
119
|
+
- spec/lib/active_hash_fields_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
homepage: http://github.com/snitko/active_hash_fields
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.0.3
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Adds nested fields to an AR model
|
145
|
+
test_files: []
|