yinum 1.7.5 → 1.8.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 +4 -4
- data/CHANGELOG.md +18 -16
- data/Gemfile.lock +1 -1
- data/lib/enum/helpers/enum_attribute.rb +2 -3
- data/lib/enum/helpers/enum_column.rb +2 -3
- data/lib/enum/helpers/enum_generator.rb +1 -2
- data/lib/enum/version.rb +1 -1
- data/lib/enum.rb +1 -1
- metadata +15 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e7f8a85d7567de167b025ebdbb35f2ee6b1d3cb
|
4
|
+
data.tar.gz: 38068b4de9cd8b12e2d1e74eed27024f02bd3d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25aaeb2029774142aad54f5ef8cd39a1942b1fdfd8c5c3bf6b58d9798353e1c02cabddfa435182abe571eda7ea4b29b13d9540545cf5be1035cbaebe244ee3ad
|
7
|
+
data.tar.gz: 938690fa7731824bea0e688e0c56ac76811cdd967317bdff04257d64cf9f2f3f861362106a5217033143bab9273de6d98c8dcc0ac14b43d7e740a5a9e81740e9
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
-
**1.
|
2
|
-
* `
|
3
|
-
|
4
|
-
specific translation are not available.
|
1
|
+
**1.8.0**
|
2
|
+
* `Enum#options` now return the mapping of translations to their corresponding
|
3
|
+
values rather than their names. Works better with `FormBuilder`.
|
5
4
|
|
6
|
-
**1.7.
|
7
|
-
*
|
8
|
-
*
|
9
|
-
|
5
|
+
**1.7.4**
|
6
|
+
* `attr_enum`'s reader allows super to hold the name etc.
|
7
|
+
* Add `#attr_enum` and `#enum` only to modules and classes (not any instance).
|
8
|
+
|
9
|
+
**1.7.3**
|
10
|
+
* `attr_enum`'s writer to accept empty string.
|
11
|
+
* `attr_enum`'s qualifier option to use the object's `#send` rather than `#[]`.
|
10
12
|
|
11
13
|
**1.7.2**
|
12
14
|
* Added `Object#enum_value?` to fix `attr_enum`'s writer, `BasicObject` does
|
13
15
|
not have `respond_to?`.
|
14
16
|
* Fix specs that didn't catch above bug.
|
15
17
|
|
16
|
-
**1.7.
|
17
|
-
* `
|
18
|
-
* `attr_enum`'s
|
18
|
+
**1.7.1**
|
19
|
+
* Remove usage of `reverse_merge`, apparently doesn't exist in Ruby core.
|
20
|
+
* `attr_enum`'s writer does not pass an `EnumValue` to the super.
|
21
|
+
* Fix `EnumValue#t` specs (mocking `I18n`).
|
19
22
|
|
20
|
-
**1.7.
|
21
|
-
* `attr_enum`
|
22
|
-
*
|
23
|
+
**1.7.0**
|
24
|
+
* `attr_enum` reader always returns an EnumValue.
|
25
|
+
* `EnumValue#t` uses `String#titlelize` if it's available and I18n or the
|
26
|
+
specific translation are not available.
|
23
27
|
|
24
|
-
**1.7.5**
|
25
|
-
* Alias helper methods to support Rails 4.1 overriding `::enum`.
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ module Enum::Helpers::EnumAttribute
|
|
7
7
|
# Generating attribute reader and writer to convert to EnumValue.
|
8
8
|
# If :qualifier => true, generates questioning methods for every name in the enum.
|
9
9
|
# If given a enum name (a symbol) and hash, also creates the enum.
|
10
|
-
def
|
10
|
+
def attr_enum(attr, name_or_enum, options = {}, hash = nil)
|
11
11
|
# the first hash is either options or the hash if the options are missing
|
12
12
|
hash, options = options, {} unless name_or_enum.is_a?(Enum) or hash
|
13
13
|
# generating or getting the enum
|
@@ -15,7 +15,7 @@ module Enum::Helpers::EnumAttribute
|
|
15
15
|
e = name_or_enum
|
16
16
|
else
|
17
17
|
# generating the enum if the hash is not empty
|
18
|
-
|
18
|
+
enum name_or_enum, hash if hash.any?
|
19
19
|
e = const_get(name_or_enum)
|
20
20
|
end
|
21
21
|
# attribute reader
|
@@ -44,7 +44,6 @@ module Enum::Helpers::EnumAttribute
|
|
44
44
|
|
45
45
|
e
|
46
46
|
end
|
47
|
-
alias_method :attr_enum, :attr_yinum
|
48
47
|
end
|
49
48
|
|
50
49
|
# Every module or class shall have it
|
@@ -8,11 +8,11 @@ module Enum::Helpers::EnumColumn
|
|
8
8
|
# Creating a validation for the attribute so it must have valid enum values (allowing nil).
|
9
9
|
# If :scoped => true, generates scopes and questioning methods for every name in the enum.
|
10
10
|
# If given a enum name (a symbol) and hash, also creates the enum.
|
11
|
-
def
|
11
|
+
def enum_column(attr, name_or_enum, options = {}, hash = nil)
|
12
12
|
# the first hash is either options or the hash if the options are missing
|
13
13
|
hash, options = options, {} unless name_or_enum.is_a?(Enum) or hash
|
14
14
|
# generating the enum attribute
|
15
|
-
e =
|
15
|
+
e = attr_enum(attr, name_or_enum, options.merge(:qualifier => options[:scoped]), hash)
|
16
16
|
# validation
|
17
17
|
validates_inclusion_of attr, :in => e.values, :allow_nil => true
|
18
18
|
if options[:scoped]
|
@@ -24,7 +24,6 @@ module Enum::Helpers::EnumColumn
|
|
24
24
|
|
25
25
|
e
|
26
26
|
end
|
27
|
-
alias_method :enum_column, :yinum_column
|
28
27
|
end
|
29
28
|
|
30
29
|
if defined?(ActiveRecord::Base)
|
data/lib/enum/version.rb
CHANGED
data/lib/enum.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Niv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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: '0'
|
27
27
|
description: Yummy implementation of enum that gives integer values with a special
|
@@ -32,7 +32,7 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- .gitignore
|
35
|
+
- ".gitignore"
|
36
36
|
- CHANGELOG.md
|
37
37
|
- Gemfile
|
38
38
|
- Gemfile.lock
|
@@ -64,18 +64,24 @@ require_paths:
|
|
64
64
|
- lib
|
65
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project: yinum
|
77
|
-
rubygems_version: 2.0
|
77
|
+
rubygems_version: 2.2.0
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Enum implementation
|
81
|
-
test_files:
|
81
|
+
test_files:
|
82
|
+
- spec/lib/enum/enum_value_spec.rb
|
83
|
+
- spec/lib/enum/helpers/enum_attribute_spec.rb
|
84
|
+
- spec/lib/enum/helpers/enum_column_spec.rb
|
85
|
+
- spec/lib/enum/helpers/enum_generator_spec.rb
|
86
|
+
- spec/lib/enum_spec.rb
|
87
|
+
- spec/spec_helper.rb
|