coercible 0.0.1
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/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +19 -0
- data/Changelog.md +4 -0
- data/Gemfile +6 -0
- data/Gemfile.devtools +44 -0
- data/Guardfile +58 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +2 -0
- data/coercible.gemspec +22 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/roodi.yml +17 -0
- data/config/site.reek +91 -0
- data/config/yardstick.yml +2 -0
- data/lib/coercible.rb +42 -0
- data/lib/coercible/coercer.rb +155 -0
- data/lib/coercible/coercer/array.rb +24 -0
- data/lib/coercible/coercer/configurable.rb +54 -0
- data/lib/coercible/coercer/date.rb +27 -0
- data/lib/coercible/coercer/date_time.rb +27 -0
- data/lib/coercible/coercer/decimal.rb +41 -0
- data/lib/coercible/coercer/false_class.rb +25 -0
- data/lib/coercible/coercer/float.rb +40 -0
- data/lib/coercible/coercer/hash.rb +72 -0
- data/lib/coercible/coercer/integer.rb +130 -0
- data/lib/coercible/coercer/numeric.rb +67 -0
- data/lib/coercible/coercer/object.rb +160 -0
- data/lib/coercible/coercer/string.rb +251 -0
- data/lib/coercible/coercer/symbol.rb +25 -0
- data/lib/coercible/coercer/time.rb +41 -0
- data/lib/coercible/coercer/time_coercions.rb +87 -0
- data/lib/coercible/coercer/true_class.rb +25 -0
- data/lib/coercible/configuration.rb +33 -0
- data/lib/coercible/version.rb +3 -0
- data/lib/support/options.rb +113 -0
- data/lib/support/type_lookup.rb +113 -0
- data/spec/integration/configuring_coercers_spec.rb +14 -0
- data/spec/shared/unit/configurable.rb +27 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/unit/coercible/coercer/array/to_set_spec.rb +12 -0
- data/spec/unit/coercible/coercer/class_methods/new_spec.rb +13 -0
- data/spec/unit/coercible/coercer/date/to_date_spec.rb +10 -0
- data/spec/unit/coercible/coercer/date/to_datetime_spec.rb +30 -0
- data/spec/unit/coercible/coercer/date/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/date/to_time_spec.rb +12 -0
- data/spec/unit/coercible/coercer/date_time/to_date_spec.rb +30 -0
- data/spec/unit/coercible/coercer/date_time/to_datetime_spec.rb +10 -0
- data/spec/unit/coercible/coercer/date_time/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/date_time/to_time_spec.rb +30 -0
- data/spec/unit/coercible/coercer/decimal/to_decimal_spec.rb +9 -0
- data/spec/unit/coercible/coercer/decimal/to_float_spec.rb +12 -0
- data/spec/unit/coercible/coercer/decimal/to_integer_spec.rb +12 -0
- data/spec/unit/coercible/coercer/decimal/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/element_reference_spec.rb +19 -0
- data/spec/unit/coercible/coercer/false_class/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/float/to_decimal_spec.rb +12 -0
- data/spec/unit/coercible/coercer/float/to_float_spec.rb +9 -0
- data/spec/unit/coercible/coercer/float/to_integer_spec.rb +12 -0
- data/spec/unit/coercible/coercer/float/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/hash/to_date_spec.rb +38 -0
- data/spec/unit/coercible/coercer/hash/to_datetime_spec.rb +38 -0
- data/spec/unit/coercible/coercer/hash/to_time_spec.rb +38 -0
- data/spec/unit/coercible/coercer/integer/to_boolean_spec.rb +27 -0
- data/spec/unit/coercible/coercer/integer/to_decimal_spec.rb +12 -0
- data/spec/unit/coercible/coercer/integer/to_float_spec.rb +12 -0
- data/spec/unit/coercible/coercer/integer/to_integer_spec.rb +9 -0
- data/spec/unit/coercible/coercer/integer/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/integer_spec.rb +11 -0
- data/spec/unit/coercible/coercer/numeric/to_decimal_spec.rb +10 -0
- data/spec/unit/coercible/coercer/numeric/to_float_spec.rb +10 -0
- data/spec/unit/coercible/coercer/numeric/to_integer_spec.rb +10 -0
- data/spec/unit/coercible/coercer/numeric/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/object/to_array_spec.rb +51 -0
- data/spec/unit/coercible/coercer/object/to_hash_spec.rb +22 -0
- data/spec/unit/coercible/coercer/object/to_integer_spec.rb +22 -0
- data/spec/unit/coercible/coercer/object/to_string_spec.rb +22 -0
- data/spec/unit/coercible/coercer/string/to_boolean_spec.rb +31 -0
- data/spec/unit/coercible/coercer/string/to_constant_spec.rb +49 -0
- data/spec/unit/coercible/coercer/string/to_date_spec.rb +25 -0
- data/spec/unit/coercible/coercer/string/to_datetime_spec.rb +52 -0
- data/spec/unit/coercible/coercer/string/to_decimal_spec.rb +47 -0
- data/spec/unit/coercible/coercer/string/to_float_spec.rb +57 -0
- data/spec/unit/coercible/coercer/string/to_integer_spec.rb +68 -0
- data/spec/unit/coercible/coercer/string/to_symbol_spec.rb +9 -0
- data/spec/unit/coercible/coercer/string/to_time_spec.rb +52 -0
- data/spec/unit/coercible/coercer/string_spec.rb +11 -0
- data/spec/unit/coercible/coercer/symbol/to_string_spec.rb +12 -0
- data/spec/unit/coercible/coercer/time/to_integer_spec.rb +10 -0
- data/spec/unit/coercible/coercer/time/to_time_spec.rb +10 -0
- data/spec/unit/coercible/coercer/time_coercions/to_date_spec.rb +30 -0
- data/spec/unit/coercible/coercer/time_coercions/to_datetime_spec.rb +34 -0
- data/spec/unit/coercible/coercer/time_coercions/to_string_spec.rb +19 -0
- data/spec/unit/coercible/coercer/time_coercions/to_time_spec.rb +34 -0
- data/spec/unit/coercible/coercer/true_class/to_string_spec.rb +12 -0
- data/spec/unit/coercible/configuration/class_methods/build_spec.rb +15 -0
- metadata +235 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install: gem install bundler
|
3
|
+
bundler_args: --without guard metrics
|
4
|
+
script: "bundle exec rake spec"
|
5
|
+
rvm:
|
6
|
+
- 1.8.7
|
7
|
+
- 1.9.2
|
8
|
+
- 1.9.3
|
9
|
+
- jruby-18mode
|
10
|
+
- jruby-19mode
|
11
|
+
- rbx-18mode
|
12
|
+
- rbx-19mode
|
13
|
+
- ree
|
14
|
+
- jruby-head
|
15
|
+
|
16
|
+
notifications:
|
17
|
+
email:
|
18
|
+
- piotr.solnica@gmail.com
|
19
|
+
- dan.kubb@gmail.com
|
data/Changelog.md
ADDED
data/Gemfile
ADDED
data/Gemfile.devtools
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
group :development do
|
2
|
+
gem 'rake', '~> 0.9.2'
|
3
|
+
gem 'rspec', '~> 2.12.0'
|
4
|
+
gem 'yard', '~> 0.8.3'
|
5
|
+
end
|
6
|
+
|
7
|
+
group :guard do
|
8
|
+
gem 'guard', '~> 1.5.4'
|
9
|
+
gem 'guard-bundler', '~> 1.0.0'
|
10
|
+
gem 'guard-rspec', '~> 2.1.1'
|
11
|
+
gem 'rb-inotify', :git => 'https://github.com/mbj/rb-inotify'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :benchmarks do
|
15
|
+
gem 'rbench', '~> 0.2.3'
|
16
|
+
end
|
17
|
+
|
18
|
+
platform :jruby do
|
19
|
+
group :jruby do
|
20
|
+
gem 'jruby-openssl', '~> 0.7.4'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
group :metrics do
|
25
|
+
gem 'flay', '~> 1.4.2'
|
26
|
+
gem 'flog', '~> 2.5.1'
|
27
|
+
gem 'reek', '~> 1.2.8', :git => 'https://github.com/dkubb/reek.git'
|
28
|
+
gem 'roodi', '~> 2.1.0'
|
29
|
+
gem 'yardstick', '~> 0.8.0'
|
30
|
+
gem 'mutant', '~> 0.2.4'
|
31
|
+
|
32
|
+
platforms :ruby_18, :ruby_19 do
|
33
|
+
# this indirectly depends on ffi which does not build on ruby-head
|
34
|
+
gem 'yard-spellcheck', '~> 0.1.5'
|
35
|
+
end
|
36
|
+
|
37
|
+
platforms :mri_19 do
|
38
|
+
gem 'simplecov', '~> 0.7'
|
39
|
+
end
|
40
|
+
|
41
|
+
platforms :rbx do
|
42
|
+
gem 'pelusa', '~> 0.2.1'
|
43
|
+
end
|
44
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'bundler' do
|
5
|
+
watch('Gemfile')
|
6
|
+
# Uncomment next line if Gemfile contain `gemspec' command
|
7
|
+
# watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'rspec' do
|
11
|
+
watch(%r{^spec/.+_spec\.rb$})
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
14
|
+
|
15
|
+
# Rails example
|
16
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
17
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
18
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
19
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
20
|
+
watch('config/routes.rb') { "spec/routing" }
|
21
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
22
|
+
|
23
|
+
# Capybara features specs
|
24
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
25
|
+
|
26
|
+
# Turnip features and steps
|
27
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
28
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
guard 'bundler' do
|
33
|
+
watch('Gemfile')
|
34
|
+
# Uncomment next line if Gemfile contain `gemspec' command
|
35
|
+
# watch(/^.+\.gemspec/)
|
36
|
+
end
|
37
|
+
|
38
|
+
guard 'rspec' do
|
39
|
+
watch(%r{^spec/.+_spec\.rb$})
|
40
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
41
|
+
watch('spec/spec_helper.rb') { "spec" }
|
42
|
+
|
43
|
+
# Rails example
|
44
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
45
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
46
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
47
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
48
|
+
watch('config/routes.rb') { "spec/routing" }
|
49
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
50
|
+
|
51
|
+
# Capybara features specs
|
52
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
53
|
+
|
54
|
+
# Turnip features and steps
|
55
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
56
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
57
|
+
end
|
58
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Piotr Solnica
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Coercible
|
2
|
+
|
3
|
+
[](http://travis-ci.org/solnic/coercible)
|
4
|
+
[](https://gemnasium.com/solnic/coercible)
|
5
|
+
[](https://codeclimate.com/github/solnic/coercible)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'coercible'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install coercible
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Coercible gives you access to coercer objects where each object is responsible
|
24
|
+
for coercing only one type into other types. For example a string coercer knows
|
25
|
+
only how to coerce string objects, integer coercer knows only how to coerce integers
|
26
|
+
etc.
|
27
|
+
|
28
|
+
Here's the most basic example:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
coercer = Coercible::Coercer.new
|
32
|
+
|
33
|
+
# coerce a string to a date
|
34
|
+
coercer[String].to_date('2012/12/25') # => #<Date: 4912573/2,0,2299161>
|
35
|
+
|
36
|
+
# coerce a string to a boolean value
|
37
|
+
coercer[String].to_string('yes') # => true
|
38
|
+
|
39
|
+
# you got the idea :)
|
40
|
+
```
|
41
|
+
|
42
|
+
For more control you can configure your coercer like that:
|
43
|
+
|
44
|
+
``` ruby
|
45
|
+
# build coercer instance
|
46
|
+
coercer = Coercible::Coercer.new do |config|
|
47
|
+
config.string.boolean_map = { 'yup' => true, 'nope' => false }
|
48
|
+
end
|
49
|
+
|
50
|
+
# coerce a string to boolean
|
51
|
+
coercer[String].to_boolean('yup') # => true
|
52
|
+
coercer[String].to_boolean('nope') # => false
|
53
|
+
```
|
54
|
+
|
55
|
+
Note that at the moment only Integer and String are configurable. More configurable
|
56
|
+
coercers will be added later whenever we find good usecases.
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/coercible.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coercible/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "coercible"
|
8
|
+
gem.version = Coercible::VERSION
|
9
|
+
gem.authors = ["Piotr Solnica"]
|
10
|
+
gem.email = ["piotr.solnica@gmail.com"]
|
11
|
+
gem.description = %q{Powerful, flexible and configurable coercion library. And nothing more.}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/solnic/coercible"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'backports', '~> 2.6'
|
21
|
+
gem.add_dependency 'descendants_tracker', '~> 0.0.1'
|
22
|
+
end
|
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/roodi.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
AbcMetricMethodCheck: { score: 12.1 }
|
3
|
+
AssignmentInConditionalCheck: { }
|
4
|
+
CaseMissingElseCheck: { }
|
5
|
+
ClassLineCountCheck: { line_count: 325 }
|
6
|
+
ClassNameCheck: { pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/ }
|
7
|
+
ClassVariableCheck: { }
|
8
|
+
CyclomaticComplexityBlockCheck: { complexity: 4 }
|
9
|
+
CyclomaticComplexityMethodCheck: { complexity: 4 }
|
10
|
+
EmptyRescueBodyCheck: { }
|
11
|
+
ForLoopCheck: { }
|
12
|
+
MethodLineCountCheck: { line_count: 10 }
|
13
|
+
MethodNameCheck: { pattern: !ruby/regexp /\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|<<|[+*&|-])\z/ }
|
14
|
+
ModuleLineCountCheck: { line_count: 331 }
|
15
|
+
ModuleNameCheck: { pattern: !ruby/regexp /\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/ }
|
16
|
+
# TODO: decrease parameter_count to 2 or less
|
17
|
+
ParameterNumberCheck: { parameter_count: 3 }
|
data/config/site.reek
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
---
|
2
|
+
UncommunicativeParameterName:
|
3
|
+
accept: []
|
4
|
+
exclude: []
|
5
|
+
enabled: true
|
6
|
+
reject:
|
7
|
+
- !ruby/regexp /^.$/
|
8
|
+
- !ruby/regexp /[0-9]$/
|
9
|
+
- !ruby/regexp /[A-Z]/
|
10
|
+
LargeClass:
|
11
|
+
max_methods: 14
|
12
|
+
exclude: []
|
13
|
+
enabled: true
|
14
|
+
max_instance_variables: 8
|
15
|
+
UncommunicativeMethodName:
|
16
|
+
accept: []
|
17
|
+
exclude: []
|
18
|
+
enabled: true
|
19
|
+
reject:
|
20
|
+
- !ruby/regexp /^[a-z]$/
|
21
|
+
- !ruby/regexp /[0-9]$/
|
22
|
+
- !ruby/regexp /[A-Z]/
|
23
|
+
LongParameterList:
|
24
|
+
max_params: 3
|
25
|
+
exclude: []
|
26
|
+
enabled: true
|
27
|
+
overrides: {}
|
28
|
+
FeatureEnvy:
|
29
|
+
exclude: []
|
30
|
+
enabled: true
|
31
|
+
ClassVariable:
|
32
|
+
exclude: []
|
33
|
+
enabled: true
|
34
|
+
BooleanParameter:
|
35
|
+
exclude: []
|
36
|
+
enabled: true
|
37
|
+
IrresponsibleModule:
|
38
|
+
exclude: []
|
39
|
+
enabled: true
|
40
|
+
UncommunicativeModuleName:
|
41
|
+
accept: []
|
42
|
+
exclude: []
|
43
|
+
enabled: true
|
44
|
+
reject:
|
45
|
+
- !ruby/regexp /^.$/
|
46
|
+
- !ruby/regexp /[0-9]$/
|
47
|
+
NestedIterators:
|
48
|
+
ignore_iterators: []
|
49
|
+
exclude: []
|
50
|
+
enabled: true
|
51
|
+
max_allowed_nesting: 2
|
52
|
+
LongMethod:
|
53
|
+
max_statements: 6
|
54
|
+
exclude: []
|
55
|
+
enabled: true
|
56
|
+
Duplication:
|
57
|
+
allow_calls: []
|
58
|
+
exclude: []
|
59
|
+
enabled: true
|
60
|
+
max_calls: 1
|
61
|
+
UtilityFunction:
|
62
|
+
max_helper_calls: 1
|
63
|
+
exclude: []
|
64
|
+
enabled: true
|
65
|
+
Attribute:
|
66
|
+
exclude: []
|
67
|
+
enabled: false
|
68
|
+
UncommunicativeVariableName:
|
69
|
+
accept: []
|
70
|
+
exclude: []
|
71
|
+
enabled: true
|
72
|
+
reject:
|
73
|
+
- !ruby/regexp /^.$/
|
74
|
+
- !ruby/regexp /[0-9]$/
|
75
|
+
- !ruby/regexp /[A-Z]/
|
76
|
+
SimulatedPolymorphism:
|
77
|
+
exclude: []
|
78
|
+
enabled: true
|
79
|
+
max_ifs: 1
|
80
|
+
DataClump:
|
81
|
+
exclude: []
|
82
|
+
enabled: true
|
83
|
+
max_copies: 2
|
84
|
+
min_clump_size: 2
|
85
|
+
ControlCouple:
|
86
|
+
exclude: []
|
87
|
+
enabled: true
|
88
|
+
LongYieldList:
|
89
|
+
max_params: 1
|
90
|
+
exclude: []
|
91
|
+
enabled: true
|
data/lib/coercible.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Coercible
|
2
|
+
EXTRA_CONST_ARGS = (RUBY_VERSION < '1.9' ? [] : [ false ]).freeze
|
3
|
+
|
4
|
+
UnsupportedCoercion = Class.new(StandardError)
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'date'
|
8
|
+
require 'time'
|
9
|
+
require 'bigdecimal'
|
10
|
+
require 'bigdecimal/util'
|
11
|
+
require 'set'
|
12
|
+
require 'backports'
|
13
|
+
|
14
|
+
require 'descendants_tracker'
|
15
|
+
require 'support/options'
|
16
|
+
require 'support/type_lookup'
|
17
|
+
|
18
|
+
require 'coercible/version'
|
19
|
+
require 'coercible/configuration'
|
20
|
+
|
21
|
+
require 'coercible/coercer'
|
22
|
+
require 'coercible/coercer/configurable'
|
23
|
+
require 'coercible/coercer/object'
|
24
|
+
|
25
|
+
require 'coercible/coercer/numeric'
|
26
|
+
require 'coercible/coercer/float'
|
27
|
+
require 'coercible/coercer/integer'
|
28
|
+
require 'coercible/coercer/decimal'
|
29
|
+
|
30
|
+
require 'coercible/coercer/string'
|
31
|
+
require 'coercible/coercer/symbol'
|
32
|
+
|
33
|
+
require 'coercible/coercer/time_coercions'
|
34
|
+
require 'coercible/coercer/date'
|
35
|
+
require 'coercible/coercer/date_time'
|
36
|
+
require 'coercible/coercer/time'
|
37
|
+
|
38
|
+
require 'coercible/coercer/false_class'
|
39
|
+
require 'coercible/coercer/true_class'
|
40
|
+
|
41
|
+
require 'coercible/coercer/array'
|
42
|
+
require 'coercible/coercer/hash'
|