dm-types 0.10.2 → 1.0.0.rc1

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.
Files changed (58) hide show
  1. data/.gitignore +36 -0
  2. data/Gemfile +147 -0
  3. data/Rakefile +7 -8
  4. data/VERSION +1 -1
  5. data/dm-types.gemspec +61 -20
  6. data/lib/dm-types.rb +24 -19
  7. data/lib/dm-types/bcrypt_hash.rb +17 -13
  8. data/lib/dm-types/comma_separated_list.rb +11 -16
  9. data/lib/dm-types/csv.rb +11 -11
  10. data/lib/dm-types/enum.rb +33 -50
  11. data/lib/dm-types/epoch_time.rb +11 -11
  12. data/lib/dm-types/file_path.rb +13 -10
  13. data/lib/dm-types/flag.rb +17 -25
  14. data/lib/dm-types/ip_address.rb +15 -11
  15. data/lib/dm-types/json.rb +17 -14
  16. data/lib/dm-types/paranoid/base.rb +38 -0
  17. data/lib/dm-types/paranoid_boolean.rb +23 -0
  18. data/lib/dm-types/paranoid_datetime.rb +22 -0
  19. data/lib/dm-types/regexp.rb +8 -8
  20. data/lib/dm-types/slug.rb +7 -12
  21. data/lib/dm-types/uri.rb +21 -9
  22. data/lib/dm-types/uuid.rb +18 -11
  23. data/lib/dm-types/yaml.rb +12 -10
  24. data/spec/fixtures/article.rb +0 -2
  25. data/spec/fixtures/bookmark.rb +0 -2
  26. data/spec/fixtures/network_node.rb +0 -2
  27. data/spec/fixtures/person.rb +0 -2
  28. data/spec/fixtures/software_package.rb +0 -2
  29. data/spec/fixtures/ticket.rb +2 -4
  30. data/spec/fixtures/tshirt.rb +3 -5
  31. data/spec/integration/bcrypt_hash_spec.rb +33 -31
  32. data/spec/integration/comma_separated_list_spec.rb +55 -53
  33. data/spec/integration/enum_spec.rb +55 -53
  34. data/spec/integration/file_path_spec.rb +105 -103
  35. data/spec/integration/flag_spec.rb +42 -40
  36. data/spec/integration/ip_address_spec.rb +91 -89
  37. data/spec/integration/json_spec.rb +41 -39
  38. data/spec/integration/slug_spec.rb +36 -34
  39. data/spec/integration/uri_spec.rb +82 -79
  40. data/spec/integration/uuid_spec.rb +63 -61
  41. data/spec/integration/yaml_spec.rb +37 -35
  42. data/spec/spec_helper.rb +7 -36
  43. data/spec/unit/bcrypt_hash_spec.rb +18 -10
  44. data/spec/unit/csv_spec.rb +92 -80
  45. data/spec/unit/enum_spec.rb +27 -42
  46. data/spec/unit/epoch_time_spec.rb +18 -7
  47. data/spec/unit/file_path_spec.rb +15 -10
  48. data/spec/unit/flag_spec.rb +13 -36
  49. data/spec/unit/ip_address_spec.rb +13 -10
  50. data/spec/unit/json_spec.rb +21 -14
  51. data/spec/unit/paranoid_boolean_spec.rb +138 -0
  52. data/spec/unit/paranoid_datetime_spec.rb +143 -0
  53. data/spec/unit/regexp_spec.rb +15 -5
  54. data/spec/unit/uri_spec.rb +13 -9
  55. data/spec/unit/yaml_spec.rb +16 -9
  56. data/tasks/local_gemfile.rake +18 -0
  57. data/tasks/spec.rake +0 -3
  58. metadata +122 -52
@@ -2,24 +2,31 @@ require 'spec_helper'
2
2
  require 'shared/identity_function_group'
3
3
 
4
4
  try_spec do
5
- describe DataMapper::Types::Yaml do
5
+
6
+ require './spec/fixtures/person'
7
+
8
+ describe DataMapper::Property::Yaml do
9
+ before :all do
10
+ @property = DataMapper::Types::Fixtures::Person.properties[:inventions]
11
+ end
12
+
6
13
  describe '.load' do
7
14
  describe 'when nil is provided' do
8
15
  it 'returns nil' do
9
- DataMapper::Types::Yaml.load(nil, :property).should be_nil
16
+ @property.load(nil).should be_nil
10
17
  end
11
18
  end
12
19
 
13
20
  describe 'when YAML encoded primitive string is provided' do
14
21
  it 'returns decoded value as Ruby string' do
15
- DataMapper::Types::Yaml.load("--- yaml string\n", :property).should == 'yaml string'
22
+ @property.load("--- yaml string\n").should == 'yaml string'
16
23
  end
17
24
  end
18
25
 
19
26
  describe 'when something else is provided' do
20
27
  it 'raises ArgumentError with a meaningful message' do
21
28
  lambda {
22
- DataMapper::Types::Yaml.load(:sym, :property)
29
+ @property.load(:sym)
23
30
  }.should raise_error(ArgumentError, '+value+ of a property of YAML type must be nil or a String')
24
31
  end
25
32
  end
@@ -28,31 +35,31 @@ try_spec do
28
35
  describe '.dump' do
29
36
  describe 'when nil is provided' do
30
37
  it 'returns nil' do
31
- DataMapper::Types::Yaml.dump(nil, :property).should be_nil
38
+ @property.dump(nil).should be_nil
32
39
  end
33
40
  end
34
41
 
35
42
  describe 'when YAML encoded primitive string is provided' do
36
43
  it 'does not do double encoding' do
37
- DataMapper::Types::Yaml.dump("--- yaml encoded string\n", :property).should == "--- yaml encoded string\n"
44
+ @property.dump("--- yaml encoded string\n").should == "--- yaml encoded string\n"
38
45
  end
39
46
  end
40
47
 
41
48
  describe 'when regular Ruby string is provided' do
42
49
  it 'dumps argument to YAML' do
43
- DataMapper::Types::Yaml.dump('dump me (to yaml)', :property).should == "--- dump me (to yaml)\n"
50
+ @property.dump('dump me (to yaml)').should == "--- dump me (to yaml)\n"
44
51
  end
45
52
  end
46
53
 
47
54
  describe 'when Ruby array is provided' do
48
55
  it 'dumps argument to YAML' do
49
- DataMapper::Types::Yaml.dump([1, 2, 3], :property).should == "--- \n- 1\n- 2\n- 3\n"
56
+ @property.dump([1, 2, 3]).should == "--- \n- 1\n- 2\n- 3\n"
50
57
  end
51
58
  end
52
59
 
53
60
  describe 'when Ruby hash is provided' do
54
61
  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"
62
+ @property.dump({ :datamapper => 'Data access layer in Ruby' }).should == "--- \n:datamapper: Data access layer in Ruby\n"
56
63
  end
57
64
  end
58
65
  end
@@ -0,0 +1,18 @@
1
+ desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
2
+ task :local_gemfile do |t|
3
+
4
+ root = Pathname(__FILE__).dirname.parent
5
+ datamapper = root.parent
6
+
7
+ source_regex = /DATAMAPPER = 'git:\/\/github.com\/datamapper'/
8
+ gem_source_regex = /:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/
9
+
10
+ root.join('Gemfile.local').open('w') do |f|
11
+ root.join('Gemfile').open.each do |line|
12
+ line.sub!(source_regex, "DATAMAPPER = '#{datamapper}'")
13
+ line.sub!(gem_source_regex, ':path => "#{DATAMAPPER}/\1"')
14
+ f.puts line
15
+ end
16
+ end
17
+
18
+ end
@@ -35,7 +35,4 @@ rescue LoadError
35
35
  end
36
36
  end
37
37
 
38
- task :spec => :check_dependencies
39
- task :rcov => :check_dependencies
40
-
41
38
  task :default => :spec
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-types
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ prerelease: true
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ - rc1
10
+ version: 1.0.0.rc1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Dan Kubb
@@ -9,89 +15,108 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-11 00:00:00 -08:00
18
+ date: 2010-05-19 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bcrypt-ruby
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 2.1.2
24
- version:
25
21
  - !ruby/object:Gem::Dependency
26
22
  name: dm-core
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
30
25
  requirements:
31
26
  - - ~>
32
27
  - !ruby/object:Gem::Version
33
- version: 0.10.2
34
- version:
28
+ segments:
29
+ - 1
30
+ - 0
31
+ - 0
32
+ - rc1
33
+ version: 1.0.0.rc1
34
+ type: :runtime
35
+ version_requirements: *id001
35
36
  - !ruby/object:Gem::Dependency
36
37
  name: fastercsv
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 5
46
+ - 0
43
47
  version: 1.5.0
44
- version:
48
+ type: :runtime
49
+ version_requirements: *id002
45
50
  - !ruby/object:Gem::Dependency
46
51
  name: json_pure
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
50
54
  requirements:
51
55
  - - ~>
52
56
  - !ruby/object:Gem::Version
53
- version: 1.2.0
54
- version:
57
+ segments:
58
+ - 1
59
+ - 4
60
+ - 3
61
+ version: 1.4.3
62
+ type: :runtime
63
+ version_requirements: *id003
55
64
  - !ruby/object:Gem::Dependency
56
65
  name: uuidtools
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
60
68
  requirements:
61
69
  - - ~>
62
70
  - !ruby/object:Gem::Version
71
+ segments:
72
+ - 2
73
+ - 1
74
+ - 1
63
75
  version: 2.1.1
64
- version:
76
+ type: :runtime
77
+ version_requirements: *id004
65
78
  - !ruby/object:Gem::Dependency
66
79
  name: stringex
67
- type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
70
82
  requirements:
71
83
  - - ~>
72
84
  - !ruby/object:Gem::Version
85
+ segments:
86
+ - 1
87
+ - 1
88
+ - 0
73
89
  version: 1.1.0
74
- version:
90
+ type: :runtime
91
+ version_requirements: *id005
75
92
  - !ruby/object:Gem::Dependency
76
93
  name: rspec
77
- type: :development
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
80
96
  requirements:
81
97
  - - ~>
82
98
  - !ruby/object:Gem::Version
83
- version: 1.2.9
84
- version:
85
- - !ruby/object:Gem::Dependency
86
- name: yard
99
+ segments:
100
+ - 1
101
+ - 3
102
+ version: "1.3"
87
103
  type: :development
88
- version_requirement:
89
- version_requirements: !ruby/object:Gem::Requirement
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: dm-validations
107
+ prerelease: false
108
+ requirement: &id007 !ruby/object:Gem::Requirement
90
109
  requirements:
91
110
  - - ~>
92
111
  - !ruby/object:Gem::Version
93
- version: 0.4.0
94
- version:
112
+ segments:
113
+ - 1
114
+ - 0
115
+ - 0
116
+ - rc1
117
+ version: 1.0.0.rc1
118
+ type: :development
119
+ version_requirements: *id007
95
120
  description: DataMapper plugin providing extra data types
96
121
  email: dan.kubb [a] gmail [d] com
97
122
  executables: []
@@ -102,6 +127,8 @@ extra_rdoc_files:
102
127
  - LICENSE
103
128
  - README.rdoc
104
129
  files:
130
+ - .gitignore
131
+ - Gemfile
105
132
  - LICENSE
106
133
  - README.rdoc
107
134
  - Rakefile
@@ -117,6 +144,9 @@ files:
117
144
  - lib/dm-types/flag.rb
118
145
  - lib/dm-types/ip_address.rb
119
146
  - lib/dm-types/json.rb
147
+ - lib/dm-types/paranoid/base.rb
148
+ - lib/dm-types/paranoid_boolean.rb
149
+ - lib/dm-types/paranoid_datetime.rb
120
150
  - lib/dm-types/regexp.rb
121
151
  - lib/dm-types/slug.rb
122
152
  - lib/dm-types/uri.rb
@@ -153,10 +183,13 @@ files:
153
183
  - spec/unit/flag_spec.rb
154
184
  - spec/unit/ip_address_spec.rb
155
185
  - spec/unit/json_spec.rb
186
+ - spec/unit/paranoid_boolean_spec.rb
187
+ - spec/unit/paranoid_datetime_spec.rb
156
188
  - spec/unit/regexp_spec.rb
157
189
  - spec/unit/uri_spec.rb
158
190
  - spec/unit/yaml_spec.rb
159
191
  - tasks/ci.rake
192
+ - tasks/local_gemfile.rake
160
193
  - tasks/metrics.rake
161
194
  - tasks/spec.rake
162
195
  - tasks/yard.rake
@@ -174,20 +207,57 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
207
  requirements:
175
208
  - - ">="
176
209
  - !ruby/object:Gem::Version
210
+ segments:
211
+ - 0
177
212
  version: "0"
178
- version:
179
213
  required_rubygems_version: !ruby/object:Gem::Requirement
180
214
  requirements:
181
- - - ">="
215
+ - - ">"
182
216
  - !ruby/object:Gem::Version
183
- version: "0"
184
- version:
217
+ segments:
218
+ - 1
219
+ - 3
220
+ - 1
221
+ version: 1.3.1
185
222
  requirements: []
186
223
 
187
224
  rubyforge_project: datamapper
188
- rubygems_version: 1.3.5
225
+ rubygems_version: 1.3.6
189
226
  signing_key:
190
227
  specification_version: 3
191
228
  summary: DataMapper plugin providing extra data types
192
- test_files: []
193
-
229
+ test_files:
230
+ - spec/fixtures/article.rb
231
+ - spec/fixtures/bookmark.rb
232
+ - spec/fixtures/invention.rb
233
+ - spec/fixtures/network_node.rb
234
+ - spec/fixtures/person.rb
235
+ - spec/fixtures/software_package.rb
236
+ - spec/fixtures/ticket.rb
237
+ - spec/fixtures/tshirt.rb
238
+ - spec/integration/bcrypt_hash_spec.rb
239
+ - spec/integration/comma_separated_list_spec.rb
240
+ - spec/integration/enum_spec.rb
241
+ - spec/integration/file_path_spec.rb
242
+ - spec/integration/flag_spec.rb
243
+ - spec/integration/ip_address_spec.rb
244
+ - spec/integration/json_spec.rb
245
+ - spec/integration/slug_spec.rb
246
+ - spec/integration/uri_spec.rb
247
+ - spec/integration/uuid_spec.rb
248
+ - spec/integration/yaml_spec.rb
249
+ - spec/shared/identity_function_group.rb
250
+ - spec/spec_helper.rb
251
+ - spec/unit/bcrypt_hash_spec.rb
252
+ - spec/unit/csv_spec.rb
253
+ - spec/unit/enum_spec.rb
254
+ - spec/unit/epoch_time_spec.rb
255
+ - spec/unit/file_path_spec.rb
256
+ - spec/unit/flag_spec.rb
257
+ - spec/unit/ip_address_spec.rb
258
+ - spec/unit/json_spec.rb
259
+ - spec/unit/paranoid_boolean_spec.rb
260
+ - spec/unit/paranoid_datetime_spec.rb
261
+ - spec/unit/regexp_spec.rb
262
+ - spec/unit/uri_spec.rb
263
+ - spec/unit/yaml_spec.rb