inum 4.0.0 → 4.0.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a13fbdf7013fbb32ae52aa22ed0a6190c952ce2
4
- data.tar.gz: 8b6d48c73567b96073e0f4b4774ed11ca372a2eb
3
+ metadata.gz: 3491f1414101351d964f664aa8257409286cc49b
4
+ data.tar.gz: 1b2be9033dc22ffda1c14ef95107004e96fedbe4
5
5
  SHA512:
6
- metadata.gz: fb3b3e5298b8993ca0b3bff39b7437a44ff82224c749457995e1298360ec37fd164d025162a36e808255d44203ae5f7a6e33f7fb65a288c0a884af4c59edd4e5
7
- data.tar.gz: 322444e9be0196b9339b6491d36658005511b2f23fe2e07ccd02570cc06780fbb78bbac3a967e233eb2419abbc0582d0a3259dbff69fa31640f4816939772d20
6
+ metadata.gz: 6926d5d38ed53b126069ab24b56af810d453acb02b03ead4603ea15dca5258b9bf16997ca47340db02ecc43d526ace91e598907ac42cee17e62a7a6bb9bacaf8
7
+ data.tar.gz: 57f444f10bb6619a1ae8edb8e86da7ea422a93014856f0f5d258032ace0688044323f383c13315607b6dbede05f8b04229d5504803e9b6e3321c1f039e863c0e
data/.gitignore CHANGED
@@ -5,18 +5,27 @@
5
5
  .yardoc
6
6
  Gemfile.lock
7
7
  InstalledFiles
8
+
9
+ # doc files.
10
+ rdoc
8
11
  _yardoc
9
- coverage
10
- doc/
12
+ doc
11
13
  lib/bundler/man
12
- pkg
13
- rdoc
14
+
15
+ # test temp files.
14
16
  spec/reports
15
17
  test/tmp
16
18
  test/version_tmp
17
- tmp
18
- vendor/
19
+ coverage
20
+
21
+ # temp directories.
22
+ pkg/
23
+ tmp/
24
+ temp/
25
+
19
26
 
20
27
  # IDE Projects files.
21
28
  nbproject/
22
29
  .project
30
+ .idea/
31
+
@@ -7,6 +7,6 @@ rvm:
7
7
  - 2.1.0
8
8
  - 2.1.2
9
9
  env:
10
- - ACTIVE_RECORD_VERSION=3.2.16
11
- - ACTIVE_RECORD_VERSION=4.0.0
12
- - ACTIVE_RECORD_VERSION=4.1.4
10
+ - ACTIVE_RECORD_VERSION=3.2.20
11
+ - ACTIVE_RECORD_VERSION=4.1.7
12
+ - ACTIVE_RECORD_VERSION=4.2.0.beta4
@@ -23,6 +23,10 @@ module Inum
23
23
  end
24
24
 
25
25
  define_method("#{column}=") do |value|
26
+ if value.class == String and /^\d$/.match(value)
27
+ value = value.to_i
28
+ end
29
+
26
30
  enum_class.parse(value).tap do |enum|
27
31
  if enum
28
32
  write_attribute(column, enum.to_i)
@@ -104,8 +104,8 @@ module Inum
104
104
  # @param option [Hash] Options.
105
105
  # @option option [Array<Symbol>] except Except enum.
106
106
  # @option option [Array<Symbol>] only Limit enum.
107
- # @return [Array<Array>] collection.
108
- def self.collection(option)
107
+ # @return [Array<Array>] collection. ex `[["HOGE", 0], ["FUGA", 1]]`
108
+ def self.collection(option = {})
109
109
  map { |e|
110
110
  next if option[:except] and option[:except].include?(e.label)
111
111
  next if option[:only] and !option[:only].include?(e.label)
@@ -115,7 +115,8 @@ module Inum
115
115
 
116
116
  # Execute the yield(block) with each member of enum.
117
117
  #
118
- # @param &block [proc{|enum| .. }] execute the block.
118
+ # @yield [enum] execute the block with enums.
119
+ # @yieldparam [Inum::Base] enum enum.
119
120
  def self.each(&block)
120
121
  @enums.each(&block)
121
122
  end
@@ -1,3 +1,3 @@
1
1
  module Inum
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -87,6 +87,18 @@ describe Inum::ActiveRecordMixin do
87
87
  subject
88
88
  end
89
89
  end
90
+
91
+ context 'When integer value of string' do
92
+ let(:target){ '1' }
93
+
94
+ it 'set value.' do
95
+ expect {
96
+ instance.anime = target
97
+ }.to change {
98
+ instance.send(:read_attribute, :anime)
99
+ }.from(type.to_i).to(Anime.parse(1).to_i)
100
+ end
101
+ end
90
102
  end
91
103
 
92
104
  describe '#getter' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inum
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alfa-jpn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler