dm-types 0.9.9 → 0.9.10

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 CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.9.10 / 2009-01-19
2
+
3
+ * 1 bug fix:
4
+
5
+ * Return empty array for a flag type property when value is nil or <= 0
6
+
7
+ * 2 minor enhancements:
8
+
9
+ * Updated Csv, Json, Yaml types to use a Text primitive rather than
10
+ a String
11
+ * Allow Flag property to be nullable
12
+
1
13
  === 0.9.9 / 2009-01-04
2
14
 
3
15
  * 1 bug fix:
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ AUTHOR = 'Sam Smoot'
12
12
  EMAIL = 'ssmoot [a] gmail [d] com'
13
13
  GEM_NAME = 'dm-types'
14
14
  GEM_VERSION = DataMapper::Types::VERSION
15
- GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"], ['addressable', '~>2.0.1']]
15
+ GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"], ['addressable', '~>2.0.1'], ["bcrypt-ruby", "~>2.0"], ["json", "~>1.1.3"]]
16
16
  GEM_CLEAN = %w[ log pkg coverage ]
17
17
  GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
18
18
 
data/lib/dm-types.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
3
 
4
- gem 'dm-core', '~>0.9.9'
4
+ gem 'dm-core', '~>0.9.10'
5
5
  require 'dm-core'
6
6
 
7
7
  module DataMapper
data/lib/dm-types/csv.rb CHANGED
@@ -1,13 +1,24 @@
1
+ if RUBY_VERSION >= '1.9.0'
2
+ require 'csv'
3
+ else
4
+ begin
5
+ gem 'fastercsv', '~>1.4.0'
6
+ require 'fastercsv'
7
+ CSV = FasterCSV
8
+ rescue LoadError
9
+ nil
10
+ end
11
+ end
12
+
1
13
  module DataMapper
2
14
  module Types
3
15
  class Csv < DataMapper::Type
4
- primitive String
5
- size 65535
16
+ primitive Text
6
17
  lazy true
7
18
 
8
19
  def self.load(value, property)
9
20
  case value
10
- when String then FasterCSV.parse(value)
21
+ when String then CSV.parse(value)
11
22
  when Array then value
12
23
  else nil
13
24
  end
@@ -16,7 +27,7 @@ module DataMapper
16
27
  def self.dump(value, property)
17
28
  case value
18
29
  when Array then
19
- FasterCSV.generate do |csv|
30
+ CSV.generate do |csv|
20
31
  value.each { |row| csv << row }
21
32
  end
22
33
  when String then value
data/lib/dm-types/flag.rb CHANGED
@@ -32,6 +32,7 @@ module DataMapper
32
32
  begin
33
33
  matches = []
34
34
 
35
+ return [] if value.nil? || (value <= 0)
35
36
  0.upto((Math.log(value) / Math.log(2)).ceil) do |i|
36
37
  pow = 2 ** i
37
38
  matches << flag_map[pow] if value & pow == pow
@@ -52,6 +53,7 @@ module DataMapper
52
53
 
53
54
  def self.typecast(value, property)
54
55
  case value
56
+ when nil then nil
55
57
  when Array then value.map {|v| v.to_sym}
56
58
  else value.to_sym
57
59
  end
data/lib/dm-types/json.rb CHANGED
@@ -1,10 +1,16 @@
1
- require 'json'
1
+ begin
2
+ gem "json"
3
+ require "json/ext"
4
+ rescue LoadError
5
+ gem "json_pure"
6
+ require "json/pure"
7
+ end
8
+
2
9
 
3
10
  module DataMapper
4
11
  module Types
5
12
  class Json < DataMapper::Type
6
- primitive String
7
- size 65535
13
+ primitive Text
8
14
  lazy true
9
15
 
10
16
  def self.load(value, property)
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Types
3
- VERSION = '0.9.9'
3
+ VERSION = '0.9.10'
4
4
  end
5
5
  end
data/lib/dm-types/yaml.rb CHANGED
@@ -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)
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::Enum do
5
5
  before(:all) do
6
- class Bug
6
+ class ::Bug
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Integer, :serial => true
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::FilePath do
5
5
  before(:all) do
6
- class FilePathTest
6
+ class ::FilePathTest
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Integer, :serial => true
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::Flag do
5
5
  before(:all) do
6
- class Shirt
6
+ class ::Shirt
7
7
  include DataMapper::Resource
8
8
  property :id, Serial
9
9
  property :sizes, DM::Flag[:xs, :small, :medium, :large, :xl, :xxl]
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::IPAddress do
5
5
  before(:all) do
6
- class IPAddressTest
6
+ class ::IPAddressTest
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Serial
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::Json do
5
5
  before(:all) do
6
- class JsonTest
6
+ class ::JsonTest
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Serial
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'pathname'
2
4
  require 'iconv'
3
5
  require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
@@ -5,7 +7,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
5
7
  describe DataMapper::Types::Slug do
6
8
 
7
9
  before(:all) do
8
- class SlugTest
10
+ class ::SlugTest
9
11
  include DataMapper::Resource
10
12
 
11
13
  property :id, Serial
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::URI do
5
5
  before(:all) do
6
- class URITest
6
+ class ::URITest
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Integer, :serial => true
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
4
  describe DataMapper::Types::Enum do
5
5
  before(:all) do
6
- class YamlTest
6
+ class ::YamlTest
7
7
  include DataMapper::Resource
8
8
 
9
9
  property :id, Serial
@@ -11,7 +11,7 @@ describe DataMapper::Types::Enum do
11
11
  end
12
12
  YamlTest.auto_migrate!
13
13
 
14
- class SerializeMe
14
+ class ::SerializeMe
15
15
  attr_accessor :name
16
16
  end
17
17
  end
@@ -1,16 +1,14 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
3
3
 
4
- require 'fastercsv'
5
-
6
4
  describe DataMapper::Types::Csv, ".load" do
7
5
  it 'should parse the value if a string is provided' do
8
- FasterCSV.should_receive(:parse).with('csv_string').once
6
+ CSV.should_receive(:parse).with('csv_string').once
9
7
  DataMapper::Types::Csv.load('csv_string', :property)
10
8
  end
11
9
 
12
10
  it 'should do nothing if the value is a string' do
13
- FasterCSV.should_not_receive(:parse)
11
+ CSV.should_not_receive(:parse)
14
12
  DataMapper::Types::Csv.load([], :property).should == []
15
13
  end
16
14
 
@@ -26,7 +24,7 @@ describe DataMapper::Types::Csv, ".dump" do
26
24
  end
27
25
 
28
26
  it 'should do nothing if the value is a string' do
29
- FasterCSV.should_not_receive(:generate)
27
+ CSV.should_not_receive(:generate)
30
28
  DataMapper::Types::Csv.dump('string', :property).should == 'string'
31
29
  end
32
30
 
data/tasks/spec.rb CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  desc 'Run specifications'
9
9
  Spec::Rake::SpecTask.new(:spec) do |t|
10
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)
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s).map { |f| f.to_s }
12
12
 
13
13
  begin
14
14
  gem 'rcov', '~>0.8'
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.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Smoot
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-04 00:00:00 -08:00
12
+ date: 2009-01-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.9
23
+ version: 0.9.10
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable
@@ -32,6 +32,26 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.0.1
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: bcrypt-ruby
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: "2.0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.3
54
+ version:
35
55
  description: DataMapper plugin providing extra data types
36
56
  email:
37
57
  - ssmoot [a] gmail [d] com