fast_attributes 0.2.2 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTM0MjRmMDVkYmRhNDM4OTVlOTAwNGY5ZTVhNjZkMDQ3NGM4NDEwOQ==
5
- data.tar.gz: !binary |-
6
- MTNlOWM2NWI0ZTdiNjhjYWEwZmY4ZmYyY2M1MTFmODNjOTc3YjJhZg==
2
+ SHA1:
3
+ metadata.gz: 4e11ae0723fe233d262a2072024c6a0c8a28eb85
4
+ data.tar.gz: 13ab026b7a65d4ca20222a76eea7efacdd74e096
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Yjc2NjhjMDBlMTlhM2FjYTgzNjFkMDg3YzMxOWVmNjk1NTE2ZWE3MTg3ZTVh
10
- ZWNlNzEyZTAxOGFhODRlODI5NjczNTc1ZjM5YzM3ZGQ1NmU1NjQwY2M5MmQz
11
- ODc0ODNkMzRjMGIwOWE3ZWIzZmJmZGVjNjFmOGNkYjQzZGE4OTI=
12
- data.tar.gz: !binary |-
13
- MTMyN2E5ODIyMzg4N2Y4NDFjYzNkNWNhZWU2MmY1MjQ4YjJkMWM0ZjZjOWVk
14
- OWY3YzVhNjg3ZTkyMDlhNzJjZGMyYmJhMGFmZjA4MGZkZmFhNTZlMTk2NDhi
15
- NTRjMWRlNzFhZDQyNzZiYzgwY2E2MjE1MjIwN2Q1MzZkZTU3YTU=
6
+ metadata.gz: 425b0d00dbeb0f30d5de690f8a2caedd0940b8752b4028a3b88528591a807e683eee65620f6514ecefda59c468d01c6cbc57b80cdc5dac5d12a4779eae45220b
7
+ data.tar.gz: 20c0977d3c65e843a45749df83c9b197a9788519ec3eb0e703aa37a44c5c9bed22ee8ad43e3fe19ae6bc3da87a2e16d2a0fa2ce66c2a3aaac6b7b7fc433408e5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ **0.3.0 (July 4, 2014)**
2
+ * Support `Float` data type
3
+
1
4
  **0.2.2 (July 2, 2014)**
2
5
  * Fix uninitialized `@type_casting` variable
3
6
 
data/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
  [![Dependency Status](http://img.shields.io/gemnasium/applift/fast_attributes.svg)](https://gemnasium.com/applift/fast_attributes)
7
7
 
8
8
  ## Motivation
9
- There are already a lot of good and flexible gems which solve the similar problem, allow to define attributes with their types, for example: [virtus](https://github.com/solnic/virtus) or [attrio](https://github.com/jetrockets/attrio). But the disadvantage of existing gems is performance. So, the goal of `fast_attributes` is to make a simple solution which is fast, understandable and easy extendable.
9
+ There are already a lot of good and flexible gems which solve a similar problem, allowing attributes to be defined with their types, for example: [virtus](https://github.com/solnic/virtus) or [attrio](https://github.com/jetrockets/attrio). However, the disadvantage of these gems is performance. So, the goal of `fast_attributes` is to provide a simple solution which is fast, understandable and extendable.
10
10
 
11
- This is [performance benchmark](https://github.com/applift/fast_attributes/blob/master/benchmarks/comparison.rb) of `fast_attributes` and other popular gems.
11
+ This is the [performance benchmark](https://github.com/applift/fast_attributes/blob/master/benchmarks/comparison.rb) of `fast_attributes` compared to other popular gems.
12
12
 
13
13
  ```
14
14
  Comparison:
@@ -123,7 +123,7 @@ book.author
123
123
  # => #<OpenStruct name="Rowling">
124
124
  ```
125
125
 
126
- Notice, that second parameter is a string. It's necessary because this code is compiled into ruby method in runtime. Placeholder `%s` represents a value which this method accepts.
126
+ Notice, that second parameter is a string. It's necessary because this code is compiled into a ruby method in runtime. The placeholder `%s` represents a value which this method accepts.
127
127
 
128
128
  If you need to refer to a placeholder twice, use a temporary variable.
129
129
  ```ruby
data/benchmarks/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  ruby '2.1.2'
4
4
 
5
- gem 'fast_attributes', '0.0.1'
5
+ gem 'fast_attributes', '0.2.2'
6
6
  gem 'virtus', '1.0.2'
7
7
  gem 'attrio', '0.7.3'
8
8
  gem 'benchmark-ips', '2.0.0'
@@ -1,3 +1,3 @@
1
1
  module FastAttributes
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -7,6 +7,7 @@ module FastAttributes
7
7
  @type_casting ||= {
8
8
  String => 'String(%s)',
9
9
  Integer => 'Integer(%s)',
10
+ Float => 'Float(%s)',
10
11
  Array => 'Array(%s)',
11
12
  Date => 'Date.parse(%s)',
12
13
  Time => 'Time.parse(%s)',
@@ -6,6 +6,7 @@ describe FastAttributes do
6
6
  expect(FastAttributes.type_casting).to eq({
7
7
  String => 'String(%s)',
8
8
  Integer => 'Integer(%s)',
9
+ Float => 'Float(%s)',
9
10
  Array => 'Array(%s)',
10
11
  Date => 'Date.parse(%s)',
11
12
  Time => 'Time.parse(%s)',
@@ -64,6 +65,7 @@ describe FastAttributes do
64
65
  expect(book.respond_to?(:title)).to be(true)
65
66
  expect(book.respond_to?(:name)).to be(true)
66
67
  expect(book.respond_to?(:pages)).to be(true)
68
+ expect(book.respond_to?(:price)).to be(true)
67
69
  expect(book.respond_to?(:authors)).to be(true)
68
70
  expect(book.respond_to?(:published)).to be(true)
69
71
  expect(book.respond_to?(:sold)).to be(true)
@@ -75,6 +77,7 @@ describe FastAttributes do
75
77
  expect(book.respond_to?(:title=)).to be(true)
76
78
  expect(book.respond_to?(:name=)).to be(true)
77
79
  expect(book.respond_to?(:pages=)).to be(true)
80
+ expect(book.respond_to?(:price=)).to be(true)
78
81
  expect(book.respond_to?(:authors=)).to be(true)
79
82
  expect(book.respond_to?(:published=)).to be(true)
80
83
  expect(book.respond_to?(:sold=)).to be(true)
@@ -86,6 +89,7 @@ describe FastAttributes do
86
89
  book.title = 123
87
90
  book.name = 456
88
91
  book.pages = '250'
92
+ book.price = '2.55'
89
93
  book.authors = 'Jobs'
90
94
  book.published = '2014-06-21'
91
95
  book.sold = '2014-06-21 20:45:15'
@@ -94,6 +98,7 @@ describe FastAttributes do
94
98
  expect(book.title).to eq('123')
95
99
  expect(book.name).to eq('456')
96
100
  expect(book.pages).to be(250)
101
+ expect(book.price).to be(2.55)
97
102
  expect(book.authors).to eq(%w[Jobs])
98
103
  expect(book.published).to eq(Date.new(2014, 6, 21))
99
104
  expect(book.sold).to eq(Time.new(2014, 6, 21, 20, 45, 15))
@@ -105,6 +110,7 @@ describe FastAttributes do
105
110
  book.title = title = 'One'
106
111
  book.name = name = 'Two'
107
112
  book.pages = pages = 250
113
+ book.price = price = 2.55
108
114
  book.authors = authors = %w[Jobs]
109
115
  book.published = published = Date.new(2014, 06, 21)
110
116
  book.sold = sold = Time.new(2014, 6, 21, 20, 45, 15)
@@ -113,6 +119,7 @@ describe FastAttributes do
113
119
  expect(book.title).to be(title)
114
120
  expect(book.name).to be(name)
115
121
  expect(book.pages).to be(pages)
122
+ expect(book.price).to be(price)
116
123
  expect(book.authors).to be(authors)
117
124
  expect(book.published).to be(published)
118
125
  expect(book.sold).to be(sold)
@@ -124,6 +131,7 @@ describe FastAttributes do
124
131
  book.title = 'One'
125
132
  book.name = 'Two'
126
133
  book.pages = 250
134
+ book.price = 2.55
127
135
  book.authors = %w[Jobs]
128
136
  book.published = Date.new(2014, 06, 21)
129
137
  book.sold = Time.new(2014, 6, 21, 20, 45, 15)
@@ -132,6 +140,7 @@ describe FastAttributes do
132
140
  book.title = nil
133
141
  book.name = nil
134
142
  book.pages = nil
143
+ book.price = nil
135
144
  book.authors = nil
136
145
  book.published = nil
137
146
  book.sold = nil
@@ -140,6 +149,7 @@ describe FastAttributes do
140
149
  expect(book.title).to be(nil)
141
150
  expect(book.name).to be(nil)
142
151
  expect(book.pages).to be(nil)
152
+ expect(book.price).to be(nil)
143
153
  expect(book.authors).to be(nil)
144
154
  expect(book.published).to be(nil)
145
155
  expect(book.sold).to be(nil)
@@ -152,6 +162,7 @@ describe FastAttributes do
152
162
  expect{ book.title = BasicObject.new }.to raise_error(TypeError)
153
163
  expect{ book.name = BasicObject.new }.to raise_error(TypeError)
154
164
  expect{ book.pages = 'number' }.to raise_error(ArgumentError)
165
+ expect{ book.price = 'price' }.to raise_error(ArgumentError)
155
166
  expect{ book.published = 'date' }.to raise_error(ArgumentError)
156
167
  expect{ book.sold = 'time' }.to raise_error(ArgumentError)
157
168
  expect{ book.finished = 'datetime' }.to raise_error(ArgumentError)
@@ -3,6 +3,7 @@ class Book
3
3
 
4
4
  attribute :title, :name, String
5
5
  attribute :pages, Integer
6
+ attribute :price, Float
6
7
  attribute :authors, Array
7
8
  attribute :published, Date
8
9
  attribute :sold, Time
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kostiantyn Stepaniuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.7.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.8.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.8.2
83
83
  description: Fast attributes with data types
@@ -87,10 +87,10 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .coveralls.yml
91
- - .gitignore
92
- - .rspec
93
- - .travis.yml
90
+ - ".coveralls.yml"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
94
  - CHANGELOG.md
95
95
  - Gemfile
96
96
  - LICENSE.txt
@@ -115,17 +115,17 @@ require_paths:
115
115
  - lib
116
116
  required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - ! '>='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: 1.9.2
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ! '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.1.11
128
+ rubygems_version: 2.2.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Fast attributes with data types