dimensional-enum 0.0.4 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15a7ee9e845e48918a901272050d827d050a9033
4
- data.tar.gz: 9417d03ff6e1cbff465bb069c7cbcf3e35256e1b
3
+ metadata.gz: af647c26e4ae6875f8db96039f1ed32aec3b3007
4
+ data.tar.gz: 6781108ffedc8296732d86eff220698b95f3a525
5
5
  SHA512:
6
- metadata.gz: e175879e0db67e6447f13472f534b037751623c5d8c8bda21da609da8948a22da8bfed06fba3d92214162ba7a19ab9928c950dad2cb3658b36378e641a5458b9
7
- data.tar.gz: 198d48a50a772d9d3ec28d6390611252c0a6ce3208000bb1eaa0c3e98c0adcc46f7b095dac8cd60eafc22121592d41b6e33888eb80d592fd0a18f95f72cff3c8
6
+ metadata.gz: f1db3a406c9c3f2ffb19c36a8199b04f6e3f2a2e67698625028148327de1ef80229f87e1bf8560672dfff3756b83eeae3bda522f52764ccad62729e8f0a931a1
7
+ data.tar.gz: cf01ebf70e298ef17a29ad1a27e695319eaf755a205db0faa5e1d6f3ddcf34f0d530dbbd0440dd57998b3582a5cd1b2e4f5c1d923b63a83267eb5d68867adb4e
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency "activesupport", "~> 4.1"
21
22
  spec.add_runtime_dependency "activerecord", "~> 4.1"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.7"
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/module/delegation"
2
+
1
3
  require "dimensional/enum/version"
2
4
  require "dimensional/enum/attributes"
3
5
  require "dimensional/enum/attribute"
@@ -2,6 +2,8 @@ module Dimensional
2
2
  module Enum
3
3
  class Attribute
4
4
 
5
+ delegate *(String.instance_methods - Object.instance_methods), to: :to_s
6
+
5
7
  def initialize( enum_attr_key, enum_attribute )
6
8
  @enum_attr_key = enum_attr_key
7
9
  @enum_attribute = enum_attribute
@@ -11,6 +13,10 @@ module Dimensional
11
13
  to_s == other
12
14
  end
13
15
 
16
+ def <=>( other )
17
+ to_s <=> other
18
+ end
19
+
14
20
  def id
15
21
  @enum_attribute[label][:id]
16
22
  rescue
@@ -45,4 +51,4 @@ module Dimensional
45
51
 
46
52
  end
47
53
  end
48
- end
54
+ end
@@ -1,5 +1,5 @@
1
1
  module Dimensional
2
2
  module Enum
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -52,5 +52,17 @@ module Dimensional::Enum
52
52
  expect( enum_attribute == "sale_on_nego" ).to eq true
53
53
  end
54
54
 
55
+ describe "Stringを想定したメソッドよびだしがto_sに対しておこなわれること" do
56
+ let(:enum_attributes) { Attributes.new Sample::ENUM_ATTRIBUTES[:core] }
57
+ let(:enum_attribute) { enum_attribute = Attribute.new "released", enum_attributes.to_attribute_h(:status) }
58
+ it "#empty?" do
59
+ expect( enum_attribute.empty? ).to eq false
60
+ end
61
+
62
+ it "#upcase" do
63
+ expect( enum_attribute.upcase ).to eq "RELEASED"
64
+ end
65
+ end
66
+
55
67
  end
56
68
  end
@@ -16,393 +16,11 @@ module Sample
16
16
  public_to_suggestees: { id: 2, name: '提案した会員にのみ公開' },
17
17
  public_to_none: { id: 3, name: '非公開' },
18
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
19
  status: {
29
20
  released: { id: 1, name: '入稿済み' },
30
21
  draft: { id: 2, name: '下書き' },
31
22
  illegal: { id: 3, name: '強制非表示' }
32
23
  }
33
24
  },
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
25
  }.freeze
408
26
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dimensional-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watanabe, Mitsutoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activerecord
15
29
  requirement: !ruby/object:Gem::Requirement