mack-data_mapper 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/idna.rb +0 -0
  2. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/uri.rb +62 -21
  3. data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/version.rb +1 -1
  4. data/lib/gems/addressable-2.0.1/tasks/clobber.rake +2 -0
  5. data/lib/gems/addressable-2.0.1/tasks/gem.rake +68 -0
  6. data/lib/gems/addressable-2.0.1/tasks/git.rake +40 -0
  7. data/lib/gems/addressable-2.0.1/tasks/metrics.rake +22 -0
  8. data/lib/gems/addressable-2.0.1/tasks/rdoc.rake +29 -0
  9. data/lib/gems/addressable-2.0.1/tasks/rubyforge.rake +89 -0
  10. data/lib/gems/addressable-2.0.1/tasks/spec.rake +64 -0
  11. data/lib/gems/data_objects-0.9.10.1/lib/data_objects.rb +46 -0
  12. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/command.rb +30 -0
  13. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/connection.rb +107 -0
  14. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/field.rb +19 -0
  15. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/logger.rb +233 -0
  16. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb +103 -0
  17. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/reader.rb +22 -0
  18. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/result.rb +13 -0
  19. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb +45 -0
  20. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/uri.rb +34 -0
  21. data/lib/gems/data_objects-0.9.10.1/lib/data_objects/version.rb +3 -0
  22. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates.rb +1 -1
  23. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/adapters/data_objects_adapter.rb +0 -0
  24. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/aggregate_functions.rb +0 -0
  25. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/collection.rb +4 -0
  26. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/model.rb +4 -0
  27. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/repository.rb +0 -0
  28. data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/support/symbol.rb +0 -0
  29. data/lib/gems/dm-aggregates-0.9.9/lib/dm-aggregates/version.rb +5 -0
  30. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core.rb +5 -5
  31. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters.rb +0 -0
  32. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/abstract_adapter.rb +0 -0
  33. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/data_objects_adapter.rb +1 -1
  34. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/in_memory_adapter.rb +0 -0
  35. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/mysql_adapter.rb +1 -1
  36. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/postgres_adapter.rb +1 -1
  37. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
  38. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations.rb +0 -0
  39. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_many.rb +0 -0
  40. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_one.rb +1 -1
  41. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_many.rb +3 -6
  42. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_one.rb +0 -0
  43. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship.rb +0 -0
  44. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship_chain.rb +0 -0
  45. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/auto_migrations.rb +0 -0
  46. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/collection.rb +26 -0
  47. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/dependency_queue.rb +0 -0
  48. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/hook.rb +0 -0
  49. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/identity_map.rb +0 -0
  50. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/is.rb +0 -0
  51. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/logger.rb +0 -0
  52. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrations/destructive_migrations.rb +0 -0
  53. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrator.rb +0 -0
  54. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/model.rb +29 -3
  55. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/naming_conventions.rb +0 -0
  56. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property.rb +13 -0
  57. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property_set.rb +0 -0
  58. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/query.rb +51 -3
  59. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/repository.rb +8 -0
  60. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/resource.rb +19 -6
  61. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/scope.rb +0 -0
  62. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support.rb +0 -0
  63. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/array.rb +0 -0
  64. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/assertions.rb +0 -0
  65. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/errors.rb +0 -0
  66. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/kernel.rb +0 -0
  67. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/symbol.rb +0 -0
  68. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/transaction.rb +0 -0
  69. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type.rb +0 -0
  70. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type_map.rb +0 -0
  71. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types.rb +0 -0
  72. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/boolean.rb +0 -0
  73. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/discriminator.rb +0 -0
  74. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/object.rb +0 -0
  75. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_boolean.rb +0 -0
  76. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_datetime.rb +0 -0
  77. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/serial.rb +0 -0
  78. data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/text.rb +0 -0
  79. data/lib/gems/dm-core-0.9.9/lib/dm-core/version.rb +3 -0
  80. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations.rb +0 -0
  81. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations/version.rb +1 -1
  82. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration.rb +5 -3
  83. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration_runner.rb +0 -0
  84. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/example/migration_example_group.rb +0 -0
  85. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/matchers/migration_matchers.rb +0 -0
  86. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql.rb +0 -0
  87. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/column.rb +0 -0
  88. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/mysql.rb +0 -0
  89. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/postgresql.rb +0 -0
  90. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/sqlite3.rb +0 -0
  91. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table.rb +0 -0
  92. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_creator.rb +0 -0
  93. data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_modifier.rb +0 -0
  94. data/lib/gems/dm-migrations-0.9.9/tasks/db.rb +22 -0
  95. data/lib/gems/dm-migrations-0.9.9/tasks/install.rb +13 -0
  96. data/lib/gems/dm-migrations-0.9.9/tasks/spec.rb +25 -0
  97. data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer.rb +1 -1
  98. data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer/version.rb +1 -1
  99. data/lib/gems/dm-observer-0.9.9/tasks/install.rb +13 -0
  100. data/lib/gems/dm-observer-0.9.9/tasks/spec.rb +25 -0
  101. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer.rb +4 -0
  102. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb +24 -0
  103. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_csv.rb +35 -0
  104. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_json.rb +73 -0
  105. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_xml.rb +61 -0
  106. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_yaml.rb +48 -0
  107. data/lib/gems/{dm-serializer-0.9.7 → dm-serializer-0.9.9}/lib/dm-serializer/version.rb +1 -1
  108. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers.rb +17 -0
  109. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb +29 -0
  110. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb +28 -0
  111. data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb +23 -0
  112. data/lib/gems/dm-serializer-0.9.9/tasks/install.rb +13 -0
  113. data/lib/gems/dm-serializer-0.9.9/tasks/spec.rb +25 -0
  114. data/lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb +58 -0
  115. data/lib/gems/{dm-timestamps-0.9.7 → dm-timestamps-0.9.9}/lib/dm-timestamps/version.rb +1 -1
  116. data/lib/gems/dm-timestamps-0.9.9/tasks/install.rb +13 -0
  117. data/lib/gems/dm-timestamps-0.9.9/tasks/spec.rb +25 -0
  118. data/lib/gems/dm-types-0.9.9/lib/dm-types.rb +26 -0
  119. data/lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb +33 -0
  120. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/csv.rb +0 -0
  121. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/enum.rb +4 -4
  122. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/epoch_time.rb +0 -0
  123. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/file_path.rb +0 -0
  124. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/flag.rb +0 -0
  125. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/ip_address.rb +0 -0
  126. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/json.rb +3 -6
  127. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/regexp.rb +0 -0
  128. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/serial.rb +0 -0
  129. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/slug.rb +0 -0
  130. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uri.rb +2 -0
  131. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uuid.rb +3 -0
  132. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/version.rb +1 -1
  133. data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/yaml.rb +1 -2
  134. data/lib/gems/dm-types-0.9.9/tasks/install.rb +13 -0
  135. data/lib/gems/dm-types-0.9.9/tasks/spec.rb +25 -0
  136. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations.rb +1 -1
  137. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/absent_field_validator.rb +0 -0
  138. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/acceptance_validator.rb +0 -0
  139. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/auto_validate.rb +0 -0
  140. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/block_validator.rb +0 -0
  141. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/confirmation_validator.rb +0 -0
  142. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/contextual_validators.rb +2 -3
  143. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/custom_validator.rb +0 -0
  144. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/format_validator.rb +0 -0
  145. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/email.rb +1 -0
  146. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/url.rb +0 -0
  147. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/generic_validator.rb +0 -0
  148. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/length_validator.rb +0 -0
  149. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/method_validator.rb +0 -0
  150. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/numeric_validator.rb +0 -0
  151. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/primitive_validator.rb +0 -0
  152. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/required_field_validator.rb +0 -0
  153. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/support/object.rb +0 -0
  154. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/uniqueness_validator.rb +1 -1
  155. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/validation_errors.rb +0 -0
  156. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/version.rb +1 -1
  157. data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/within_validator.rb +0 -0
  158. data/lib/gems/dm-validations-0.9.9/tasks/install.rb +13 -0
  159. data/lib/gems/dm-validations-0.9.9/tasks/spec.rb +25 -0
  160. data/lib/gems/json_pure-1.1.3/tools/fuzz.rb +140 -0
  161. data/lib/gems/json_pure-1.1.3/tools/server.rb +62 -0
  162. data/lib/mack-data_mapper/dm_patches/migrations.rb +22 -1
  163. data/lib/mack-data_mapper/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +1 -1
  164. metadata +216 -172
  165. data/lib/gems/dm-aggregates-0.9.7/lib/dm-aggregates/version.rb +0 -7
  166. data/lib/gems/dm-core-0.9.7/lib/dm-core/version.rb +0 -3
  167. data/lib/gems/dm-core-0.9.7/script/all +0 -5
  168. data/lib/gems/dm-core-0.9.7/script/performance.rb +0 -284
  169. data/lib/gems/dm-core-0.9.7/script/profile.rb +0 -87
  170. data/lib/gems/dm-serializer-0.9.7/lib/dm-serializer.rb +0 -183
  171. data/lib/gems/dm-timestamps-0.9.7/lib/dm-timestamps.rb +0 -57
  172. data/lib/gems/dm-types-0.9.7/lib/dm-types.rb +0 -28
  173. data/lib/gems/dm-types-0.9.7/lib/dm-types/bcrypt_hash.rb +0 -31
  174. data/lib/gems/json_pure-1.1.3/GPL +0 -340
  175. data/lib/gems/uuidtools-1.0.3/lib/uuidtools.rb +0 -648
  176. data/lib/gems/uuidtools-1.0.3/lib/uuidtools/version.rb +0 -32
@@ -13,14 +13,12 @@ module DataMapper
13
13
  elsif value.is_a?(String)
14
14
  ::JSON.load(value)
15
15
  else
16
- raise ArgumentError.new("+value+ must be nil or a String")
16
+ raise ArgumentError, '+value+ must be nil or a String'
17
17
  end
18
18
  end
19
19
 
20
20
  def self.dump(value, property)
21
- if value.nil?
22
- nil
23
- elsif value.is_a?(String)
21
+ if value.nil? || value.is_a?(String)
24
22
  value
25
23
  else
26
24
  ::JSON.dump(value)
@@ -28,8 +26,7 @@ module DataMapper
28
26
  end
29
27
 
30
28
  def self.typecast(value, property)
31
- # Arrays and hashes are left alone, while strings are parsed as JSON.
32
- if value.kind_of?(Array) || value.kind_of?(Hash)
29
+ if value.nil? || value.kind_of?(Array) || value.kind_of?(Hash)
33
30
  value
34
31
  else
35
32
  ::JSON.load(value.to_s)
@@ -1,4 +1,6 @@
1
1
  require 'rubygems'
2
+
3
+ gem 'addressable', '~>2.0.1'
2
4
  require 'addressable/uri'
3
5
 
4
6
  module DataMapper
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ gem 'uuidtools', '~>1.0.7'
1
4
  require 'uuidtools'
2
5
 
3
6
  module DataMapper
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Types
3
- VERSION = "0.9.7"
3
+ VERSION = '0.9.9'
4
4
  end
5
5
  end
@@ -3,8 +3,7 @@ require 'yaml'
3
3
  module DataMapper
4
4
  module Types
5
5
  class Yaml < DataMapper::Type
6
- primitive String
7
- size 65535
6
+ primitive Text
8
7
  lazy true
9
8
 
10
9
  def self.load(value, property)
@@ -0,0 +1,13 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
+ task :install => [ :package ] do
7
+ sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
+ end
9
+
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
+ end
@@ -0,0 +1,25 @@
1
+ begin
2
+ gem 'rspec', '~>1.1.11'
3
+ require 'spec'
4
+ require 'spec/rake/spectask'
5
+
6
+ task :default => [ :spec ]
7
+
8
+ desc 'Run specifications'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
12
+
13
+ begin
14
+ gem 'rcov', '~>0.8'
15
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
+ t.rcov_opts << '--exclude' << 'spec'
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ rescue LoadError
20
+ # rcov not installed
21
+ end
22
+ end
23
+ rescue LoadError
24
+ # rspec not installed
25
+ end
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'pathname'
3
3
 
4
- gem 'dm-core', '~>0.9.7'
4
+ gem 'dm-core', '~>0.9.9'
5
5
  require 'dm-core'
6
6
 
7
7
  dir = Pathname(__FILE__).dirname.expand_path / 'dm-validations'
@@ -17,15 +17,14 @@ module DataMapper
17
17
  #
18
18
  # @return <Hash> a hash of validators <GenericValidator>
19
19
  def contexts
20
- @contexts ||= @contexts = {}
20
+ @contexts ||= {}
21
21
  end
22
22
 
23
23
  # Return an array of validators for a named context
24
24
  #
25
25
  # @return <Array> An array of validators
26
26
  def context(name)
27
- contexts[name] = [] unless contexts.has_key?(name)
28
- contexts[name]
27
+ contexts[name] ||= []
29
28
  end
30
29
 
31
30
  # Clear all named context validators off of the resource
@@ -9,6 +9,7 @@ module DataMapper
9
9
  )
10
10
  end
11
11
 
12
+ # RFC2822 (No attribution reference available)
12
13
  EmailAddress = begin
13
14
  alpha = "a-zA-Z"
14
15
  digit = "0-9"
@@ -6,7 +6,7 @@ module DataMapper
6
6
  # @author Guy van den Berg
7
7
  # @since 0.9
8
8
  class UniquenessValidator < GenericValidator
9
- include Assertions
9
+ include Extlib::Assertions
10
10
 
11
11
  def initialize(field_name, options = {})
12
12
  assert_kind_of 'scope', options[:scope], Array, Symbol if options.has_key?(:scope)
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Validations
3
- VERSION = "0.9.7"
3
+ VERSION = '0.9.9'
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
+ task :install => [ :package ] do
7
+ sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
+ end
9
+
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
+ end
@@ -0,0 +1,25 @@
1
+ begin
2
+ gem 'rspec', '~>1.1.11'
3
+ require 'spec'
4
+ require 'spec/rake/spectask'
5
+
6
+ task :default => [ :spec ]
7
+
8
+ desc 'Run specifications'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
12
+
13
+ begin
14
+ gem 'rcov', '~>0.8'
15
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
+ t.rcov_opts << '--exclude' << 'spec'
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ rescue LoadError
20
+ # rcov not installed
21
+ end
22
+ end
23
+ rescue LoadError
24
+ # rspec not installed
25
+ end
@@ -0,0 +1,140 @@
1
+ $KCODE='UTF8'
2
+ require 'json'
3
+
4
+ require 'iconv'
5
+ ISO_8859_1_TO_UTF8 = Iconv.new('utf-8', 'iso-8859-15')
6
+ class ::String
7
+ def to_utf8
8
+ ISO_8859_1_TO_UTF8.iconv self
9
+ end
10
+ end
11
+
12
+ class Fuzzer
13
+ def initialize(n, freqs = {})
14
+ sum = freqs.inject(0.0) { |s, x| s + x.last }
15
+ freqs.each_key { |x| freqs[x] /= sum }
16
+ s = 0.0
17
+ freqs.each_key do |x|
18
+ freqs[x] = s .. (s + t = freqs[x])
19
+ s += t
20
+ end
21
+ @freqs = freqs
22
+ @n = n
23
+ @alpha = (0..0xff).to_a
24
+ end
25
+
26
+ def random_string
27
+ s = ''
28
+ 30.times { s << @alpha[rand(@alpha.size)] }
29
+ s.to_utf8
30
+ end
31
+
32
+ def pick
33
+ r = rand
34
+ found = @freqs.find { |k, f| f.include? rand }
35
+ found && found.first
36
+ end
37
+
38
+ def make_pick
39
+ k = pick
40
+ case
41
+ when k == Hash, k == Array
42
+ k.new
43
+ when k == true, k == false, k == nil
44
+ k
45
+ when k == String
46
+ random_string
47
+ when k == Fixnum
48
+ rand(2 ** 30) - 2 ** 29
49
+ when k == Bignum
50
+ rand(2 ** 70) - 2 ** 69
51
+ end
52
+ end
53
+
54
+ def fuzz(current = nil)
55
+ if @n > 0
56
+ case current
57
+ when nil
58
+ @n -= 1
59
+ current = fuzz [ Hash, Array ][rand(2)].new
60
+ when Array
61
+ while @n > 0
62
+ @n -= 1
63
+ current << case p = make_pick
64
+ when Array, Hash
65
+ fuzz(p)
66
+ else
67
+ p
68
+ end
69
+ end
70
+ when Hash
71
+ while @n > 0
72
+ @n -= 1
73
+ current[random_string] = case p = make_pick
74
+ when Array, Hash
75
+ fuzz(p)
76
+ else
77
+ p
78
+ end
79
+ end
80
+ end
81
+ end
82
+ current
83
+ end
84
+ end
85
+
86
+ class MyState < JSON.state
87
+ WS = " \r\t\n"
88
+
89
+ def initialize
90
+ super(
91
+ :indent => make_spaces,
92
+ :space => make_spaces,
93
+ :space_before => make_spaces,
94
+ :object_nl => make_spaces,
95
+ :array_nl => make_spaces,
96
+ :max_nesting => false
97
+ )
98
+ end
99
+
100
+ def make_spaces
101
+ s = ''
102
+ rand(1).times { s << WS[rand(WS.size)] }
103
+ s
104
+ end
105
+ end
106
+
107
+ n = (ARGV.shift || 500).to_i
108
+ loop do
109
+ fuzzer = Fuzzer.new(n,
110
+ Hash => 25,
111
+ Array => 25,
112
+ String => 10,
113
+ Fixnum => 10,
114
+ Bignum => 10,
115
+ nil => 5,
116
+ true => 5,
117
+ false => 5
118
+ )
119
+ o1 = fuzzer.fuzz
120
+ json = JSON.generate o1, MyState.new
121
+ if $DEBUG
122
+ puts "-" * 80
123
+ puts json, json.size
124
+ else
125
+ puts json.size
126
+ end
127
+ begin
128
+ o2 = JSON.parse(json, :max_nesting => false)
129
+ rescue JSON::ParserError => e
130
+ puts "Caught #{e.class}: #{e.message}\n#{e.backtrace * "\n"}"
131
+ puts "o1 = #{o1.inspect}", "json = #{json}", "json_str = #{json.inspect}"
132
+ puts "locals = #{local_variables.inspect}"
133
+ exit
134
+ end
135
+ if o1 != o2
136
+ puts "mismatch", "o1 = #{o1.inspect}", "o2 = #{o2.inspect}",
137
+ "json = #{json}", "json_str = #{json.inspect}"
138
+ puts "locals = #{local_variables.inspect}"
139
+ end
140
+ end
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $KCODE='UTF8'
4
+ require 'webrick'
5
+ include WEBrick
6
+ $:.unshift 'ext'
7
+ $:.unshift 'lib'
8
+ require 'json'
9
+
10
+ class JSONServlet < HTTPServlet::AbstractServlet
11
+ @@count = 1
12
+
13
+ def do_GET(req, res)
14
+ obj = {
15
+ "TIME" => Time.now.strftime("%FT%T"),
16
+ "foo" => "Bär",
17
+ "bar" => "© ≠ €!",
18
+ 'a' => 2,
19
+ 'b' => 3.141,
20
+ 'COUNT' => @@count += 1,
21
+ 'c' => 'c',
22
+ 'd' => [ 1, "b", 3.14 ],
23
+ 'e' => { 'foo' => 'bar' },
24
+ 'g' => "松本行弘",
25
+ 'h' => 1000.0,
26
+ 'i' => 0.001,
27
+ 'j' => "\xf0\xa0\x80\x81",
28
+ }
29
+ res.body = JSON.generate obj
30
+ res['Content-Type'] = "application/json"
31
+ end
32
+ end
33
+
34
+ def create_server(err, dir, port)
35
+ dir = File.expand_path(dir)
36
+ err.puts "Surf to:", "http://#{Socket.gethostname}:#{port}"
37
+
38
+ s = HTTPServer.new(
39
+ :Port => port,
40
+ :DocumentRoot => dir,
41
+ :Logger => WEBrick::Log.new(err),
42
+ :AccessLog => [
43
+ [ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
44
+ [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
45
+ [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ]
46
+ ]
47
+ )
48
+ s.mount("/json", JSONServlet)
49
+ s
50
+ end
51
+
52
+ default_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
53
+ dir = ARGV.shift || default_dir
54
+ port = (ARGV.shift || 6666).to_i
55
+ s = create_server(STDERR, dir, 6666)
56
+ t = Thread.new { s.start }
57
+ trap(:INT) do
58
+ s.shutdown
59
+ t.join
60
+ exit
61
+ end
62
+ sleep