dm-types 0.9.11 → 0.10.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.
- data/{History.txt → History.rdoc} +5 -4
- data/LICENSE +16 -14
- data/Manifest.txt +13 -3
- data/{README.txt → README.rdoc} +0 -0
- data/Rakefile +3 -4
- data/TODO +74 -0
- data/lib/dm-types.rb +15 -18
- data/lib/dm-types/bcrypt_hash.rb +1 -4
- data/lib/dm-types/comma_separated_list.rb +31 -0
- data/lib/dm-types/csv.rb +12 -18
- data/lib/dm-types/enum.rb +18 -15
- data/lib/dm-types/epoch_time.rb +6 -11
- data/lib/dm-types/file_path.rb +5 -4
- data/lib/dm-types/flag.rb +14 -13
- data/lib/dm-types/ip_address.rb +1 -0
- data/lib/dm-types/json.rb +5 -11
- data/lib/dm-types/regexp.rb +2 -3
- data/lib/dm-types/slug.rb +8 -17
- data/lib/dm-types/uri.rb +8 -14
- data/lib/dm-types/uuid.rb +9 -15
- data/lib/dm-types/version.rb +1 -1
- data/lib/dm-types/yaml.rb +4 -3
- data/spec/fixtures/article.rb +39 -0
- data/spec/fixtures/bookmark.rb +27 -0
- data/spec/fixtures/invention.rb +9 -0
- data/spec/fixtures/network_node.rb +40 -0
- data/spec/fixtures/person.rb +29 -0
- data/spec/fixtures/software_package.rb +37 -0
- data/spec/fixtures/ticket.rb +25 -0
- data/spec/fixtures/tshirt.rb +28 -0
- data/spec/integration/bcrypt_hash_spec.rb +37 -55
- data/spec/integration/comma_separated_list_spec.rb +89 -0
- data/spec/integration/enum_spec.rb +62 -42
- data/spec/integration/file_path_spec.rb +149 -17
- data/spec/integration/flag_spec.rb +56 -25
- data/spec/integration/ip_address_spec.rb +142 -17
- data/spec/integration/json_spec.rb +60 -17
- data/spec/integration/slug_spec.rb +39 -40
- data/spec/integration/uri_spec.rb +126 -21
- data/spec/integration/uuid_spec.rb +84 -30
- data/spec/integration/yaml_spec.rb +55 -25
- data/spec/shared/identity_function_group.rb +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +49 -17
- data/spec/unit/bcrypt_hash_spec.rb +107 -64
- data/spec/unit/csv_spec.rb +111 -27
- data/spec/unit/enum_spec.rb +128 -87
- data/spec/unit/epoch_time_spec.rb +57 -32
- data/spec/unit/file_path_spec.rb +55 -34
- data/spec/unit/flag_spec.rb +102 -65
- data/spec/unit/ip_address_spec.rb +90 -40
- data/spec/unit/json_spec.rb +108 -41
- data/spec/unit/regexp_spec.rb +47 -17
- data/spec/unit/uri_spec.rb +57 -46
- data/spec/unit/yaml_spec.rb +91 -45
- data/tasks/install.rb +1 -1
- data/tasks/spec.rb +4 -4
- metadata +25 -32
- data/lib/dm-types/serial.rb +0 -8
data/spec/unit/regexp_spec.rb
CHANGED
@@ -1,23 +1,53 @@
|
|
1
|
-
require '
|
2
|
-
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
try_spec do
|
4
|
+
describe DataMapper::Types::Regexp do
|
5
|
+
describe '.load' do
|
6
|
+
describe 'when argument is a string' do
|
7
|
+
before :all do
|
8
|
+
@input = '[a-z]\d+'
|
9
|
+
@result = DataMapper::Types::Regexp.load(@input, :property)
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
12
|
+
it 'create a regexp instance from argument' do
|
13
|
+
@result.should == Regexp.new(@input)
|
14
|
+
end
|
15
|
+
end
|
14
16
|
|
15
|
-
describe
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
describe 'when argument is nil' do
|
18
|
+
before :all do
|
19
|
+
@input = nil
|
20
|
+
@result = DataMapper::Types::Regexp.load(@input, :property)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns nil' do
|
24
|
+
@result.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.dump' do
|
30
|
+
describe 'when argument is a regular expression' do
|
31
|
+
before :all do
|
32
|
+
@input = /\d+/
|
33
|
+
@result = DataMapper::Types::Regexp.dump(@input, :property)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'escapes the argument' do
|
37
|
+
@result.should == '\\d+'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'when argument is nil' do
|
42
|
+
before :all do
|
43
|
+
@input = nil
|
44
|
+
@result = DataMapper::Types::Regexp.dump(@input, :property)
|
45
|
+
end
|
19
46
|
|
20
|
-
|
21
|
-
|
47
|
+
it 'returns nil' do
|
48
|
+
@result.should be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
22
52
|
end
|
23
53
|
end
|
data/spec/unit/uri_spec.rb
CHANGED
@@ -1,49 +1,60 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
describe DataMapper::Types::URI do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
try_spec do
|
4
|
+
describe DataMapper::Types::URI do
|
5
|
+
before do
|
6
|
+
@uri_str = 'http://example.com/path/to/resource/'
|
7
|
+
@uri = Addressable::URI.parse(@uri_str)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.dump' do
|
11
|
+
it 'returns the URI as a String' do
|
12
|
+
DataMapper::Types::URI.dump(@uri, :property).should == @uri_str
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'when given nil' do
|
16
|
+
it 'returns nil' do
|
17
|
+
DataMapper::Types::URI.dump(nil, :property).should be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'when given an empty string' do
|
22
|
+
it 'returns an empty URI' do
|
23
|
+
DataMapper::Types::URI.dump('', :property).should == ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.load' do
|
29
|
+
it 'returns the URI as Addressable' do
|
30
|
+
DataMapper::Types::URI.load(@uri_str, :property).should == @uri
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when given nil' do
|
34
|
+
it 'returns nil' do
|
35
|
+
DataMapper::Types::URI.load(nil, :property).should be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'if given an empty String' do
|
40
|
+
it 'returns an empty URI' do
|
41
|
+
DataMapper::Types::URI.load('', :property).should == Addressable::URI.parse('')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.typecast' do
|
47
|
+
describe 'given instance of Addressable::URI' do
|
48
|
+
it 'does nothing' do
|
49
|
+
DataMapper::Types::URI.typecast(@uri, :property).should == @uri
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'when given a string' do
|
54
|
+
it 'delegates to .load' do
|
55
|
+
DataMapper::Types::URI.typecast(@uri_str, :property).should == @uri
|
56
|
+
end
|
57
|
+
end
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
data/spec/unit/yaml_spec.rb
CHANGED
@@ -1,58 +1,104 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/identity_function_group'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
4
|
+
try_spec do
|
5
|
+
describe DataMapper::Types::Yaml do
|
6
|
+
describe '.load' do
|
7
|
+
describe 'when nil is provided' do
|
8
|
+
it 'returns nil' do
|
9
|
+
DataMapper::Types::Yaml.load(nil, :property).should be_nil
|
10
|
+
end
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
describe 'when YAML encoded primitive string is provided' do
|
14
|
+
it 'returns decoded value as Ruby string' do
|
15
|
+
DataMapper::Types::Yaml.load("--- yaml string\n", :property).should == 'yaml string'
|
16
|
+
end
|
17
|
+
end
|
20
18
|
|
21
|
-
describe
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
describe 'when something else is provided' do
|
20
|
+
it 'raises ArgumentError with a meaningful message' do
|
21
|
+
lambda {
|
22
|
+
DataMapper::Types::Yaml.load(:sym, :property)
|
23
|
+
}.should raise_error(ArgumentError, '+value+ of a property of YAML type must be nil or a String')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
describe '.dump' do
|
29
|
+
describe 'when nil is provided' do
|
30
|
+
it 'returns nil' do
|
31
|
+
DataMapper::Types::Yaml.dump(nil, :property).should be_nil
|
32
|
+
end
|
33
|
+
end
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
describe 'when YAML encoded primitive string is provided' do
|
36
|
+
it 'does not do double encoding' do
|
37
|
+
DataMapper::Types::Yaml.dump("--- yaml encoded string\n", :property).should == "--- yaml encoded string\n"
|
38
|
+
end
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
+
describe 'when regular Ruby string is provided' do
|
42
|
+
it 'dumps argument to YAML' do
|
43
|
+
DataMapper::Types::Yaml.dump('dump me (to yaml)', :property).should == "--- dump me (to yaml)\n"
|
44
|
+
end
|
45
|
+
end
|
41
46
|
|
42
|
-
describe
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
describe 'when Ruby array is provided' do
|
48
|
+
it 'dumps argument to YAML' do
|
49
|
+
DataMapper::Types::Yaml.dump([1, 2, 3], :property).should == "--- \n- 1\n- 2\n- 3\n"
|
50
|
+
end
|
51
|
+
end
|
46
52
|
|
47
|
-
|
48
|
-
|
53
|
+
describe 'when Ruby hash is provided' do
|
54
|
+
it 'dumps argument to YAML' do
|
55
|
+
DataMapper::Types::Yaml.dump({ :datamapper => 'Data access layer in Ruby' }, :property).should == "--- \n:datamapper: Data access layer in Ruby\n"
|
56
|
+
end
|
57
|
+
end
|
49
58
|
end
|
50
59
|
|
51
|
-
|
52
|
-
|
60
|
+
describe '.typecast' do
|
61
|
+
class SerializeMe
|
62
|
+
attr_accessor :name
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'given a number' do
|
66
|
+
before :all do
|
67
|
+
@input = 15
|
68
|
+
@result = 15
|
69
|
+
end
|
70
|
+
|
71
|
+
it_should_behave_like 'identity function'
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'given an Array instance' do
|
75
|
+
before :all do
|
76
|
+
@input = ['dm-core', 'dm-more']
|
77
|
+
@result = ['dm-core', 'dm-more']
|
78
|
+
end
|
79
|
+
|
80
|
+
it_should_behave_like 'identity function'
|
81
|
+
end
|
53
82
|
|
54
|
-
|
55
|
-
|
56
|
-
|
83
|
+
describe 'given a Hash instance' do
|
84
|
+
before :all do
|
85
|
+
@input = { :format => 'yaml' }
|
86
|
+
@result = { :format => 'yaml' }
|
87
|
+
end
|
88
|
+
|
89
|
+
it_should_behave_like 'identity function'
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'given a plain old Ruby object' do
|
93
|
+
before :all do
|
94
|
+
@input = SerializeMe.new
|
95
|
+
@input.name = 'yamly'
|
96
|
+
|
97
|
+
@result = @input
|
98
|
+
end
|
99
|
+
|
100
|
+
it_should_behave_like 'identity function'
|
101
|
+
end
|
102
|
+
end
|
57
103
|
end
|
58
104
|
end
|
data/tasks/install.rb
CHANGED
@@ -4,7 +4,7 @@ end
|
|
4
4
|
|
5
5
|
desc "Install #{GEM_NAME} #{GEM_VERSION}"
|
6
6
|
task :install => [ :package ] do
|
7
|
-
sudo_gem "install
|
7
|
+
sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
|
data/tasks/spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
begin
|
2
|
-
gem 'rspec', '~>1.2'
|
3
|
-
require 'spec'
|
4
2
|
require 'spec/rake/spectask'
|
5
3
|
|
6
4
|
task :default => [ :spec ]
|
@@ -8,16 +6,18 @@ begin
|
|
8
6
|
desc 'Run specifications'
|
9
7
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
10
8
|
t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
11
|
-
t.
|
9
|
+
t.libs << 'lib' << 'spec' # needed for CI rake spec task, duplicated in spec_helper
|
12
10
|
|
13
11
|
begin
|
14
|
-
|
12
|
+
require 'rcov'
|
15
13
|
t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
|
16
14
|
t.rcov_opts << '--exclude' << 'spec'
|
17
15
|
t.rcov_opts << '--text-summary'
|
18
16
|
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
19
17
|
rescue LoadError
|
20
18
|
# rcov not installed
|
19
|
+
rescue SyntaxError
|
20
|
+
# rcov syntax invalid
|
21
21
|
end
|
22
22
|
end
|
23
23
|
rescue LoadError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Smoot
|
@@ -9,29 +9,10 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: dm-core
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.11
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: addressable
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.2
|
34
|
-
version:
|
14
|
+
dependencies: []
|
15
|
+
|
35
16
|
description: DataMapper plugin providing extra data types
|
36
17
|
email:
|
37
18
|
- ssmoot [a] gmail [d] com
|
@@ -40,19 +21,20 @@ executables: []
|
|
40
21
|
extensions: []
|
41
22
|
|
42
23
|
extra_rdoc_files:
|
43
|
-
- README.
|
24
|
+
- README.rdoc
|
44
25
|
- LICENSE
|
45
26
|
- TODO
|
46
|
-
- History.
|
27
|
+
- History.rdoc
|
47
28
|
files:
|
48
|
-
- History.
|
29
|
+
- History.rdoc
|
49
30
|
- LICENSE
|
50
31
|
- Manifest.txt
|
51
|
-
- README.
|
32
|
+
- README.rdoc
|
52
33
|
- Rakefile
|
53
34
|
- TODO
|
54
35
|
- lib/dm-types.rb
|
55
36
|
- lib/dm-types/bcrypt_hash.rb
|
37
|
+
- lib/dm-types/comma_separated_list.rb
|
56
38
|
- lib/dm-types/csv.rb
|
57
39
|
- lib/dm-types/enum.rb
|
58
40
|
- lib/dm-types/epoch_time.rb
|
@@ -61,13 +43,21 @@ files:
|
|
61
43
|
- lib/dm-types/ip_address.rb
|
62
44
|
- lib/dm-types/json.rb
|
63
45
|
- lib/dm-types/regexp.rb
|
64
|
-
- lib/dm-types/serial.rb
|
65
46
|
- lib/dm-types/slug.rb
|
66
47
|
- lib/dm-types/uri.rb
|
67
48
|
- lib/dm-types/uuid.rb
|
68
49
|
- lib/dm-types/version.rb
|
69
50
|
- lib/dm-types/yaml.rb
|
51
|
+
- spec/fixtures/article.rb
|
52
|
+
- spec/fixtures/bookmark.rb
|
53
|
+
- spec/fixtures/invention.rb
|
54
|
+
- spec/fixtures/network_node.rb
|
55
|
+
- spec/fixtures/person.rb
|
56
|
+
- spec/fixtures/software_package.rb
|
57
|
+
- spec/fixtures/ticket.rb
|
58
|
+
- spec/fixtures/tshirt.rb
|
70
59
|
- spec/integration/bcrypt_hash_spec.rb
|
60
|
+
- spec/integration/comma_separated_list_spec.rb
|
71
61
|
- spec/integration/enum_spec.rb
|
72
62
|
- spec/integration/file_path_spec.rb
|
73
63
|
- spec/integration/flag_spec.rb
|
@@ -77,6 +67,7 @@ files:
|
|
77
67
|
- spec/integration/uri_spec.rb
|
78
68
|
- spec/integration/uuid_spec.rb
|
79
69
|
- spec/integration/yaml_spec.rb
|
70
|
+
- spec/shared/identity_function_group.rb
|
80
71
|
- spec/spec.opts
|
81
72
|
- spec/spec_helper.rb
|
82
73
|
- spec/unit/bcrypt_hash_spec.rb
|
@@ -93,11 +84,13 @@ files:
|
|
93
84
|
- tasks/install.rb
|
94
85
|
- tasks/spec.rb
|
95
86
|
has_rdoc: true
|
96
|
-
homepage: http://github.com/
|
87
|
+
homepage: http://github.com/datamapper/dm-more/tree/master/dm-types
|
88
|
+
licenses: []
|
89
|
+
|
97
90
|
post_install_message:
|
98
91
|
rdoc_options:
|
99
92
|
- --main
|
100
|
-
- README.
|
93
|
+
- README.rdoc
|
101
94
|
require_paths:
|
102
95
|
- lib
|
103
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -115,9 +108,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
108
|
requirements: []
|
116
109
|
|
117
110
|
rubyforge_project: datamapper
|
118
|
-
rubygems_version: 1.3.
|
111
|
+
rubygems_version: 1.3.5
|
119
112
|
signing_key:
|
120
|
-
specification_version:
|
113
|
+
specification_version: 3
|
121
114
|
summary: DataMapper plugin providing extra data types
|
122
115
|
test_files: []
|
123
116
|
|