rebase_attr 1.0.0

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: 6c5ca1579c9b6c0d4b53dbf284b9a907e78e0672
4
+ data.tar.gz: 59a8675533ba8782afac72c77b4abc5f3e864793
5
+ SHA512:
6
+ metadata.gz: 11f4460a87351f5440b6a99ad40b5f5365acaa957192c4478b715b44f870cdc1be575192a89ea56561f97a9948697aa61eb8463ad0b2d677e49ba9201b761b59
7
+ data.tar.gz: 83d57eb45a652d7ea51d7621d83d15ec962db0e1762db238fcfa4fcba38f99a9ebb58ac0e5aa05f9ace9bb80bf2bb0336f5cefe4270d956bfb47268ddf83e545
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rebase_attr.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # rebase_attr [![Gem Version](https://badge.fury.io/rb/attr_rebase.svg)](http://badge.fury.io/rb/attr_rebase)
2
+
3
+ Convert an attribute to a specified base.
4
+
5
+ When do you need this?
6
+
7
+ - If your IDs are too long to show, just convert to base 36 (digits and lower
8
+ case letters).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rebase_attr'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rebase_attr
25
+
26
+ ## Usage
27
+
28
+ Example for an active record table with long IDs:
29
+
30
+ ```ruby
31
+ # == Schema Info
32
+ #
33
+ # Table name: medical_bills
34
+ #
35
+ # id :integer(11) not null, primary key
36
+ #
37
+
38
+ class Bill < ActiveRecord::Base
39
+ rebase_attr :id, base: 32, readable: true # only digits and leters, without '0', '1', 'i' and 'l'
40
+ end
41
+ ```
42
+
43
+ Then use it:
44
+
45
+ ```ruby
46
+ bill = Bill.find(3151957185711)
47
+ bill.id
48
+ => "2rnfkjw5f"
49
+ bill.id_without_rebase
50
+ => 3151957185711
51
+ bill.id = "gw88yeya"
52
+ bill.id_without_rebase
53
+ => 572581263402
54
+ ```
55
+
56
+ Other functions you get when using rebase_attr:
57
+
58
+ ```ruby
59
+ bill.id_without_rebase = 3151957185711
60
+ bill.id
61
+ => "2rnfkjw5f"
62
+ Bill.find(Bill.decode("2rnfkjw5f"))
63
+ => #<Bill id: 3151957185711>
64
+ bill.decode("2rnfkjw5f")
65
+ => 3151957185711
66
+ Bill.encode(3151957185711)
67
+ => "2rnfkjw5f"
68
+ bill.encode(3151957185711)
69
+ => "2rnfkjw5f"
70
+ ```
71
+
72
+ Options you can pass to rebase_attr:
73
+
74
+ ```ruby
75
+ # Have :x return base 16, while '0' and '1' are replaced with 'x' and 'y', and then uppercased.
76
+ rebase_attr :x, to: 16, readable: true, convert: :upcase
77
+ # Have both :x and :y converted from a backend of octal string to a binary string, adding a 'b' in the beginning.
78
+ rebase_attr :x, :y, from: 8, to: 2, convert: -> (v) { "b#{v}" }, deconvert: -> (v) { v[1..-1] }
79
+ ```
80
+
81
+ ## Contributing
82
+
83
+ 1. Fork it ( https://github.com/odedniv/rebase_attr/fork )
84
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
85
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
86
+ 4. Push to the branch (`git push origin my-new-feature`)
87
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,3 @@
1
+ module RebaseAttr
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,77 @@
1
+ require "rebase_attr/version"
2
+
3
+ module RebaseAttr
4
+ READABLE_MAPPING = { '0' => 'x', '1' => 'y', 'l' => 'w', 'o' => 'z' }
5
+
6
+ module Generator
7
+ def rebase_attr(*attributes, to: nil, from: nil, convert: nil, deconvert: nil, readable: false)
8
+ raise ArgumentError, "#rebase_attr must receive :to" unless to
9
+ raise ArgumentError, "#rebase_attr does not accept a block, did you mean to use :convert?" if block_given?
10
+ raise ArgumentError, "#rebase_attr does not allow :readable option with bases higher than 32, #{to} given" if readable and to > 32
11
+
12
+ attributes.each do |attr|
13
+ # encoders & decoders
14
+ define_singleton_method :"encode_#{attr}" do |decoded|
15
+ result = decoded
16
+ raise TypeError, "decoded value must implement #to_i, #{result.inspect} given" unless result.respond_to?(:to_i)
17
+ result = result.to_i(from || 10) if result.is_a?(String)
18
+ result = result.to_s(to)
19
+ READABLE_MAPPING.each { |s, d| result.gsub!(/#{s}/i, d) } if readable # gsub! to conserve memory
20
+ result = convert.respond_to?(:call) ? convert.call(result) : result.public_send(convert) if convert
21
+ result
22
+ end
23
+ define_method :"encode_#{attr}" do |decoded|
24
+ self.class.send(:"encode_#{attr}", decoded)
25
+ end
26
+
27
+ define_singleton_method :"decode_#{attr}" do |encoded|
28
+ result = encoded
29
+ if deconvert
30
+ begin
31
+ result = result.clone # deconvert to not modify outside variable
32
+ rescue TypeError # can't clone, immutable
33
+ end
34
+ result = deconvert.respond_to?(:call) ? deconvert.call(result) : result.public_send(deconvert)
35
+ end
36
+ raise TypeError, "encoded value must implement #to_i, #{result.inspect} given" unless result.respond_to?(:to_i)
37
+ if readable
38
+ begin
39
+ result = result.clone # not modifying outside variable
40
+ rescue TypeError # can't clone, immutable
41
+ end
42
+ READABLE_MAPPING.each { |s, d| result.gsub!(/#{d}/i, s) } # gsub! to conserve memory
43
+ end
44
+ result = result.to_i(to)
45
+ result = result.to_s(from) if from
46
+ result
47
+ end
48
+ define_method :"decode_#{attr}" do |encoded|
49
+ self.class.send(:"decode_#{attr}", encoded)
50
+ end
51
+
52
+ # readers & writers
53
+ begin
54
+ alias_method :"#{attr}_without_rebase", attr
55
+ rescue NameError # reader does not exist
56
+ else
57
+ define_method attr do
58
+ send(:"encode_#{attr}", send(:"#{attr}_without_rebase"))
59
+ end
60
+ end
61
+
62
+ begin
63
+ alias_method :"#{attr}_without_rebase=", :"#{attr}="
64
+ rescue NameError # writer does not exist
65
+ else
66
+ define_method :"#{attr}=" do |encoded|
67
+ send(:"#{attr}_without_rebase=", send(:"decode_#{attr}", encoded))
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ class Module
76
+ include RebaseAttr::Generator
77
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rebase_attr/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rebase_attr"
8
+ spec.version = RebaseAttr::VERSION
9
+ spec.authors = ["Oded Niv"]
10
+ spec.email = ["oded.niv@gmail.com"]
11
+ spec.summary = %q{Convert an attribute to a specified base.}
12
+ spec.description = %q{Override attribute readers and writers with base encoders.}
13
+ spec.homepage = "https://github.com/odedniv/rebase_attr"
14
+ spec.license = "UNLICENSE"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rspec", "~> 3.1"
23
+ spec.add_development_dependency "rspec-its", "~> 1.0"
24
+ end
@@ -0,0 +1,230 @@
1
+ require 'rebase_attr'
2
+
3
+ class RebaseTestBase
4
+ attr_accessor :x
5
+ end
6
+
7
+ # This converts options to local varaibels so they can be used inside the Class.new { }
8
+ def rebase_class(**options, &block)
9
+ Class.new(RebaseTestBase) { rebase_attr(:x, **options, &block) }
10
+ end
11
+
12
+ describe RebaseAttr::Generator do
13
+ #requires: decoded, encoded
14
+ shared_examples_for "values" do
15
+ subject(:instance) { klass.new }
16
+
17
+ describe "#encode" do
18
+ specify { expect(klass.encode_x(decoded)).to eq(encoded) }
19
+ specify { expect(instance.encode_x(decoded)).to eq(encoded) }
20
+ end
21
+
22
+ describe "#decode" do
23
+ specify { expect(klass.decode_x(encoded)).to eq(decoded) }
24
+ specify { expect(instance.decode_x(encoded)).to eq(decoded) }
25
+ end
26
+
27
+ describe "reader" do
28
+ before { d = decoded; instance.instance_eval { @x = d } } # converting decoded to local variable so I can use it inside instance_eval
29
+ its(:x) { should == encoded }
30
+ end
31
+
32
+ describe "#without_rebase" do
33
+ before { d = decoded; instance.instance_eval { @x = d } } # converting decoded to local variable so I can use it inside instance_eval
34
+ its(:x_without_rebase) { should == decoded }
35
+ end
36
+
37
+ describe "writer" do
38
+ before { instance.x = encoded }
39
+ specify { expect(instance.instance_eval { @x }).to eq(decoded) }
40
+ end
41
+
42
+ describe "#without_rebase=" do
43
+ before { instance.x_without_rebase = decoded }
44
+ specify { expect(instance.instance_eval { @x }).to eq(decoded) }
45
+ end
46
+ end
47
+
48
+ # requires: from, to, convert_name, convert_block, decoded_default, decoded_from,
49
+ # decoded_convert, decoded_convert_from, encoded_default, encoded_convert
50
+ shared_context "all except readable" do
51
+ context "without from" do
52
+ context "not converted" do
53
+ let(:klass) { rebase_class to: to }
54
+ let(:decoded) { decoded_default }
55
+ let(:encoded) { encoded_default }
56
+ it_behaves_like "values"
57
+ end
58
+
59
+ context "converted" do
60
+ context "named" do
61
+ let(:klass) { rebase_class to: to, convert: convert_name, deconvert: deconvert }
62
+ let(:decoded) { decoded_default }
63
+ let(:encoded) { encoded_convert }
64
+ it_behaves_like "values"
65
+ end
66
+
67
+ context "block" do
68
+ let(:klass) { rebase_class to: to, convert: convert_block, deconvert: deconvert }
69
+ let(:decoded) { decoded_default }
70
+ let(:encoded) { encoded_convert }
71
+ it_behaves_like "values"
72
+ end
73
+ end
74
+ end
75
+
76
+ context "from" do
77
+ context "not converted" do
78
+ let(:klass) { rebase_class from: from, to: to }
79
+ let(:decoded) { decoded_from }
80
+ let(:encoded) { encoded_default }
81
+ it_behaves_like "values"
82
+ end
83
+
84
+ context "converted" do
85
+ let(:klass) { rebase_class from: from, to: to, convert: convert_name, deconvert: deconvert }
86
+ let(:decoded) { decoded_from }
87
+ let(:encoded) { encoded_convert }
88
+ it_behaves_like "values"
89
+ end
90
+ end
91
+ end
92
+
93
+ # requires: from, to, convert_name, convert_block, decoded_default, decoded_from, decoded_convert,
94
+ # decoded_convert_from, encoded_default, encoded_convert, encoded_readable, encoded_convert_readable
95
+ shared_context "allows readable" do
96
+ include_context "all except readable"
97
+
98
+ context "readable" do # 0 => x, 1 => y, l => w, o => z
99
+ context "without from" do
100
+ context "not converted" do
101
+ let(:klass) { rebase_class to: to, readable: true }
102
+ let(:decoded) { decoded_default }
103
+ let(:encoded) { encoded_readable }
104
+ it_behaves_like "values"
105
+ end
106
+
107
+ context "converted" do
108
+ let(:klass) { rebase_class to: to, readable: true, convert: convert_name, deconvert: deconvert }
109
+ let(:decoded) { decoded_default }
110
+ let(:encoded) { encoded_convert_readable }
111
+ it_behaves_like "values"
112
+ end
113
+ end
114
+
115
+ context "from" do
116
+ context "not converted" do
117
+ let(:klass) { rebase_class from: from, to: to, readable: true }
118
+ let(:decoded) { decoded_from }
119
+ let(:encoded) { encoded_readable }
120
+ it_behaves_like "values"
121
+ end
122
+
123
+ context "converted" do
124
+ let(:klass) { rebase_class from: from, to: to, readable: true, convert: convert_name, deconvert: deconvert }
125
+ let(:decoded) { decoded_from }
126
+ let(:encoded) { encoded_convert_readable }
127
+ it_behaves_like "values"
128
+ end
129
+ end
130
+ end
131
+ end
132
+
133
+ # requires: from, to, convert_name, convert_block, decoded_default, decoded_from,
134
+ # encoded_default, encoded_convert
135
+ shared_context "does not allow readable" do
136
+ include_context "all except readable"
137
+ end
138
+
139
+ # defaults
140
+ let(:from) { 8 }
141
+ let(:convert_name) { :upcase }
142
+ let(:convert_block) { -> (x) { x.send(convert_name) } }
143
+ let(:deconvert) { nil }
144
+ let(:decoded_default) { 31756185168571 }
145
+ let(:decoded_from) { "716072010565273" }
146
+
147
+ context "base 2" do
148
+ let(:to) { 2 }
149
+ let(:convert_name) { :chop }
150
+ let(:deconvert) { -> (x) { x + "1" } }
151
+ let(:encoded_default) { "111001110000111010000001000101110101010111011" }
152
+ let(:encoded_convert) { "11100111000011101000000100010111010101011101" }
153
+ let(:encoded_readable) { "yyyxxyyyxxxxyyyxyxxxxxxyxxxyxyyyxyxyxyxyyyxyy" }
154
+ let(:encoded_convert_readable) { "yyyxxyyyxxxxyyyxyxxxxxxyxxxyxyyyxyxyxyxyyyxy" }
155
+
156
+ include_context "allows readable"
157
+ end
158
+
159
+ context "base 8" do
160
+ let(:to) { 8 }
161
+ let(:from) { 7 }
162
+ let(:convert_name) { :chop }
163
+ let(:deconvert) { -> (x) { x + "3" } }
164
+ let(:decoded_from) { "6455210605126033" }
165
+ let(:encoded_default) { "716072010565273" }
166
+ let(:encoded_convert) { "71607201056527" }
167
+ let(:encoded_readable) { "7y6x72xyx565273" }
168
+ let(:encoded_convert_readable) { "7y6x72xyx56527" }
169
+
170
+ include_context "allows readable"
171
+ end
172
+
173
+ context "base 16" do
174
+ let(:to) { 16 }
175
+ let(:encoded_default) { "1ce1d022eabb" }
176
+ let(:encoded_convert) { "1CE1D022EABB" }
177
+ let(:encoded_readable) { "yceydx22eabb" }
178
+ let(:encoded_convert_readable) { "YCEYDX22EABB" }
179
+
180
+ include_context "allows readable"
181
+ end
182
+
183
+ context "base 32" do
184
+ let(:to) { 32 }
185
+ let(:encoded_default) { "ss7825qlr" }
186
+ let(:encoded_convert) { "SS7825QLR" }
187
+ let(:encoded_readable) { "ss7825qwr" }
188
+ let(:encoded_convert_readable) { "SS7825QWR" }
189
+
190
+ include_context "allows readable"
191
+ end
192
+
193
+ context "base 36" do
194
+ let(:to) { 36 }
195
+ let(:encoded_default) { "b98l8q8qj" }
196
+ let(:encoded_convert) { "B98L8Q8QJ" }
197
+
198
+ include_context "does not allow readable"
199
+ end
200
+
201
+ context "errors" do
202
+ specify { expect { rebase_class }.to raise_error(ArgumentError, "#rebase_attr must receive :to") }
203
+ specify { expect { rebase_class(to: 10) { } }.to raise_error(ArgumentError, "#rebase_attr does not accept a block, did you mean to use :convert?") }
204
+ specify { expect { rebase_class(to: 33, readable: true) }.to raise_error(ArgumentError, "#rebase_attr does not allow :readable option with bases higher than 32, 33 given") }
205
+
206
+ context "input" do
207
+ let(:klass) { rebase_class(to: 16) }
208
+ let(:instance) { klass.new }
209
+
210
+ describe "#encode" do
211
+ specify { expect { klass.encode_x(:a) }.to raise_error(TypeError, "decoded value must implement #to_i, :a given") }
212
+ specify { expect { instance.encode_x(:a) }.to raise_error(TypeError, "decoded value must implement #to_i, :a given") }
213
+ end
214
+
215
+ describe "#decode" do
216
+ specify { expect { klass.decode_x(:a) }.to raise_error(TypeError, "encoded value must implement #to_i, :a given") }
217
+ specify { expect { instance.decode_x(:a) }.to raise_error(TypeError, "encoded value must implement #to_i, :a given") }
218
+ end
219
+
220
+ describe "reader" do
221
+ before { instance.instance_eval { @x = :a } }
222
+ specify { expect { instance.x }.to raise_error(TypeError, "decoded value must implement #to_i, :a given") }
223
+ end
224
+
225
+ describe "writer" do
226
+ specify { expect { instance.x = :a }.to raise_error(TypeError, "encoded value must implement #to_i, :a given") }
227
+ end
228
+ end
229
+ end
230
+ end
@@ -0,0 +1,91 @@
1
+ require 'rspec/its'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
6
+ # file to always be loaded, without a need to explicitly require it in any files.
7
+ #
8
+ # Given that it is always loaded, you are encouraged to keep this file as
9
+ # light-weight as possible. Requiring heavyweight dependencies from this file
10
+ # will add to the boot time of your test suite on EVERY test run, even for an
11
+ # individual file that may not need all of that loaded. Instead, consider making
12
+ # a separate helper file that requires the additional dependencies and performs
13
+ # the additional setup, and require it from the spec files that actually need it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
54
+ # For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rebase_attr
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Oded Niv
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-its
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: Override attribute readers and writers with base encoders.
56
+ email:
57
+ - oded.niv@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - UNLICENSE
68
+ - lib/rebase_attr.rb
69
+ - lib/rebase_attr/version.rb
70
+ - rebase_attr.gemspec
71
+ - spec/rebase_attr_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/odedniv/rebase_attr
74
+ licenses:
75
+ - UNLICENSE
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Convert an attribute to a specified base.
97
+ test_files:
98
+ - spec/rebase_attr_spec.rb
99
+ - spec/spec_helper.rb