valuable 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8e6611d7f14d540de2e9af5e14f5c361f231867
4
- data.tar.gz: 6f41e3ca7e14c92be80f48f4ecdbd707e6218137
3
+ metadata.gz: da8784960fceb040aaabcb25475c849731245869
4
+ data.tar.gz: 184e99edcf813a8bc0870d96588d0ac131d26698
5
5
  SHA512:
6
- metadata.gz: 028179bc5fb3c9a23d0b6cb42f18857fa78687ff7a3f80711bafe09853e6ab310557cb3fa2662a7cf9c1f39f92130666cb9e014226a9aee521ddbb0b01ac6882
7
- data.tar.gz: 0b5119b7fd419f893a0735d525d1c10e0c7a776f248e7fbdc542f3fcde115bdaaf5f9d541b14b1557037cea6c9a3b5fa9cd71e188b9b688bd259a04aa7ecb999
6
+ metadata.gz: 79ea215a33a5510fe1a323e12a5599bd1399059fb1a87bfd05eb606fce7c113b1426301f41803eaeef876b52f7b4a230954ba567cbc3a186927f08a30def7104
7
+ data.tar.gz: f4aa9ca89a97ed94363a9e6c29022ea8ea32fd8d3d631a2cc28dc1473a353486cd0906d4297678edef0da974b59564e0fc2bcc6f18f446afe958e8cefea88838
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- valuable (0.9.12)
4
+ valuable (0.9.13)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -32,4 +32,4 @@ DEPENDENCIES
32
32
  valuable!
33
33
 
34
34
  BUNDLED WITH
35
- 1.10.6
35
+ 1.13.0.rc.2
@@ -118,12 +118,21 @@ module Valuable::Utils
118
118
  [:klass, :default, :negative, :alias, :parse_with, :extend, :allow_blank]
119
119
  end
120
120
 
121
+ def can_be_duplicated?( item )
122
+ Marshal.dump(item)
123
+ true
124
+ rescue
125
+ false
126
+ end
127
+
121
128
  # this helper raises an exception if the options passed to has_value
122
129
  # are wrong. Mostly written because I occasionally used :class instead
123
130
  # of :klass and, being a moron, wasted time trying to find the issue.
124
131
  def check_options_validity( class_name, attribute, options )
125
132
  invalid_options = options.keys - known_options
126
133
 
134
+ raise ArgumentError, "#{class_name}##{attribute} has a default value that must be set using a lambda. Use :default => lambda { Thing.new }." if options[:default] && !options[:default].kind_of?(Proc) && !can_be_duplicated?( options[:default] )
135
+
127
136
  raise ArgumentError, "has_value did not know how to respond to option(s) #{invalid_options.join(', ')}. Valid (optional) arguments are: #{known_options.join(', ')}" unless invalid_options.empty?
128
137
 
129
138
  raise ArgumentError, "#{class_name} doesn't know how to format #{attribute} with :klass => #{options[:klass].inspect}" unless klass_options.any?{|klass| klass === options[:klass]}
@@ -35,5 +35,13 @@ class BadAttributesTest < Test::Unit::TestCase
35
35
  model.new(:invalid => 'should be ignored')
36
36
  end
37
37
  end
38
+
39
+ def test_that_we_provide_a_better_error_when_objects_can_not_be_marhsaled
40
+ assert_raises ArgumentError do
41
+ Class.new(Valuable) do
42
+ has_value :invalid, :default => StringIO.new
43
+ end
44
+ end
45
+ end
38
46
  end
39
47
 
@@ -3,7 +3,7 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
3
3
  require 'rubygems'
4
4
  require 'test/unit'
5
5
  require 'valuable.rb'
6
- require 'mocha'
6
+ require 'mocha/setup'
7
7
 
8
8
  class Person < Valuable
9
9
  has_value :first_name
@@ -2,7 +2,7 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'valuable.rb'
5
- require 'mocha'
5
+ require 'mocha/setup'
6
6
 
7
7
  class Signature < String
8
8
  end
@@ -3,7 +3,7 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
3
3
  require 'rubygems'
4
4
  require 'test/unit'
5
5
  require 'valuable.rb'
6
- require 'mocha'
6
+ require 'mocha/setup'
7
7
 
8
8
  class Parent < Valuable
9
9
  has_value :name, :default => 'unknown'
@@ -2,7 +2,7 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'valuable.rb'
5
- require 'mocha'
5
+ require 'mocha/setup'
6
6
 
7
7
  class Person < Valuable
8
8
  has_value :first_name
@@ -2,7 +2,7 @@ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
2
 
3
3
  require 'test/unit'
4
4
  require 'valuable.rb'
5
- require 'mocha'
5
+ require 'mocha/setup'
6
6
 
7
7
  class Cubical < String
8
8
  def initialize(number)
@@ -1 +1 @@
1
- 0.9.12
1
+ 0.9.13
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valuable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johnathon Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-24 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Valuable is a ruby base class that is essentially attr_accessor on steroids.
14
14
  A simple and intuitive interface allows you to get on with modeling in your app.
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.4.5.1
69
+ rubygems_version: 2.5.1
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: attr_accessor on steroids with defaults, attribute formatting, alias methods,