enumify 0.2.0 → 1.0.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: 635791d1c61f10feee7cebf75a2be9a06ff95a20
4
- data.tar.gz: 37859ccd1e25feb2789a52a151cf4fb5194e9596
3
+ metadata.gz: b87f16577e0ad0f7e3764f92f0d069d07e7ac5a3
4
+ data.tar.gz: 2844722bb6c6023ca4ce0a1189b1603424da26de
5
5
  SHA512:
6
- metadata.gz: f9061022d1e98c0c006b3969041d48e6af15bf5df51ffa516c4d2c75e2e755945a70ae4e4d8b1838288f50f52efe9669f83d6958ecf76679e524e35a7e152b4e
7
- data.tar.gz: 2ab5669fade3bdebd803c55838a0dee632b70632d15f324aa239ee5003cfd8e01e2f71478ca0739969087ed8ded4379c89c6ebf1a8e6fc656092af93fb39f421
6
+ metadata.gz: 265d1739e223e900024b5bedadfd223a8915ff01a4e8e8e746452fd864ab56524e65d763cf31e86e09b3e5956fb0a906d4ad36802f4165a17ad68bc3febbf30b
7
+ data.tar.gz: fff56ae04ccf2358be474acee0b7dd5ab5a871b9c407f021261d6cc9b4719f5ea43000546fa38b50b58871dadb7845afe3e5eab8aeecb36159a1efd94ec19c22
@@ -4,8 +4,6 @@ rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
6
  - 2.1.0
7
- - rbx
8
- - jruby-19mode
9
7
  gemfile:
10
8
  - gemfiles/rails30.gemfile
11
9
  - gemfiles/rails31.gemfile
@@ -1,3 +1,7 @@
1
+ ## v1.0.0
2
+ * Removed the option of using `enum` as the method. You can only
3
+ define enums as `enumify`
4
+
1
5
  ## v0.0.7
2
6
  * Fixed an issue with setting an enum as a nil value
3
7
 
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ group :development do
8
8
  gem 'guard'
9
9
  gem 'guard-rspec'
10
10
  gem 'terminal-notifier-guard'
11
+ gem 'bump'
11
12
  end
12
13
 
13
14
  # Specify your gem's dependencies in enumify.gemspec
data/Readme.md CHANGED
@@ -12,25 +12,14 @@ gem 'enumify'
12
12
 
13
13
  ## How to use
14
14
 
15
- Just call the `enum` function in any ActiveRecord object, the function accepts the field name as the first variable and the possible values as an array
16
-
17
- ```ruby
18
- class Event < ActiveRecord::Base
19
- enum :status, [:available, :canceled, :completed]
20
- end
21
- ```
22
-
23
- ## Rails 4.1+
24
-
25
- You can also instantiate a _Enumify_ enum by calling the `enumify` method instead of `enum`.
26
- This is especially helpful when your app is running Rail 4.1 or better which has it's own built in enum (although not as good)
15
+ Just call the `enumify` function in any ActiveRecord object, the function accepts the field name as the first variable and the possible values as an array
27
16
 
28
17
  ```ruby
29
18
  class Event < ActiveRecord::Base
30
19
  enumify :status, [:available, :canceled, :completed]
31
20
  end
32
21
  ```
33
-
22
+
34
23
  ## Usage
35
24
 
36
25
  After that you get several autogenerated commands to use with the enum
@@ -58,20 +47,20 @@ By default the enum field does not support a nil value. In order to allow nil va
58
47
 
59
48
  ```ruby
60
49
  class Event < ActiveRecord::Base
61
- enum :status, [:available, :canceled, :completed], :allow_nil => true
50
+ enumify :status, [:available, :canceled, :completed], :allow_nil => true
62
51
  end
63
52
 
64
53
  Event.create! # Is valid and does not throw an exception.
65
54
  ```
66
55
 
67
56
  #### :prefix
68
- By default all enum values are available as scopes, bang and query methods based on the value.
69
- You can add a prefix for the enum values in order to differentiate different enums on the same object.
57
+ By default all enum values are available as scopes, bang and query methods based on the value.
58
+ You can add a prefix for the enum values in order to differentiate different enums on the same object.
70
59
 
71
60
  ```ruby
72
61
  class Event < ActiveRecord::Base
73
- enum :status, [:available, :canceled, :completed], :prefix => true
74
- enum :subtype, [:company, :personal], :prefix => 'type'
62
+ enumify :status, [:available, :canceled, :completed], :prefix => true
63
+ enumify :subtype, [:company, :personal], :prefix => 'type'
75
64
  end
76
65
 
77
66
  event.available? # Not available anymore
@@ -85,9 +74,9 @@ You can remove the constant by passing a falsy value (i.e: `nil`, `false`) or re
85
74
 
86
75
  ```ruby
87
76
  class Event < ActiveRecord::Base
88
- enum :status, [:available, :canceled, :completed]
89
- enum :without_const, [:foo, :bar], :constant => false
90
- enum :custom_name, [:a, :b, :c], :constant => :special_name
77
+ enumify :status, [:available, :canceled, :completed]
78
+ enumify :without_const, [:foo, :bar], :constant => false
79
+ enumify :custom_name, [:a, :b, :c], :constant => :special_name
91
80
  end
92
81
 
93
82
  event::STATUSES # returns [:available, :canceled, :completed]
@@ -104,7 +93,7 @@ All you need to do is add a x_changed method in your class and the enumify will
104
93
 
105
94
  ```ruby
106
95
  class Event < ActiveRecord::Base
107
- enum :status, [:available, :canceled, :completed]
96
+ enumify :status, [:available, :canceled, :completed]
108
97
 
109
98
  def status_changed(old, new)
110
99
  puts "status changed from #{old} to #{new}"
@@ -5,8 +5,8 @@ require "enumify/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "enumify"
7
7
  s.version = Enumify::VERSION
8
- s.authors = ["yon"]
9
- s.email = ["yonatanbergman@gmail.com"]
8
+ s.authors = ["yonbergman"]
9
+ s.email = ["yonbergman@gmail.com"]
10
10
  s.homepage = "http://github.com/yonbergman/enumify"
11
11
  s.summary = %q{enumify adds an enum command to all ActiveRecord models which enables you to work with string attributes as if they were enums}
12
12
  s.description = <<-END
@@ -81,7 +81,6 @@ module Enumify
81
81
  end
82
82
  end
83
83
  end
84
- alias_method :enum, :enumify
85
84
  end
86
85
 
87
86
  end
@@ -1,3 +1,3 @@
1
1
  module Enumify
2
- VERSION = '0.2.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  class Model < ActiveRecord::Base
4
4
  include Enumify::Model
5
5
 
6
- enum :status, [:available, :canceled, :completed]
6
+ enumify :status, [:available, :canceled, :completed]
7
7
  end
8
8
 
9
9
  class OtherModel < ActiveRecord::Base
@@ -11,13 +11,13 @@ class OtherModel < ActiveRecord::Base
11
11
 
12
12
  belongs_to :model
13
13
 
14
- enum :status, [:active, :expired, :not_expired]
14
+ enumify :status, [:active, :expired, :not_expired]
15
15
  end
16
16
 
17
17
  class ModelAllowingNil < ActiveRecord::Base
18
18
  include Enumify::Model
19
19
  self.table_name = 'models'
20
- enum :status, [:available, :canceled, :completed], :allow_nil => true
20
+ enumify :status, [:available, :canceled, :completed], :allow_nil => true
21
21
  end
22
22
 
23
23
 
@@ -201,19 +201,19 @@ describe :Enumify do
201
201
  class ModelWithoutConst < ActiveRecord::Base
202
202
  include Enumify::Model
203
203
  self.table_name = 'models'
204
- enum :status, [:available, :canceled, :completed], :constant => false
204
+ enumify :status, [:available, :canceled, :completed], :constant => false
205
205
  end
206
206
 
207
207
  class ModelWithSymbolNamedConst < ActiveRecord::Base
208
208
  include Enumify::Model
209
209
  self.table_name = 'models'
210
- enum :status, [:available, :canceled, :completed], :constant => :special_status
210
+ enumify :status, [:available, :canceled, :completed], :constant => :special_status
211
211
  end
212
212
 
213
213
  class ModelWithStringNamedConst < ActiveRecord::Base
214
214
  include Enumify::Model
215
215
  self.table_name = 'models'
216
- enum :status, [:available, :canceled, :completed], :constant => 'special_status'
216
+ enumify :status, [:available, :canceled, :completed], :constant => 'special_status'
217
217
  end
218
218
 
219
219
  it 'class should have a CONST that holds all the available options of the enum by default' do
@@ -240,7 +240,7 @@ describe :Enumify do
240
240
  Class.new(ActiveRecord::Base) {
241
241
  include Enumify::Model
242
242
  self.table_name = 'models'
243
- enum :status, [:available, :canceled, :completed], :constant => invalid_name
243
+ enumify :status, [:available, :canceled, :completed], :constant => invalid_name
244
244
  }
245
245
  }.to raise_error(NameError)
246
246
  end
@@ -255,7 +255,7 @@ describe :Enumify do
255
255
  class ModelWithPrefix < ActiveRecord::Base
256
256
  include Enumify::Model
257
257
  self.table_name = 'models'
258
- enum :status, [:available, :canceled, :completed], :prefix => 'foo'
258
+ enumify :status, [:available, :canceled, :completed], :prefix => 'foo'
259
259
  end
260
260
 
261
261
  subject { ModelWithPrefix.new(:status => :available) }
@@ -289,7 +289,7 @@ describe :Enumify do
289
289
  class ModelWithPrefixTrue < ActiveRecord::Base
290
290
  include Enumify::Model
291
291
  self.table_name = 'models'
292
- enum :status, [:available, :canceled, :completed], :prefix => true
292
+ enumify :status, [:available, :canceled, :completed], :prefix => true
293
293
  end
294
294
 
295
295
  subject { ModelWithPrefixTrue.new(:status => :available) }
@@ -17,4 +17,3 @@ def set_database
17
17
  end
18
18
 
19
19
  set_database
20
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - yon
7
+ - yonbergman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-21 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -75,7 +75,7 @@ description: |2
75
75
  Callback support - you can add a x_callback method which will be called each time the status changes
76
76
  Scopes - you can easily query for values of the enum
77
77
  email:
78
- - yonatanbergman@gmail.com
78
+ - yonbergman@gmail.com
79
79
  executables: []
80
80
  extensions: []
81
81
  extra_rdoc_files: []