model_attribute 3.0.0 → 3.1.0

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: f7732b75fa197e06270fb128e6765d2f6907a11c
4
- data.tar.gz: d30224be4128b258304a58b5560dbe63d854fb0e
3
+ metadata.gz: 50352c846ab8e95216a97c8bb1f75e98e700efcc
4
+ data.tar.gz: 7db758d0a583b823627949a64ce766a9555a8152
5
5
  SHA512:
6
- metadata.gz: 90199911d48ea11bcab09b6e993135cf60f5b584ebfbf05192f86c5a39d9d928baea6ceeda4703a03afbc32c8be1cc4e3e3b6cfbcba983ea437f6b51ec5504ff
7
- data.tar.gz: 5a87bbf29f4d0c321c764f02ea8a8a77ba9ac255ac9fdcec2f96d0f907f5bf34efb6b63cd7c4950910eee6e0d1a21a05bde8fdc09ba7960f8a7be4def71af6d3
6
+ metadata.gz: 1126078dd83bc04a5e92c32e397d940458195c68062a17ebeb366670cd56cbe7ecae791efd081d3a1e01a8a1b00725936a02e62813dbb804e1b723609f100f0d
7
+ data.tar.gz: 46dacb941d9bc0a72ca982fa8f7001a73ac3413e878f07346e2465be7d6e0b874f9922e792e1cc77b13b04c796946594e433aedceb082841e1cfafd1b8283f15
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --require spec_helper
3
+ --warnings
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
+ install:
3
+ - bundle install --without interactive
2
4
  rvm:
3
5
  - "1.9.3"
4
- - "2.1.7"
5
- - "2.2.3"
6
- - "jruby-9.0.0.0"
6
+ - "2.1.10"
7
+ - "2.2.5"
8
+ - "2.3.1"
9
+ - "jruby-9.1.5.0"
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 3.1.0
6
+
7
+ - Allow strings 'true' and 'false' to be assigned to boolean attributes and be
8
+ cast as expected.
9
+
5
10
  ## 3.0.0
6
11
 
7
12
  - **Breaking change**: All casting errors raise `ArgumentError`. Previously some
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in model_attribute.gemspec
4
4
  gemspec
5
+
6
+ group 'interactive' do
7
+ gem 'rspec-nc'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ModelAttribute [![Build Status](https://travis-ci.org/yammer/model_attribute.svg?branch=master)](https://travis-ci.org/yammer/model_attribute)
1
+ # ModelAttribute [![Gem Version](https://badge.fury.io/rb/model_attribute.svg)](http://badge.fury.io/rb/model_attribute) [![Build Status](https://travis-ci.org/yammer/model_attribute.svg?branch=master)](https://travis-ci.org/yammer/model_attribute)
2
2
 
3
3
  Simple attributes for a non-ActiveRecord model.
4
4
 
@@ -75,6 +75,10 @@ user.paid = 'f'
75
75
  user.paid # => false
76
76
  user.paid = 't'
77
77
  user.paid # => true
78
+ user.paid = 'false'
79
+ user.paid # => false
80
+ user.paid = 'true'
81
+ user.paid # => true
78
82
 
79
83
  # A :time attribute
80
84
  user.created_at = Time.now
@@ -215,3 +219,12 @@ Or install it yourself as:
215
219
  3. Commit your changes (`git commit -am 'Add some feature'`)
216
220
  4. Push to the branch (`git push origin my-new-feature`)
217
221
  5. Create a new Pull Request
222
+
223
+ ## Code of Conduct
224
+
225
+ This project has adopted the [Microsoft Open Source Code of
226
+ Conduct](https://opensource.microsoft.com/codeofconduct/). For more information
227
+ see the [Code of Conduct
228
+ FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
229
+ [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
230
+ questions or comments.
@@ -13,9 +13,9 @@ module ModelAttribute
13
13
  when :boolean
14
14
  if !!value == value
15
15
  value
16
- elsif value == 't'
16
+ elsif value == 't' || value == 'true'
17
17
  true
18
- elsif value == 'f'
18
+ elsif value == 'f' || value == 'false'
19
19
  false
20
20
  else
21
21
  raise ArgumentError, "Can't cast #{value.inspect} to boolean"
@@ -1,3 +1,3 @@
1
1
  module ModelAttribute
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -24,7 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.1"
27
- spec.add_development_dependency "rspec-nc", "~> 0.2"
28
- spec.add_development_dependency "guard", "~> 2.8"
29
- spec.add_development_dependency "guard-rspec", "~> 4.3"
30
27
  end
@@ -119,6 +119,16 @@ RSpec.describe "a class using ModelAttribute" do
119
119
  expect(user.paid).to eq(false)
120
120
  end
121
121
 
122
+ it "parses 'false' to false" do
123
+ user.paid = 'false'
124
+ expect(user.paid).to eq(false)
125
+ end
126
+
127
+ it "parses 'true' to true" do
128
+ user.paid = 'true'
129
+ expect(user.paid).to eq(true)
130
+ end
131
+
122
132
  it "raises if passed a string it can't parse" do
123
133
  expect { user.paid = '3a' }.to raise_error(ArgumentError,
124
134
  'Can\'t cast "3a" to boolean')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Waller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,48 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec-nc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.2'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.2'
69
- - !ruby/object:Gem::Dependency
70
- name: guard
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.8'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.8'
83
- - !ruby/object:Gem::Dependency
84
- name: guard-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '4.3'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '4.3'
97
55
  description: |2
98
56
  Attributes for non-ActiveRecord models.
99
57
  Smaller and simpler than Virtus, and adds dirty tracking.
@@ -140,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
98
  version: '0'
141
99
  requirements: []
142
100
  rubyforge_project:
143
- rubygems_version: 2.4.5.1
101
+ rubygems_version: 2.5.1
144
102
  signing_key:
145
103
  specification_version: 4
146
104
  summary: Attributes for non-ActiveRecord models