yinum 1.7.5 → 1.8.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: 1852e8cae1da2ec57b29129ccac0e22bd10903b5
4
- data.tar.gz: 87ab148db37f6c7681582d3224ff86775dd96518
3
+ metadata.gz: 6e7f8a85d7567de167b025ebdbb35f2ee6b1d3cb
4
+ data.tar.gz: 38068b4de9cd8b12e2d1e74eed27024f02bd3d9b
5
5
  SHA512:
6
- metadata.gz: bb0820b263ade12501ef425a1dd73b11f0e3623c2ee9bd7a8079f4bb33b46f5b096e018c2d4d720aeeb4194c015fa7613e063db7a76bf5903880a1adf2f32ca7
7
- data.tar.gz: f8971edbac61a68d4c5bd792355885dfdb2755f52ee27b1478688856f63e215a8a9259dd732cdf73b46dbcea0ef282649887c71379c07ec3e511b766c91d41c7
6
+ metadata.gz: 25aaeb2029774142aad54f5ef8cd39a1942b1fdfd8c5c3bf6b58d9798353e1c02cabddfa435182abe571eda7ea4b29b13d9540545cf5be1035cbaebe244ee3ad
7
+ data.tar.gz: 938690fa7731824bea0e688e0c56ac76811cdd967317bdff04257d64cf9f2f3f861362106a5217033143bab9273de6d98c8dcc0ac14b43d7e740a5a9e81740e9
data/CHANGELOG.md CHANGED
@@ -1,25 +1,27 @@
1
- **1.7.0**
2
- * `attr_enum` reader always returns an EnumValue.
3
- * `EnumValue#t` uses `String#titlelize` if it's available and I18n or the
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.1**
7
- * Remove usage of `reverse_merge`, apparently doesn't exist in Ruby core.
8
- * `attr_enum`'s writer does not pass an `EnumValue` to the super.
9
- * Fix `EnumValue#t` specs (mocking `I18n`).
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.3**
17
- * `attr_enum`'s writer to accept empty string.
18
- * `attr_enum`'s qualifier option to use the object's `#send` rather than `#[]`.
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.4**
21
- * `attr_enum`'s reader allows super to hold the name etc.
22
- * Add `#attr_enum` and `#enum` only to modules and classes (not any instance).
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yinum (1.7.5)
4
+ yinum (1.8.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -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 attr_yinum(attr, name_or_enum, options = {}, hash = nil)
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
- yinum name_or_enum, hash if hash.any?
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 yinum_column(attr, name_or_enum, options = {}, hash = nil)
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 = attr_yinum(attr, name_or_enum, options.merge(:qualifier => options[:scoped]), hash)
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)
@@ -1,10 +1,9 @@
1
1
  require 'enum'
2
2
 
3
3
  module Enum::Helpers::EnumGenerator
4
- def yinum(name, hash)
4
+ def enum(name, hash)
5
5
  const_set name, Enum.new(name, self, hash)
6
6
  end
7
- alias_method :enum, :yinum
8
7
  end
9
8
 
10
9
  # Every module or class shall have it
data/lib/enum/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Enum
2
- VERSION = '1.7.5'
2
+ VERSION = '1.8.0'
3
3
  end
data/lib/enum.rb CHANGED
@@ -43,7 +43,7 @@ class Enum
43
43
  end
44
44
 
45
45
  def options
46
- Hash[map { |ev| [ev.t, ev.name] }]
46
+ Hash[map { |ev| [ev.t, ev] }]
47
47
  end
48
48
 
49
49
  private
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.7.5
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-08-04 00:00:00.000000000 Z
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.3
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