dummy-apartment 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -9
- data/dummy-apartment.gemspec +1 -1
- data/lib/data.yml +1 -0
- data/lib/dummy-apartment.rb +36 -1
- data/lib/dummy-apartment/version.rb +1 -1
- data/spec/dummy-apartment_spec.rb +71 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c7b373277d13ea9e273cc82d0964bce85de2be
|
4
|
+
data.tar.gz: 188d14ebc395f91283b779dd1a5b7b680405b2fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62ce22f2174f9ceec7eaae9a1bbc74602d9299e347325e13400a5edc2605444fbf3a4a6fcc9048f3c69cae0b5c7d5de803907dfe5699030f5df23fa71dda294
|
7
|
+
data.tar.gz: b0e42004449f0ef8bce267dcad776d866b401eddea81aad9de0d90eed158216ffe82fd5e5cb22fcae761ce78c87b2349a228ca50be82dd0fbab49dfd25083273
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##
|
1
|
+
## DummyApartment
|
2
2
|
|
3
3
|
This gem generates dummy information of apartment including
|
4
4
|
|
@@ -7,6 +7,10 @@ This gem generates dummy information of apartment including
|
|
7
7
|
* latitude/longitude
|
8
8
|
* floor/top
|
9
9
|
* room number
|
10
|
+
* room type
|
11
|
+
* keeping pets
|
12
|
+
* playable the musical instruments or not
|
13
|
+
* floor type
|
10
14
|
|
11
15
|
### Installation
|
12
16
|
|
@@ -24,15 +28,14 @@ Or just:
|
|
24
28
|
|
25
29
|
### Usage
|
26
30
|
|
31
|
+
require 'dummy-apartment'
|
32
|
+
|
27
33
|
apartment = DummyApartment.generate
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# :room_number => "203"}
|
34
|
-
|
35
|
-
apartment.room_floor #=> 2
|
34
|
+
|
35
|
+
apartment.address #=> "群馬県長谷市60"
|
36
|
+
apartment.building_name #=> "石井コーポ"
|
37
|
+
apartment_room_floor #=> 2
|
38
|
+
|
36
39
|
apartment[:room_floor] #=> 2
|
37
40
|
apartment['room_floor'] #=> 2
|
38
41
|
|
data/dummy-apartment.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Joe-noh"]
|
10
10
|
spec.email = ["goflb.jh@gmail.com"]
|
11
11
|
spec.summary = %q{Generator of Japanese Apartment Dummy Data}
|
12
|
-
spec.description = %q{This gem generates dummy information of apartment, including address, name, room number and
|
12
|
+
spec.description = %q{This gem generates dummy information of apartment, including address, name, room number, geo and more.}
|
13
13
|
spec.homepage = "https://github.com/Joe-noh/dummy-apartment"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/data.yml
CHANGED
@@ -3,3 +3,4 @@ cities: ["原田市", "熊塚市", "佐々木市", "大応寺市", "野村市",
|
|
3
3
|
building_name:
|
4
4
|
first_half: ["石井", "山城", "大井台", "片山", "大山", "植木", "長嶺", "東", "南", "西", "北", "市橋", "富岡", "田町", "江頭", "ポール", "牧", "片岡", "鶴", "太郎", "メゾン・ド", "SAKURA", "紫", "碧"]
|
5
5
|
second_half: ["コーポ", "ハイツ", "サンハイツ", "メゾン", "パレス", "ネオパレス", "プロミネンス", "カーサ", "Petit", "プチトマト", "パーク", "ネックス", "エスポワール", "エクセル", "グラン", "コンフォート", "エトワール", "フローラ", "リバティ", "荘"]
|
6
|
+
room_type: ["1R", "1K", "1DK", "1LDK", "2K", "2DK", "2LDK", "3K", "3DK", "3LDK"]
|
data/lib/dummy-apartment.rb
CHANGED
@@ -11,7 +11,8 @@ class DummyApartment
|
|
11
11
|
|
12
12
|
@@dic ||= Psych.load(File.open(YML).read)
|
13
13
|
|
14
|
-
ATTRIBUTES = %i(address building_name geo top_floor room_floor room_number)
|
14
|
+
ATTRIBUTES = %i(address building_name geo top_floor room_floor room_number room_type keeping_pets) +
|
15
|
+
%i(playing_the_instruments place_for_washing_machine floor_type)
|
15
16
|
|
16
17
|
attr_reader *ATTRIBUTES
|
17
18
|
|
@@ -22,6 +23,11 @@ class DummyApartment
|
|
22
23
|
top_floor = gen_top_floor
|
23
24
|
room_floor = gen_room_floor(top_floor)
|
24
25
|
room_number = gen_room_number(room_floor)
|
26
|
+
room_type = gen_room_type
|
27
|
+
keeping_pets = gen_keeping_pets
|
28
|
+
playing_the_instruments = gen_playing_the_instruments
|
29
|
+
place_for_washing_machine = gen_place_for_washing_machine
|
30
|
+
floor_type = gen_floor_type
|
25
31
|
|
26
32
|
values = ATTRIBUTES.map{ |attr| eval "#{attr}" }
|
27
33
|
DummyApartment.new(Hash[ATTRIBUTES.zip values])
|
@@ -64,6 +70,14 @@ class DummyApartment
|
|
64
70
|
RUBY
|
65
71
|
end
|
66
72
|
|
73
|
+
def flooring?
|
74
|
+
@floor_type == :flooring
|
75
|
+
end
|
76
|
+
|
77
|
+
def tatami?
|
78
|
+
@floor_type == :tatami
|
79
|
+
end
|
80
|
+
|
67
81
|
def method_missing(method_name, *args)
|
68
82
|
@hash.send(method_name, *args) if @hash.respond_to? method_name
|
69
83
|
end
|
@@ -104,6 +118,27 @@ class DummyApartment
|
|
104
118
|
"#{floor}0#{rand(0..9)}"
|
105
119
|
end
|
106
120
|
|
121
|
+
def self.gen_room_type
|
122
|
+
types = @@dic['room_type']
|
123
|
+
types.sample
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.gen_keeping_pets
|
127
|
+
['可', '不可', '要相談'].sample
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.gen_playing_the_instruments
|
131
|
+
['可', '不可'].sample
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.gen_place_for_washing_machine
|
135
|
+
['室内', '室外', '無し'].sample
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.gen_floor_type
|
139
|
+
[:flooring, :tatami].sample
|
140
|
+
end
|
141
|
+
|
107
142
|
private_class_method *self.public_methods.grep(/\Agen_/)
|
108
143
|
|
109
144
|
private
|
@@ -94,4 +94,75 @@ describe DummyApartment do
|
|
94
94
|
expect(room_number).to start_with room_floor.to_s
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
describe 'Room Type' do
|
99
|
+
let(:room_type){ @apartment[:room_type] }
|
100
|
+
|
101
|
+
it 'should be a String object' do
|
102
|
+
expect(room_type).to be_a String
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should be match the format' do
|
106
|
+
expect(room_type).to match /\A\d(R|[LDK]{1,3})\z/
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'Keeping Pets' do
|
111
|
+
let(:keeping_pets){ @apartment[:keeping_pets] }
|
112
|
+
|
113
|
+
it 'should be a String object' do
|
114
|
+
expect(keeping_pets).to be_a String
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should equal "可", "不可" or "要相談"' do
|
118
|
+
expect(keeping_pets).to match /\A(可|不可|要相談)\z/
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'Playing the Instruments' do
|
123
|
+
let(:playing_the_instruments){ @apartment[:playing_the_instruments] }
|
124
|
+
|
125
|
+
it 'should be a String object' do
|
126
|
+
expect(playing_the_instruments).to be_a String
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should equal "可" or "不可"' do
|
130
|
+
expect(playing_the_instruments).to match /\A不?可\z/
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe 'Place for Washing Machine' do
|
135
|
+
let(:place_for_washing_machine){ @apartment[:place_for_washing_machine] }
|
136
|
+
|
137
|
+
it 'should be a String object' do
|
138
|
+
expect(place_for_washing_machine).to be_a String
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should equal "室内", "室外" or "無し"' do
|
142
|
+
expect(place_for_washing_machine).to match /\A(室内|室外|無し)\z/
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'Floor Type' do
|
147
|
+
let(:floor_type){ @apartment[:floor_type] }
|
148
|
+
|
149
|
+
it 'should be a Symbol' do
|
150
|
+
expect(floor_type).to be_a Symbol
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should equal :flooring or :tatami' do
|
154
|
+
expect([:flooring, :tatami]).to include floor_type
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should consistent between #floor_type, #tatami? and #flooring?' do
|
158
|
+
case floor_type
|
159
|
+
when :flooring
|
160
|
+
expect(@apartment.flooring?).to be_true
|
161
|
+
expect(@apartment.tatami?).to be_false
|
162
|
+
when :tatami
|
163
|
+
expect(@apartment.flooring?).to be_false
|
164
|
+
expect(@apartment.tatami?).to be_true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
97
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dummy-apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe-noh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: This gem generates dummy information of apartment, including address,
|
56
|
-
name, room number and
|
56
|
+
name, room number, geo and more.
|
57
57
|
email:
|
58
58
|
- goflb.jh@gmail.com
|
59
59
|
executables: []
|