sequel-store 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88cb7494cd109ca4eb440b9a1dd8609d71604c9d
4
+ data.tar.gz: 1d414b8c30fe134090670be21ca64cec0a73a7e2
5
+ SHA512:
6
+ metadata.gz: 87cc181b8064e3a88f792857c3319b24db2cc67d5d860db0eeb8718148eb5dc9bf03183ea50299e9ece43fd1ba89c3aac438d1138f7feda67ac76f305e63c9ad
7
+ data.tar.gz: 496cc4a74ba41d7913f3b2efc23e3c1fc1f59358e56a6ac409b3338cceba9b69718096c56dd875c5fa236a700eb97ed66c35a76340e1413473946995a84acdf0
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sequel-store.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Sergey Besedin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # SequelStore
2
+
3
+ Tiny extension for Sequel to add store_accessor capabilities similar to ActiveRecord::Store: http://api.rubyonrails.org/classes/ActiveRecord/Store.html
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sequel-store'
11
+ ```
12
+
13
+ And then add extension to Sequel:
14
+
15
+ ```
16
+ Sequel.extension :store_accessor
17
+ ```
18
+
19
+ Now define your accessors in `Sequel::Model` classes:
20
+
21
+ ```
22
+ class Article < Sequel::Model(:articles)
23
+ store_accessor :metadata, :year, :rating, :views_count
24
+
25
+ def views_count
26
+ super || 0
27
+ end
28
+ end
29
+ ```
30
+
31
+ ```
32
+ article = Article.new
33
+ article.year #=> nil
34
+ article.year = 2017
35
+ article.year #=> 2017
36
+ article.views_count #=> 0
37
+ article.metadata #=> {"year"=>2017}
38
+ ```
39
+
40
+ ## Development
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kressh/sequel-store.
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
52
+
@@ -0,0 +1 @@
1
+ require 'sequel_store/version'
@@ -0,0 +1,19 @@
1
+ module Sequel
2
+ module Extensions
3
+ module StoreAccessor
4
+ def store_accessor(field, *accessors)
5
+ accessors.each do |accessor|
6
+ define_method accessor do
7
+ self[field]&.send(:[], accessor.to_s)
8
+ end
9
+
10
+ define_method "#{accessor}=" do |value|
11
+ send "#{field}=", (self[field] || {}).merge({ accessor.to_s => value })
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Sequel::Model.extend Sequel::Extensions::StoreAccessor
@@ -0,0 +1,3 @@
1
+ module SequelStore
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sequel-store'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "sequel-store"
8
+ s.version = SequelStore::VERSION
9
+ s.authors = ["Sergey Besedin"]
10
+ s.email = ["kr3ssh@gmail.com"]
11
+
12
+ s.summary = %q{Extension for Sequel}
13
+ s.description = %q{Allows to use ActiveRecord-like store_accessor on hash fields}
14
+ s.homepage = "https://github.com/kressh/sequel-store"
15
+ s.license = "MIT"
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ s.bindir = "exe"
21
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_dependency 'sequel'
25
+
26
+ s.add_development_dependency "bundler", "~> 1.14"
27
+ s.add_development_dependency "rake", "~> 10.0"
28
+ s.add_development_dependency "rspec", "~> 3.0"
29
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel-store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergey Besedin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sequel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Allows to use ActiveRecord-like store_accessor on hash fields
70
+ email:
71
+ - kr3ssh@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - lib/sequel-store.rb
83
+ - lib/sequel/extensions/store_accessor.rb
84
+ - lib/sequel_store/version.rb
85
+ - sequel-store.gemspec
86
+ homepage: https://github.com/kressh/sequel-store
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.6.11
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Extension for Sequel
110
+ test_files: []