necromancer 0.3.0 → 0.7.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 +5 -5
- data/CHANGELOG.md +70 -3
- data/README.md +204 -86
- data/lib/necromancer.rb +17 -18
- data/lib/necromancer/configuration.rb +1 -1
- data/lib/necromancer/context.rb +16 -3
- data/lib/necromancer/conversion_target.rb +31 -14
- data/lib/necromancer/conversions.rb +39 -16
- data/lib/necromancer/converter.rb +10 -8
- data/lib/necromancer/converters/array.rb +143 -45
- data/lib/necromancer/converters/boolean.rb +21 -19
- data/lib/necromancer/converters/date_time.rb +58 -13
- data/lib/necromancer/converters/hash.rb +119 -0
- data/lib/necromancer/converters/numeric.rb +32 -28
- data/lib/necromancer/converters/range.rb +44 -18
- data/lib/necromancer/null_converter.rb +4 -2
- data/lib/necromancer/version.rb +2 -2
- metadata +39 -72
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.travis.yml +0 -19
- data/Gemfile +0 -16
- data/Rakefile +0 -8
- data/necromancer.gemspec +0 -21
- data/spec/spec_helper.rb +0 -53
- data/spec/unit/can_spec.rb +0 -11
- data/spec/unit/config_spec.rb +0 -32
- data/spec/unit/configuration/new_spec.rb +0 -30
- data/spec/unit/conversions/register_spec.rb +0 -49
- data/spec/unit/convert_spec.rb +0 -104
- data/spec/unit/converters/array/array_to_boolean_spec.rb +0 -22
- data/spec/unit/converters/array/array_to_numeric_spec.rb +0 -22
- data/spec/unit/converters/array/array_to_set_spec.rb +0 -18
- data/spec/unit/converters/array/object_to_array_spec.rb +0 -21
- data/spec/unit/converters/array/string_to_array_spec.rb +0 -33
- data/spec/unit/converters/boolean/boolean_to_integer_spec.rb +0 -26
- data/spec/unit/converters/boolean/integer_to_boolean_spec.rb +0 -22
- data/spec/unit/converters/boolean/string_to_boolean_spec.rb +0 -36
- data/spec/unit/converters/date_time/string_to_date_spec.rb +0 -22
- data/spec/unit/converters/date_time/string_to_datetime_spec.rb +0 -32
- data/spec/unit/converters/numeric/string_to_float_spec.rb +0 -48
- data/spec/unit/converters/numeric/string_to_integer_spec.rb +0 -62
- data/spec/unit/converters/numeric/string_to_numeric_spec.rb +0 -32
- data/spec/unit/converters/range/string_to_range_spec.rb +0 -35
- data/spec/unit/new_spec.rb +0 -12
- data/spec/unit/register_spec.rb +0 -17
- data/tasks/console.rake +0 -10
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
@@ -1,32 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Necromancer::NumericConverters::StringToNumericConverter, '.call' do
|
6
|
-
|
7
|
-
subject(:converter) { described_class.new(:string, :numeric) }
|
8
|
-
|
9
|
-
{
|
10
|
-
'1' => 1,
|
11
|
-
'+1' => 1,
|
12
|
-
'-1' => -1,
|
13
|
-
'1e1' => 10.0,
|
14
|
-
'1e-1' => 0.1,
|
15
|
-
'-1e1' => -10.0,
|
16
|
-
'-1e-1' => -0.1,
|
17
|
-
'1.0' => 1.0,
|
18
|
-
'1.0e+1' => 10.0,
|
19
|
-
'1.0e-1' => 0.1,
|
20
|
-
'-1.0e+1' => -10.0,
|
21
|
-
'-1.0e-1' => -0.1,
|
22
|
-
'.1' => 0.1,
|
23
|
-
'.1e+1' => 1.0,
|
24
|
-
'.1e-1' => 0.01,
|
25
|
-
'-.1e+1' => -1.0,
|
26
|
-
'-.1e-1' => -0.01
|
27
|
-
}.each do |actual, expected|
|
28
|
-
it "converts '#{actual}' to '#{expected}'" do
|
29
|
-
expect(converter.call(actual)).to eql(expected)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Necromancer::RangeConverters::StringToRangeConverter, '.call' do
|
6
|
-
|
7
|
-
subject(:converter) { described_class.new }
|
8
|
-
|
9
|
-
it "raises error for empty string in strict mode" do
|
10
|
-
expect {
|
11
|
-
converter.call('', strict: true)
|
12
|
-
}.to raise_error(Necromancer::ConversionTypeError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns value in non-strict mode" do
|
16
|
-
expect(converter.call('', strict: false)).to eq('')
|
17
|
-
end
|
18
|
-
|
19
|
-
{
|
20
|
-
'1' => 1..1,
|
21
|
-
'1..10' => 1..10,
|
22
|
-
'1-10' => 1..10,
|
23
|
-
'1,10' => 1..10,
|
24
|
-
'1...10' => 1...10,
|
25
|
-
'-1..10' => -1..10,
|
26
|
-
'1..-10' => 1..-10,
|
27
|
-
'a..z' => 'a'..'z',
|
28
|
-
'a-z' => 'a'..'z',
|
29
|
-
'A-Z' => 'A'..'Z'
|
30
|
-
}.each do |actual, expected|
|
31
|
-
it "converts '#{actual}' to range type" do
|
32
|
-
expect(converter.call(actual)).to eql(expected)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/spec/unit/new_spec.rb
DELETED
data/spec/unit/register_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe Necromancer, '.register' do
|
6
|
-
it "allows ro register converter" do
|
7
|
-
converter = described_class.new
|
8
|
-
UpcaseConverter = Struct.new(:source, :target) do
|
9
|
-
def call(value, options)
|
10
|
-
value.to_s.upcase
|
11
|
-
end
|
12
|
-
end
|
13
|
-
upcase_converter = UpcaseConverter.new(:string, :upcase)
|
14
|
-
expect(converter.register(upcase_converter)).to eq(true)
|
15
|
-
expect(converter.convert('magic').to(:upcase)).to eq('MAGIC')
|
16
|
-
end
|
17
|
-
end
|
data/tasks/console.rake
DELETED
data/tasks/coverage.rake
DELETED
data/tasks/spec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
desc 'Run all specs'
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :spec do
|
12
|
-
desc 'Run unit specs'
|
13
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Run integration specs'
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue LoadError
|
24
|
-
%w[spec spec:unit spec:integration].each do |name|
|
25
|
-
task name do
|
26
|
-
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|