dimensional-enum 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2aef29e2efcac274df9eb27b3703976d0242018e
4
+ data.tar.gz: 9ba21ae0467760bc9daff451502dfa3dde974978
5
+ SHA512:
6
+ metadata.gz: 64e5ccd93176af13e5b52bb84a285b4fb8fbcb0dfac7e6818e4946c714ac90645ac7e1527dec152c1bde6ebe399eda49baf920589a1737828b820d192c46f233
7
+ data.tar.gz: ae1cc51bc6e30d8142fa3e1745e36564c9ac42c277d7e960334909f928275e17d311c2bcfe11ddbd19971f8a656779d6919f6d56ad0d1c13a2a0bc9ba345bd8c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dimensional-enum.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Watanabe, Mitsutoshi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Dimensional::Enum
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dimensional-enum'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dimensional-enum
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/dimensional-enum/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dimensional/enum/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dimensional-enum"
8
+ spec.version = Dimensional::Enum::VERSION
9
+ spec.authors = ["Watanabe, Mitsutoshi"]
10
+ spec.email = ["mitsutoshi@reivo.co.jp"]
11
+ spec.summary = %q{Extends to handle Rails Enum with multi dimensional attributes.}
12
+ spec.description = %q{Extends to handle Rails Enum with multi dimensional attributes.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "activerecord", "~> 4.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,44 @@
1
+ require "dimensional/enum/version"
2
+ require "dimensional/enum/attributes"
3
+ require "dimensional/enum/attribute"
4
+
5
+ module Dimensional
6
+ module Enum
7
+ class InvalidDefinition < StandardError; end
8
+
9
+ def self.included(klass)
10
+ klass.extend ClassMethods
11
+ # klass.class_eval do
12
+ # attr_reader :enum_attributes
13
+ # end
14
+ end
15
+
16
+ module ClassMethods
17
+ def set_enum_config( enum_attributes )
18
+ @enum_attributes = enum_attributes
19
+ end
20
+
21
+ def def_enum( enum_key )
22
+ if @enum_attributes.nil?
23
+ raise ::Dimensional::Enum::InvalidDefinition, "Undefined @enum_attributes on #{self}"
24
+ end
25
+
26
+ unless @enum_attributes.include? enum_key
27
+ raise ::Dimensional::Enum::InvalidDefinition, "Undefined enum_key #{enum_key} in @enum_attributes"
28
+ end
29
+
30
+ enum_values = @enum_attributes.to_value_h( enum_key )
31
+ enum_attribute = @enum_attributes.to_attribute_h( enum_key )
32
+
33
+ self.class_eval do
34
+ enum enum_key => enum_values
35
+
36
+ define_method enum_key do
37
+ return nil unless attr_key = super()
38
+ ::Dimensional::Enum::Object.new attr_key, enum_attribute
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,48 @@
1
+ module Dimensional
2
+ module Enum
3
+ class Attribute
4
+
5
+ def initialize( enum_attr_key, enum_attribute )
6
+ @enum_attr_key = enum_attr_key
7
+ @enum_attribute = enum_attribute
8
+ end
9
+
10
+ def ==( other )
11
+ to_s == other
12
+ end
13
+
14
+ def id
15
+ @enum_attribute[label][:id]
16
+ rescue
17
+ nil
18
+ end
19
+
20
+ def name
21
+ @enum_attribute[label][:name]
22
+ rescue
23
+ nil
24
+ end
25
+
26
+ def label
27
+ @enum_attr_key.to_sym
28
+ rescue
29
+ nil
30
+ end
31
+
32
+ def to_s
33
+ label.to_s
34
+ end
35
+
36
+ def to_sym
37
+ label.to_sym
38
+ end
39
+
40
+ def to_i
41
+ id.to_i
42
+ end
43
+
44
+ alias_method :value, :id
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,54 @@
1
+ module Dimensional
2
+ module Enum
3
+ class Attributes
4
+
5
+ attr_reader :attrs
6
+
7
+ def initialize( enum_attributes_hash={} )
8
+ @attrs = enum_attributes_hash
9
+ end
10
+
11
+ def include?(key)
12
+ @attrs.include? key
13
+ end
14
+
15
+ def to_attribute_h(enum_key)
16
+ @attrs[enum_key]
17
+ end
18
+
19
+ def to_value_h(enum_key)
20
+ hash = @attrs[enum_key].each_with_object({}) do |(key, value), h|
21
+ h[key] = value[:id]
22
+ end
23
+ end
24
+
25
+ def to_display_h(enum_key)
26
+ hash = @attrs[enum_key].each_with_object({}) do |(key, value), h|
27
+ h[key] = value[:name]
28
+ end
29
+ end
30
+
31
+ def id(enum_key, enum_attr_key)
32
+ @attrs[enum_key.to_sym][enum_attr_key.to_sym][:id]
33
+ rescue
34
+ nil
35
+ end
36
+
37
+ def name(enum_key, enum_attr_key)
38
+ @attrs[enum_key.to_sym][enum_attr_key.to_sym][:name]
39
+ rescue
40
+ nil
41
+ end
42
+
43
+ def to_json(enum_key)
44
+ arr = []
45
+ @attrs[enum_key].each do |key, value|
46
+ arr << { value: key, text: value[:name] }
47
+ end
48
+ JSON.unparse arr
49
+ end
50
+
51
+ alias_method :to_origin_h, :to_attribute_h
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Dimensional
2
+ module Enum
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+ require "dimensional/enum"
3
+
4
+ module Dimensional::Enum
5
+ describe Attribute do
6
+ it "初期化できること" do
7
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
8
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
9
+ expect( enum_attribute.class ).to eq Dimensional::Enum::Attribute
10
+ end
11
+
12
+ it "#id" do
13
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
14
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
15
+ expect( enum_attribute.id ).to eq 4
16
+ end
17
+
18
+ it "#name" do
19
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
20
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
21
+ expect( enum_attribute.name ).to eq "商談中"
22
+ end
23
+
24
+ it "#label" do
25
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
26
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
27
+ expect( enum_attribute.label ).to eq :sale_on_nego
28
+ end
29
+
30
+ it "#to_sym" do
31
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
32
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
33
+ expect( enum_attribute.to_sym ).to eq :sale_on_nego
34
+ end
35
+
36
+ it "#to_s" do
37
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
38
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
39
+ expect( enum_attribute.to_s ).to eq "sale_on_nego"
40
+ end
41
+
42
+ it "#to_i" do
43
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
44
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
45
+ expect( enum_attribute.to_i ).to eq 4
46
+ end
47
+
48
+ it "#==" do
49
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
50
+ enum_attribute = Attribute.new "sale_on_nego", enum_attributes.to_attribute_h(:sale_state)
51
+ expect( enum_attribute == "sale_on_running" ).to eq false
52
+ expect( enum_attribute == "sale_on_nego" ).to eq true
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+ require "dimensional/enum"
3
+
4
+ module Dimensional::Enum
5
+ describe Attributes do
6
+ it "初期化できること" do
7
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
8
+ expect( enum_attributes.class ).to eq Dimensional::Enum::Attributes
9
+ end
10
+
11
+ it "#include?" do
12
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
13
+ expect( enum_attributes.include? :sale_state ).to eq true
14
+ expect( enum_attributes.include? :available_type ).to eq false
15
+ end
16
+
17
+ it "#to_attribute" do
18
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
19
+ enum_attribute = enum_attributes.to_attribute_h(:status)
20
+ expect( enum_attribute.has_key? :released ).to eq true
21
+ expect( enum_attribute.has_key? :not_found ).to eq false
22
+ expect( enum_attribute[:released][:id] ).to eq 1
23
+ expect( enum_attribute[:released][:name] ).to eq "入稿済み"
24
+ end
25
+
26
+ it "#to_value_h" do
27
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
28
+ enum_attribute = enum_attributes.to_value_h(:status)
29
+ expect( enum_attribute.has_key? :released ).to eq true
30
+ expect( enum_attribute[:released] ).to eq 1
31
+ end
32
+
33
+ it "#to_display_h" do
34
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
35
+ enum_attribute = enum_attributes.to_display_h(:status)
36
+ expect( enum_attribute.has_key? :released ).to eq true
37
+ expect( enum_attribute[:released] ).to eq "入稿済み"
38
+ end
39
+
40
+ it "#id" do
41
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
42
+ expect( enum_attributes.id(:status, :released) ).to eq 1
43
+ end
44
+
45
+ it "#name" do
46
+ enum_attributes = Attributes.new Sample::ENUM_ATTRIBUTES[:core]
47
+ expect( enum_attributes.name(:status, :released) ).to eq "入稿済み"
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+ require "dimensional/enum"
3
+
4
+ describe Dimensional::Enum do
5
+
6
+ end
@@ -0,0 +1,2 @@
1
+ require "rubygems"
2
+ require "support/sample.rb"
@@ -0,0 +1,408 @@
1
+ module Sample
2
+ ENUM_ATTRIBUTES = {
3
+ # ---------------------------
4
+ # Core
5
+ # ---------------------------
6
+ core: {
7
+ sale_state: {
8
+ sale_planned: { id: 1, name: '売り出し見込み' },
9
+ sale_running: { id: 2, name: '売り出し中' },
10
+ sale_stopped: { id: 3, name: '売り止め' },
11
+ sale_on_nego: { id: 4, name: '商談中' },
12
+ sale_nego_completed: { id: 5, name: '成約済み' }
13
+ },
14
+ public_scope: {
15
+ public_to_all: { id: 1, name: '公開' },
16
+ public_to_suggestees: { id: 2, name: '提案した会員にのみ公開' },
17
+ public_to_none: { id: 3, name: '非公開' },
18
+ },
19
+ profile_scope_control: {
20
+ show_for_all: { id: 1, name: '全ユーザー' },
21
+ show_for_members: { id: 2, name: '一般会員' },
22
+ show_for_bronzes: { id: 3, name: 'ブロンズ会員' },
23
+ show_for_silvers: { id: 4, name: 'シルバー会員' },
24
+ show_for_goalds: { id: 5, name: 'ゴールド会員' },
25
+ show_for_platinums: { id: 6, name: 'プラチナ会員' },
26
+ show_for_suggestees: { id: 7, name: '提案した会員' },
27
+ },
28
+ status: {
29
+ released: { id: 1, name: '入稿済み' },
30
+ draft: { id: 2, name: '下書き' },
31
+ illegal: { id: 3, name: '強制非表示' }
32
+ }
33
+ },
34
+
35
+ # ---------------------------
36
+ # Profile
37
+ # ---------------------------
38
+ profile: {
39
+ #
40
+ # Required
41
+ #
42
+ available_type: {
43
+ available_now: { id: 1, name: '即時' },
44
+ available_with_consult: { id: 2, name: '要相談' },
45
+ available_at: { id: 3, name: '期日指定' }
46
+ },
47
+ estate_agent_type: {
48
+ agent_owner: { id: 1, name: '売主' },
49
+ agent_proxy: { id: 2, name: '代理' },
50
+ agent_dedicated_exclusive: { id: 3, name: '専属専任媒介' },
51
+ agent_dedicated: { id: 4, name: '専任媒介' },
52
+ agent_common: { id: 5, name: '一般媒介' },
53
+ agent_others: { id: 6, name: 'その他仲介' }
54
+ },
55
+ allows_placement: {
56
+ placement_denied: { id: 1, name: '不可' },
57
+ placement_allowed: { id: 2, name: '可(他社取込不可)' },
58
+ placement_succeeded_allowed: { id: 3, name: '可(他社取込可)' }
59
+ },
60
+ management_type: {
61
+ managed_by_self: { id: 1, name: '自社' },
62
+ managed_by_other: { id: 2, name: '先物' }
63
+ },
64
+ needs_private_road_fee: {
65
+ private_road_fee_free: { id: 1, name: '無' },
66
+ private_road_fee_required: { id: 2, name: '有' }
67
+ },
68
+ has_setback: {
69
+ setback_free: { id: 1, name: '無' },
70
+ setback_required: { id: 2, name: '有' }
71
+ },
72
+ available_road_state: {
73
+ road_connected_1_side: { id: 1, name: '一方' },
74
+ road_connected_2_side_at_corner: { id: 2, name: '二方(角地)' },
75
+ road_connected_2_side_both: { id: 3, name: '二方(両面)' },
76
+ road_connected_3_side: { id: 4, name: '三方' },
77
+ road_connected_4_side: { id: 5, name: '四方' },
78
+ road_connected_none: { id: 6, name: '接道なし' },
79
+ },
80
+
81
+ #
82
+ # Optional
83
+ #
84
+ has_deposit_guaranty: {
85
+ deposit_guaranty: { id: 1, name: '保証制度あり' },
86
+ deposit_guaranty_others: { id: 2, name: 'その他' }
87
+ },
88
+ agent_commission: {
89
+ agent_commission_required: { id: 1, name: '要' },
90
+ agent_commission_not_required: { id: 2, name: '不要' },
91
+ agent_commission_half: { id: 3, name: '半額' },
92
+ agent_commission_others: { id: 4, name: 'その他' },
93
+ },
94
+ tap_water_type: {
95
+ tap_water_from_public: { id: 1, name: '公営' },
96
+ tap_water_private: { id: 2, name: '私設' },
97
+ tap_water_from_well: { id: 3, name: '井戸' },
98
+ tap_water_others: { id: 4, name: 'その他' }
99
+ },
100
+ drainage_type: {
101
+ drainage_to_public: { id: 1, name: '下水' },
102
+ drainage_to_clear_well: { id: 2, name: '浄水槽' },
103
+ drainage_to_vault: { id: 3, name: '汲取' },
104
+ drainage_others: { id: 4, name: 'その他' }
105
+ },
106
+ gas_type: {
107
+ gas_city: { id: 1, name: '都市' },
108
+ gas_lp: { id: 2, name: 'プロパン' },
109
+ gas_replaced_by_electric: { id: 3, name: 'オール電化' },
110
+ gas_others: { id: 4, name: 'その他' }
111
+ },
112
+ rental_fee_payment_cycle: {
113
+ rental_fee_payed_monthly: { id: 1, name: '月額' },
114
+ rental_fee_payed_yearly: { id: 2, name: '年額' },
115
+ }
116
+ },
117
+
118
+ # ---------------------------
119
+ # Uniq
120
+ # ---------------------------
121
+ uniq: {
122
+ #
123
+ # DB columnと直接ひもづかない属性
124
+ #
125
+ story_upper_or_lower: ['地上', '地下'],
126
+ #
127
+ # Required
128
+ #
129
+ lot_measuring_method: {
130
+ lot_measured_by_public: { id: 1, name: '公簿' },
131
+ lot_measured_by_result: { id: 2, name: '実測' }
132
+ },
133
+ building_state: {
134
+ building_vacant: { id: 1, name: '空き家' },
135
+ building_resident: { id: 2, name: '居住中' },
136
+ building_rented: { id: 3, name: '賃貸中' },
137
+ building_under_construction: { id: 4, name: '建築中' },
138
+ building_construction_completed: { id: 5, name: '完成済み' },
139
+ building_before_construction: { id: 6, name: '未着工' },
140
+ building_construction_pending: { id: 7, name: '未完成' },
141
+ },
142
+ building_lot_measuring_method: {
143
+ building_lot_measured_by_public: { id: 1, name: '公簿' },
144
+ building_lot_measured_by_result: { id: 2, name: '実測' }
145
+ },
146
+ use_of_land: {
147
+ housing_land: { id: 1, name: '宅地' },
148
+ other_land: { id: 2, name: '雑種地' },
149
+ rice_field: { id: 3, name: '田' },
150
+ vege_field: { id: 4, name: '畑' },
151
+ # 旧既存宅地:
152
+ # 市街化調整区域(urban_controlled)における宅地で、
153
+ # 都市計画施工前に既に宅地となっていた物件で、旧法律では開発を許されていた
154
+ housing_land_in_urban_controlled: { id: 5, name: '旧既存宅地' },
155
+ forest: { id: 6, name: '山林' },
156
+ moor: { id: 7, name: '原野' }
157
+ },
158
+ admin_cost_payment_cycle: {
159
+ admin_cost_none: { id: 0, name: '無し' },
160
+ admin_cost_payed_monthly: { id: 1, name: '月額' },
161
+ admin_cost_payed_yearly: { id: 2, name: '年額' }
162
+ },
163
+ fix_cost_payment_cycle: {
164
+ fix_cost_none: { id: 0, name: '無し' },
165
+ fix_cost_payed_monthly: { id: 1, name: '月額' },
166
+ fix_cost_payed_yearly: { id: 2, name: '年額' }
167
+ },
168
+ administrator_work_shift: {
169
+ administrator_none: { id: 1, name: '無し' },
170
+ administrator_resident: { id: 2, name: '常駐' },
171
+ administrator_shifting: { id: 3, name: '日勤' },
172
+ administrator_patrol: { id: 4, name: '巡回' },
173
+ administrator_part_time: { id: 5, name: '非常勤' },
174
+ },
175
+ administration_type: {
176
+ admin_by_themselves: { id: 1, name: '自主管理' },
177
+ admin_by_partially_commission: { id: 2, name: '一部委託' },
178
+ admin_by_totally_commission: { id: 3, name: '全部委託' }
179
+ },
180
+ has_administrator_association: {
181
+ administrator_association_exist: { id: 1, name: '有' },
182
+ administrator_association_none: { id: 2, name: '無' }
183
+ },
184
+ condo_unit_measuring_method: {
185
+ condo_unit_measured_by_public: { id: 1, name: '公簿' },
186
+ condo_unit_measured_by_result: { id: 2, name: '実測' }
187
+ },
188
+ land_state: {
189
+ land_vacant: { id: 1, name: '更地' },
190
+ land_with_building: { id: 2, name: '建物あり' },
191
+ land_with_parking: { id: 3, name: '駐車場' },
192
+ land_with_building_to_demolish: { id: 4, name: '建物解体予定' },
193
+ land_developing: { id: 5, name: '造成中' },
194
+ land_with_others: { id: 6, name: 'その他' }
195
+ },
196
+
197
+ #
198
+ # Optional
199
+ #
200
+ #other_cost_payment_cycle: {
201
+ # other_cost_payed_at_first: { id: 1, name: '物件取得時' },
202
+ # other_cost_payed_monthly: { id: 2, name: '月額' },
203
+ # other_cost_payed_yearly: { id: 3, name: '年額' },
204
+ # other_cost_payed_every_2y: { id: 4, name: '2年毎' },
205
+ # other_cost_payed_every_3y: { id: 5, name: '3年毎' }
206
+ #},
207
+ construction_type: {
208
+ constructed_by_wood: { id: 1, name: '木造' },
209
+ constructed_by_block: { id: 2, name: 'ブロック' },
210
+ constructed_by_iron_frame: { id: 3, name: '鉄骨' },
211
+ constructed_by_rc: { id: 4, name: '鉄筋コンクリート(RC)' },
212
+ constructed_by_src: { id: 5, name: '鉄骨鉄筋コンクリート(SRC)' },
213
+ constructed_by_light_iron_frame: { id: 6, name: '軽量鉄骨' },
214
+ constructed_by_heavy_iron_frame: { id: 7, name: '重量鉄骨' },
215
+ constructed_by_alc: { id: 8, name: '軽量気泡コンクリート(ALC)' },
216
+ constructed_by_pc: { id: 9, name: 'プレキャストコンクリート(PC)' },
217
+ constructed_by_hpc: { id: 10, name: '鉄骨プレキャストコンクリート(HPC)' },
218
+ constructed_by_other: { id: 11, name: 'その他' }
219
+ },
220
+ seismic_diagnosis_state: {
221
+ seismic_diagnosis_executed: { id: 1, name: '実施' },
222
+ seismic_diagnosis_not_executed: { id: 2, name: '未実施' },
223
+ seismic_diagnosis_unknown: { id: 3, name: '不明' }
224
+ },
225
+ building_inspection_state: {
226
+ building_inspection_executed: { id: 1, name: '実施' },
227
+ building_inspection_not_executed: { id: 2, name: '未実施' },
228
+ building_inspection_unknown: { id: 3, name: '不明' },
229
+ },
230
+ daylightful_direction: {
231
+ daylightful_at_north: { id: 1, name: '北' },
232
+ daylightful_at_south: { id: 2, name: '南' },
233
+ daylightful_at_east: { id: 3, name: '東' },
234
+ daylightful_at_west: { id: 4, name: '西' },
235
+ daylightful_at_northeast: { id: 5, name: '北東' },
236
+ daylightful_at_northwest: { id: 6, name: '北西' },
237
+ daylightful_at_southeast: { id: 7, name: '南東' },
238
+ daylightful_at_southwest: { id: 8, name: '南西' }
239
+ },
240
+ parking_type: {
241
+ parking_self: { id: 1, name: '駐車場' },
242
+ parking_garage: { id: 2, name: '車庫' },
243
+ parking_neighborhood: { id: 3, name: '近隣駐車場' }
244
+ },
245
+ parking_fee_payment_cycle: {
246
+ parking_fee_payed_monthly: { id: 1, name: '月額' },
247
+ parking_fee_payed_yearly: { id: 2, name: '年額' },
248
+ parking_fee_payed_dayly: { id: 3, name: '日額' }
249
+ },
250
+ cooking_stove_type: {
251
+ cooking_stove_gas: { id: 1, name: 'ガス' },
252
+ cooking_stove_electric: { id: 2, name: '電気' },
253
+ cooking_stove_ih: { id: 3, name: 'IH' }
254
+ },
255
+ cooking_stove_burner_count: {
256
+ cooking_stove_burner_1_port: { id: 1, name: '一口' },
257
+ cooking_stove_burner_2_port: { id: 2, name: '二口' },
258
+ cooking_stove_burner_3_port: { id: 3, name: '三口' },
259
+ cooking_stove_burner_more: { id: 4, name: '四口以上' }
260
+ },
261
+ room_layout_type: {
262
+ dk: { id: 1, name: 'DK' },
263
+ ldk: { id: 2, name: 'LDK' },
264
+ sldk: { id: 3, name: 'SLDK' },
265
+ r: { id: 4, name: 'R' },
266
+ k: { id: 5, name: 'K' },
267
+ sk: { id: 6, name: 'SK' },
268
+ sdk: { id: 7, name: 'SDK' },
269
+ lk: { id: 8, name: 'LK' },
270
+ slk: { id: 9, name: 'SLK' }
271
+ },
272
+ urban_project: {
273
+ urban_promoted: { id: 1, name: '市街化区域' },
274
+ urban_controlled: { id: 2, name: '市街化調整区域' },
275
+ urban_neutral: { id: 3, name: '非線引区域' },
276
+ urban_out_of_projected: { id: 4, name: '都市計画区域外' },
277
+ urban_sub_projected: { id: 5, name: '準都市計画区域' }
278
+ },
279
+ zoning_type: {
280
+ zone_first_low_rise: { id: 1, name: '一種低層' },
281
+ zone_second_low_rise: { id: 2, name: '二種低層' },
282
+ zone_first_mid_high_rise: { id: 3, name: '一種中高層' },
283
+ zone_second_mid_high_rise: { id: 4, name: '二種中高層' },
284
+ zone_first_resident: { id: 5, name: '一種住居' },
285
+ zone_second_resident: { id: 6, name: '二種住居' },
286
+ zone_sub_resident: { id: 7, name: '準住居' },
287
+ zone_neighborhood_commercial: { id: 8, name: '近隣商業' },
288
+ zone_commercial: { id: 9, name: '商業' },
289
+ zone_sub_industrial: { id: 10, name: '準工業' },
290
+ zone_industrial: { id: 11, name: '工業' },
291
+ zone_industrial_exclusive: { id: 12, name: '工業専用' },
292
+ zone_none: { id: 13, name: '指定なし' }
293
+ },
294
+ right_of_land: {
295
+ right_of_ownership: { id: 1, name: '所有権' },
296
+ right_of_surface: { id: 2, name: '地上権' },
297
+ right_of_lease: { id: 3, name: '賃借権' },
298
+ right_of_lease_common: { id: 4, name: '普通賃借権' },
299
+ right_of_lease_restricted: { id: 5, name: '定期賃借権' },
300
+ right_of_surface_common: { id: 6, name: '普通地上権' },
301
+ right_of_surface_restricted: { id: 7, name: '定期地上権' }
302
+ },
303
+ nation_land_act_state: {
304
+ nl_act_required: { id: 1, name: '要' },
305
+ nl_act_filing: { id: 2, name: '届け出中' },
306
+ nl_act_not_required: { id: 3, name: '不要' },
307
+ nl_act_none: { id: 4, name: '指定なし' },
308
+ nl_act_checked: { id: 5, name: '確認済み' },
309
+ },
310
+ },
311
+
312
+ # ---------------------------
313
+ # Room
314
+ # ---------------------------
315
+ room: {
316
+ genre: {
317
+ western: { id: 1, name: '洋室' },
318
+ japanese: { id: 2, name: '和室' },
319
+ living: { id: 3, name: 'リビング' },
320
+ dining_kitchen: { id: 4, name: 'ダイニングキッチン' },
321
+ living_dining_kitchen: { id: 5, name: 'リビングダイニングキッチン' }
322
+ }
323
+ },
324
+
325
+ # ---------------------------
326
+ # AvailableFacility
327
+ # ---------------------------
328
+ available_facility: {
329
+ genre: {
330
+ elementary_school: { id: 1, name: '最寄り小学校' },
331
+ middle_school: { id: 2, name: '最寄り中学校' },
332
+ convenience_store: { id: 3, name: '最寄りコンビニ' },
333
+ grocery_store: { id: 4, name: '最寄りスーパー' },
334
+ hospital: { id: 5, name: '最寄り総合病院' }
335
+ }
336
+ },
337
+
338
+ # ---------------------------
339
+ # Content
340
+ # ---------------------------
341
+ content: {
342
+ use_for: {
343
+ layout: { id: 1, name: '間取り図・図面' },
344
+ exterior: { id: 2, name: '外観' },
345
+ living: { id: 3, name: '居間' },
346
+ interior: { id: 4, name: '室内・内装' },
347
+ shared: { id: 5, name: '共用部' },
348
+ surrounding: { id: 6, name: '周辺環境' },
349
+ other_usage: { id: 7, name: 'その他' }
350
+ }
351
+ },
352
+
353
+ # ---------------------------
354
+ # Event
355
+ # ---------------------------
356
+ event: {
357
+ public_state: {
358
+ public_waiting: { id: 1, name: 'オープン前' },
359
+ public_running: { id: 2, name: 'オープン中' },
360
+ public_closed: { id: 3, name: 'クローズ' }
361
+ }
362
+ },
363
+
364
+ # ---------------------------
365
+ # MiscFee
366
+ # ---------------------------
367
+ misc_fee: {
368
+ genre: {
369
+ resident_membership: { id: 1, name: '町会費' },
370
+ self_government: { id: 2, name: '自治会費' },
371
+ administration: { id: 3, name: '共益/管理費' },
372
+ cable_broadcast: { id: 4, name: '有線放送利用費' },
373
+ internet: { id: 5, name: 'インターネット利用費' },
374
+ catv: { id: 6, name: 'CATV利用費' },
375
+ spa_use: { id: 7, name: '温泉使用料' },
376
+ spa_provider: { id: 8, name: '温泉権利金' },
377
+ other_fee: { id: 9, name: 'その他' }
378
+ },
379
+ payment_cycle: {
380
+ payed_at_first: { id: 1, name: '物件取得時' },
381
+ payed_monthly: { id: 2, name: '月額' },
382
+ payed_yearly: { id: 3, name: '年額' },
383
+ payed_every_2y: { id: 4, name: '2年毎' },
384
+ payed_every_3y: { id: 5, name: '3年毎' }
385
+ },
386
+ },
387
+
388
+ # ---------------------------
389
+ # AvailableRoad
390
+ # ---------------------------
391
+ available_road: {
392
+ direction: {
393
+ at_north: { id: 1, name: '北' },
394
+ at_south: { id: 2, name: '南' },
395
+ at_east: { id: 3, name: '東' },
396
+ at_west: { id: 4, name: '西' },
397
+ at_northeast: { id: 5, name: '北東' },
398
+ at_northwest: { id: 6, name: '北西' },
399
+ at_southeast: { id: 7, name: '南東' },
400
+ at_southwest: { id: 8, name: '南西' }
401
+ },
402
+ genre: {
403
+ public_road: { id: 1, name: '公道' },
404
+ private_road: { id: 2, name: '私道' }
405
+ }
406
+ }
407
+ }.freeze
408
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dimensional-enum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Watanabe, Mitsutoshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Extends to handle Rails Enum with multi dimensional attributes.
70
+ email:
71
+ - mitsutoshi@reivo.co.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - dimensional-enum.gemspec
82
+ - lib/dimensional/enum.rb
83
+ - lib/dimensional/enum/attribute.rb
84
+ - lib/dimensional/enum/attributes.rb
85
+ - lib/dimensional/enum/version.rb
86
+ - spec/attribute_spec.rb
87
+ - spec/attributes_spec.rb
88
+ - spec/dimensional-enum_spec.rb
89
+ - spec/spec_helper.rb
90
+ - spec/support/sample.rb
91
+ homepage: ''
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Extends to handle Rails Enum with multi dimensional attributes.
115
+ test_files:
116
+ - spec/attribute_spec.rb
117
+ - spec/attributes_spec.rb
118
+ - spec/dimensional-enum_spec.rb
119
+ - spec/spec_helper.rb
120
+ - spec/support/sample.rb