selectable_attr 0.3.7 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/selectable_attr/base.rb +1 -1
- data/lib/selectable_attr/enum.rb +1 -1
- data/lib/selectable_attr.rb +11 -0
- data/spec/selectable_attr_base_alias_spec.rb +10 -1
- data/spec/selectable_attr_enum_spec.rb +10 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/selectable_attr/base.rb
CHANGED
data/lib/selectable_attr/enum.rb
CHANGED
@@ -153,7 +153,7 @@ module SelectableAttr
|
|
153
153
|
|
154
154
|
def inspect
|
155
155
|
# object_idを2倍にしているのは通常のinspectと合わせるためです。
|
156
|
-
'#<%s:%x @id=%s, @key=%s, @name=%s, @options=%s' % [
|
156
|
+
'#<%s:%x @id=%s, @key=%s, @name=%s, @options=%s>' % [
|
157
157
|
self.class.name, object_id * 2, id.inspect, key.inspect, name.inspect, @options.inspect]
|
158
158
|
end
|
159
159
|
|
data/lib/selectable_attr.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require 'logger'
|
3
|
+
|
2
4
|
module SelectableAttr
|
3
5
|
autoload :VERSION, 'selectable_attr/version'
|
4
6
|
autoload :Enum, 'selectable_attr/enum'
|
5
7
|
autoload :Base, 'selectable_attr/base'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def logger
|
11
|
+
@logger ||= Logger.new(STDERR)
|
12
|
+
end
|
13
|
+
def logger=(value)
|
14
|
+
@logger = value
|
15
|
+
end
|
16
|
+
end
|
6
17
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
+
require 'stringio'
|
3
4
|
|
4
5
|
describe SelectableAttr do
|
5
6
|
|
@@ -419,10 +420,18 @@ describe SelectableAttr do
|
|
419
420
|
end
|
420
421
|
|
421
422
|
it "should call attr_accessor_with_default when default are given but attr_accessor is not TRUE" do
|
422
|
-
|
423
|
+
SelectableAttr.logger.should_receive(:warn).with(":default option ignored for enum1")
|
423
424
|
DefiningMock1.define_accessor(:attr => :enum1, :attr_accessor => false, :default => 1)
|
424
425
|
end
|
425
426
|
|
427
|
+
it "warning message to logger" do
|
428
|
+
io = StringIO.new
|
429
|
+
SelectableAttr.logger = Logger.new(io)
|
430
|
+
DefiningMock1.define_accessor(:attr => :enum1, :attr_accessor => false, :default => 1)
|
431
|
+
io.rewind
|
432
|
+
io.read.should =~ /WARN -- : :default option ignored for enum1$/
|
433
|
+
end
|
434
|
+
|
426
435
|
|
427
436
|
end
|
428
437
|
|
@@ -126,4 +126,14 @@ describe SelectableAttr::Enum do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
describe :inspect do
|
130
|
+
it "NULL" do
|
131
|
+
SelectableAttr::Enum::Entry::NULL.inspect.should =~ /\#<SelectableAttr::Enum::Entry:[0-9a-f]+\ @id=nil,\ @key=nil,\ @name=nil,\ @options=nil>/
|
132
|
+
end
|
133
|
+
|
134
|
+
it "valid" do
|
135
|
+
InetAccess[1].inspect.should =~ /\#<SelectableAttr::Enum::Entry:[0-9a-f]+\ @id=1,\ @key=:email,\ @name="Eメール",\ @options=\{:protocol=>"mailto:"\}>/
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
129
139
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selectable_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi Akima
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-14 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|