hash_accessor 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7098291ed6e537cfcc5b10d9d373df566468c6ff
4
+ data.tar.gz: a70729fdf9bd57daab92a4063bb306ae14fc2f29
5
+ SHA512:
6
+ metadata.gz: d137ed9b3df56b6ef8b07080b42b32bec92317c91f83f656efb688e7952f7b816093f2a6e4456247ffeb08d922a4e56a659236f5610ec75b51b1d61874c1bd1b
7
+ data.tar.gz: 335525f8481eeab048131104e33e36e9a6995a64575d220c23eef8afb36c7cdb2881eb14530f5b1ce277a220bc38193bc755e5715f665fde5ddd9d8523bbceee
data/.coveralls ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -1 +1,5 @@
1
1
  *.gem
2
+ Gemfile*.lock
3
+
4
+ .bundle/
5
+ .idea
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.4
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ language: ruby
3
+ script: bundle exec rake
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.5
8
+ - 2.2.0
9
+ - jruby-19mode
10
+ gemfile:
11
+ - test/gemfiles/Gemfile.rails-4.2.x
12
+ matrix:
13
+ exclude:
14
+ - rvm: 1.9.3
15
+ gemfile: spec/gemfiles/rails-4.2.x.gemfile
16
+ fast_finish: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # 1.0.6 / 2018-6-12
2
+
3
+ * Update activesupport to 4.2.9
4
+
5
+ # 1.0.5 / 2012-9-20
6
+
7
+ * [BUGFIX] don't share variables between instances
8
+
9
+ # 1.0.4 / 2012-9-20
10
+
11
+ * [ENHANCEMENT] added support for :decimal type
12
+
13
+ # 1.0.2 / 2012-1-22
14
+
15
+ * support Rails 3.2
16
+
17
+ # 1.0.1 / 2011-11-17
18
+
19
+ * [BUGFIX] fixing extra slash in load path of old init file
20
+
21
+ # 1.0.0 / 2011-8-16
22
+
23
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem 'coveralls', :require => false
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright on Updates - Copyright (c) 2011 OctopusApp Inc. (http://getjobber.com), released under the MIT license
1
+ Copyright (c) 2013 OctopusApp Inc. (http://getjobber.com), released under the MIT license
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # HashAccessor
2
+
3
+ [![Build Status](https://travis-ci.org/GetJobber/hash_accessor.png?branch=testing)](https://travis-ci.org/GetJobber/hash_accessor) [![Coverage Status](https://img.shields.io/coveralls/GetJobber/hash_accessor.svg)](https://coveralls.io/r/GetJobber/hash_accessor) [![Code Climate](https://codeclimate.com/github/GetJobber/hash_accessor.png)](https://codeclimate.com/github/GetJobber/hash_accessor)
4
+
5
+ This gem provides similar functionality to Rails' new ActiveAttr, except with a bunch of powerful methods behind it. Type definitions, defaults, lambdas on arrays, and more.
6
+
7
+ The purpose behind building HashAccessor was to be able to quickly add/modify/remove variables being stored in a serialized hash of a rails model. This is very useful if you have a large list of often changing variables on a model which don't get queried against. You can create new variables without messing up your DB. Storing account configurations or custom themes is a common scenario.
8
+
9
+ This gem was designed to have HTML forms update directly to the hash, but maintain the correct class (respecting :attr_accessible of course). Options like :default, :type, and :collects are particularly helpful when dealing with forms.
10
+
11
+ ## Installation
12
+
13
+ In your Gemfile:
14
+
15
+ ```
16
+ gem "hash_accessor"
17
+ ```
18
+
19
+ Then run:
20
+
21
+ ```
22
+ bundle install
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ You define each accessor you want to be stored inside the serialized hash:
28
+
29
+ ```
30
+ hash_accessor _NAME_OF_HASH_, _NAME_OF_VARIABLE_, options
31
+ ```
32
+
33
+ Here is an example:
34
+
35
+ ```ruby
36
+ class MyModel < ActiveRecord::Base
37
+ serialize :options, Hash
38
+
39
+ hash_accessor :options, :currency, :default => "$USD"
40
+ hash_accessor :options, :display_currency_on_invoices, :type => :boolean, :default => true
41
+ hash_accessor :options, :invoice_due_date_net, :type => :integer, :default => 3
42
+
43
+
44
+ def some_method
45
+
46
+ self.currency = "$CAD"
47
+
48
+ display_currency_on_invoices?
49
+
50
+ # ...
51
+ end
52
+
53
+ end
54
+ ```
55
+
56
+ ### Valid Options:
57
+
58
+ `:default` - if undefined, this plugin will create an empty instance of the defined type or null
59
+
60
+ `:type` - defaults to :string. Can also be :integer, :float, :decimal, :boolean, or :array
61
+
62
+ #### For Arrays only:
63
+
64
+ `:collects` - only runs on arrays. Calls the lambda method on each item in the array before saving
65
+
66
+ `:reject_blanks` - removes all blank elements after the collect method. This with :collects can be used together for storing a list of ids stored as checkboxes in a form.
67
+
68
+
69
+
70
+ ## Contributing & Reporting Issues
71
+
72
+ Please feel free to report any issues, provide feedback, or make suggestions on the [Issue Tracker](http://github.com/GetJobber/hash_accessor/issues)
73
+
74
+ Tests can be ran against different versions of Rails like so:
75
+
76
+ ```
77
+ BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle install
78
+ BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle exec rake test
79
+ ```
80
+
81
+ ---
82
+
83
+
84
+ Copyright (c) 2014 OctopusApp Inc. ([getjobber.com](http://getjobber.com)), released under the MIT license
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
+ require "rubygems"
2
+ require "bundler/gem_tasks"
3
+
1
4
  require 'rake/testtask'
2
5
 
3
6
  Rake::TestTask.new do |t|
4
- t.libs << 'test'
7
+ t.libs.push "lib"
8
+ t.test_files = FileList['test/*_test.rb']
9
+ t.verbose = true
5
10
  end
6
11
 
7
12
  desc "Run tests"
8
- task :default => :test
13
+ task :default => :test
@@ -7,18 +7,21 @@ Gem::Specification.new do |s|
7
7
  s.email = ["forrest@getjobber.com"]
8
8
  s.date = Time.now.utc.strftime("%Y-%m-%d")
9
9
 
10
- s.description = 'This gem provides accessor methods to hash keys.'
10
+ s.description = "This gem provides accessor methods to hash keys."
11
11
  s.summary = "This gem provides extended functionality to serialized hashed in rails similary to rails' active_attr. It allows you to define accessor methods for variable that rest "+
12
12
  "inside a serialized hash. This is very useful if you have a large list of often changing DB variables on a model which don't get queried against."
13
13
 
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.platform = Gem::Platform::RUBY
16
- s.add_dependency 'activesupport', '>= 3.2.0'
16
+
17
+ s.add_dependency "activesupport", ">= 4.2.9"
18
+ s.add_development_dependency "minitest", ">= 4.0"
19
+ s.add_development_dependency "bundler", ">= 1.3"
20
+ s.add_development_dependency "rake"
17
21
 
18
22
  s.files = `git ls-files`.split("\n")
19
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
24
  s.require_path = "lib"
21
25
 
22
26
  s.has_rdoc = true
23
- s.extra_rdoc_files = ["README.rdoc"]
24
27
  end
data/lib/hash_accessor.rb CHANGED
@@ -4,7 +4,7 @@ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname
4
4
  require 'hash_accessor/railtie' if defined?(Rails)
5
5
 
6
6
  module HashAccessor
7
- VERSION = "1.0.5"
7
+ VERSION = "1.0.6"
8
8
 
9
9
  autoload :ClassMethods, 'hash_accessor/class_methods'
10
10
 
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+ gemspec :path => "./../.."
3
+
4
+ gem "activesupport", "~> 4.2.0"
5
+ gem 'coveralls', :require => false
@@ -1,8 +1,6 @@
1
- require 'test/unit'
1
+ require_relative "test_helper"
2
2
 
3
- require File.expand_path("../lib/hash_accessor", File.dirname(__FILE__))
4
-
5
- class HashAccessorTest < Test::Unit::TestCase
3
+ class HashAccessorTest < MiniTest::Unit::TestCase
6
4
 
7
5
  class TestClassWithHash
8
6
  include HashAccessor
@@ -13,7 +11,7 @@ class HashAccessorTest < Test::Unit::TestCase
13
11
  hash_accessor :options, :test_decimal, :type => :decimal
14
12
  hash_accessor :options, :test_bool, :type => :bool
15
13
  hash_accessor :options, :test_array_1, :type => :array, :collects => lambda{|item|
16
- item.gsub(/li_/, "").to_i
14
+ item.gsub(/li_/, "").to_i
17
15
  }
18
16
  hash_accessor :options, :test_array_2, :type => :array, :reject_blanks => true
19
17
 
@@ -0,0 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require "minitest/autorun"
5
+
6
+ require File.expand_path("../lib/hash_accessor", File.dirname(__FILE__))
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
5
- prerelease:
4
+ version: 1.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jobber
@@ -10,69 +9,115 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-09-20 00:00:00.000000000 Z
12
+ date: 2018-06-13 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
- version: 3.2.0
20
+ version: 4.2.9
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
- version: 3.2.0
27
+ version: 4.2.9
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '4.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '4.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '1.3'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '1.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
31
70
  description: This gem provides accessor methods to hash keys.
32
71
  email:
33
72
  - forrest@getjobber.com
34
73
  executables: []
35
74
  extensions: []
36
- extra_rdoc_files:
37
- - README.rdoc
75
+ extra_rdoc_files: []
38
76
  files:
39
- - .gitignore
77
+ - ".coveralls"
78
+ - ".gitignore"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
82
+ - Gemfile
40
83
  - MIT-LICENSE
41
- - README.rdoc
84
+ - README.md
42
85
  - Rakefile
43
86
  - hash_accessor.gemspec
44
87
  - lib/hash_accessor.rb
45
88
  - lib/hash_accessor/class_methods.rb
46
89
  - lib/hash_accessor/railtie.rb
47
90
  - rails/init.rb
91
+ - test/gemfiles/Gemfile.rails-4.2.x
48
92
  - test/hash_accessor_test.rb
93
+ - test/test_helper.rb
49
94
  homepage:
50
95
  licenses: []
96
+ metadata: {}
51
97
  post_install_message:
52
98
  rdoc_options: []
53
99
  require_paths:
54
100
  - lib
55
101
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
102
  requirements:
58
- - - ! '>='
103
+ - - ">="
59
104
  - !ruby/object:Gem::Version
60
105
  version: '0'
61
106
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
107
  requirements:
64
- - - ! '>='
108
+ - - ">="
65
109
  - !ruby/object:Gem::Version
66
110
  version: 1.3.6
67
111
  requirements: []
68
112
  rubyforge_project:
69
- rubygems_version: 1.8.22
113
+ rubygems_version: 2.6.12
70
114
  signing_key:
71
- specification_version: 3
115
+ specification_version: 4
72
116
  summary: This gem provides extended functionality to serialized hashed in rails similary
73
117
  to rails' active_attr. It allows you to define accessor methods for variable that
74
118
  rest inside a serialized hash. This is very useful if you have a large list of often
75
119
  changing DB variables on a model which don't get queried against.
76
120
  test_files:
121
+ - test/gemfiles/Gemfile.rails-4.2.x
77
122
  - test/hash_accessor_test.rb
78
- has_rdoc: true
123
+ - test/test_helper.rb
data/README.rdoc DELETED
@@ -1,67 +0,0 @@
1
- = HashAccessor
2
-
3
- This gem provides similar functionality to Rails' new ActiveAttr, except with a bunch of powerful methods behind it. Type definitions, defaults, lambdas on arrays, and more.
4
-
5
- The purpose behind building HashAccessor was to be able to quickly add/modify/remove variables being stored in a serialized hash of a rails model. This is very useful if you have a large list of often changing variables on a model which don't get queried against. You can create new variables without messing up your DB. Storing account configurations or custom themes is a common scenario.
6
-
7
- This gem was designed to have HTML forms update directly to the hash, but maintain the correct class (respecting :attr_accessible of course). Options like :default, :type, and :collects are particularly helpful when dealing with forms.
8
-
9
- == Installation
10
-
11
- In your <code>Gemfile</code>:
12
-
13
- gem "hash_accessor"
14
-
15
- Then run:
16
-
17
- bundle install
18
-
19
- == Usage
20
-
21
- You define each accessor you want to be stored inside the serialized hash
22
-
23
- <code>hash_accessor _NAME_OF_HASH_, _NAME_OF_VARIABLE_, options</code>
24
-
25
- Here is an example:
26
-
27
- class MyModel < ActiveRecord::Base
28
- serialize :options, Hash
29
-
30
- hash_accessor :options, :currency, :default => "$USD"
31
- hash_accessor :options, :display_currency_on_invoices, :type => :boolean, :default => true
32
- hash_accessor :options, :invoice_due_date_net, :type => :integer, :default => 3
33
-
34
-
35
- def some_method
36
-
37
- self.currency = "$CAD"
38
-
39
- display_currency_on_invoices?
40
-
41
- ...
42
- end
43
-
44
- end
45
-
46
- === Valid Options:
47
-
48
- <code>:default</code> - if undefined, this plugin will create an empty instance of the defined type or null
49
-
50
- <code>:type</code> - defaults to :string. Can also be :integer, :float, :decimal, :boolean, or :array
51
-
52
- ==== For Arrays only:
53
- <code>:collects</code> - only runs on arrays. Calls the lambda method on each item in the array before saving
54
-
55
- <code>:reject_blanks</code> - removes all blank elements after the collect method. This with :collects can be used together for storing a list of ids stored as checkboxes in a form.
56
-
57
-
58
-
59
- == Contributing & Reporting Issues
60
-
61
- While I can't promise the most speedy response, I do plan to continue to maintain this gem. Please feel free to report any issues, provide feedback, or make suggestions on the {Issue Tracker}[http://github.com/GetJobber/hash_accessor/issues]
62
-
63
-
64
- ---
65
-
66
-
67
- Copyright on Updates - Copyright (c) 2011 OctopusApp Inc. ({getjobber.com}[http://getjobber.com]), released under the MIT license