dummy-apartment 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -0
- data/dummy-apartment.gemspec +3 -1
- data/lib/data.yml +1 -1
- data/lib/dummy-apartment.rb +48 -2
- data/spec/dummy-apartment_spec.rb +83 -9
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f86c8fd8c82def08f9022a7c59126b11dc2bd6
|
4
|
+
data.tar.gz: 9499ffb2cdfb0061fa77f5f410db710edd4e29cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d25ab1f3ba7a8cf8ca0fabfcf81f5d72472951086b6a89266cea2f48d8f389f64998913cc1b2e8f74422aa100139c219244716987e09c638ac0444356ec75c
|
7
|
+
data.tar.gz: 7c0efcbf27a06b895cdef2f80cde13d57924eaa9bf04f597228f57854cf5f43cd23bc02b4a408b650a6cec993ce1925bde95ff3a731f4431cb3485bf4e600164
|
data/README.md
CHANGED
@@ -18,6 +18,21 @@ This gem generates dummy information of apartment including
|
|
18
18
|
* is self-locking door?
|
19
19
|
* whether the manager patrols
|
20
20
|
* names of closest stations
|
21
|
+
* minutes to reach the stations
|
22
|
+
* on foot
|
23
|
+
* by bus
|
24
|
+
* whether bath and toilet are in different rooms
|
25
|
+
* date of
|
26
|
+
* construction
|
27
|
+
* renovation
|
28
|
+
* monthly rent
|
29
|
+
* monthly management fee
|
30
|
+
* monthly parking price
|
31
|
+
* deposit money
|
32
|
+
* finder's reward
|
33
|
+
* leasing term is fixed or not
|
34
|
+
* the term if it's fixed
|
35
|
+
* renewal fee if it's fixed
|
21
36
|
|
22
37
|
### Installation
|
23
38
|
|
@@ -51,6 +66,43 @@ Or just:
|
|
51
66
|
apartment.to_hash
|
52
67
|
#=> {address: "群馬県長谷市60", building_name: "ハイツ谷川", ... }
|
53
68
|
|
69
|
+
#### Instance Methods
|
70
|
+
|
71
|
+
* `address`
|
72
|
+
* `building_name`
|
73
|
+
* `geo`
|
74
|
+
* `top_floor`
|
75
|
+
* `room_floor`
|
76
|
+
* `room_number`
|
77
|
+
* `room_type`
|
78
|
+
* `occupied_area`
|
79
|
+
* `keeping_pets`
|
80
|
+
* `playing_the_instruments`
|
81
|
+
* `place_for_washing_machine`
|
82
|
+
* `floor_type`
|
83
|
+
* `flooring?`
|
84
|
+
* `tatami?`
|
85
|
+
* `exposure`
|
86
|
+
* `air_conditioner_equipped?`
|
87
|
+
* `self_locking?`
|
88
|
+
* `manager_patrol?`
|
89
|
+
* `nearest_stations`
|
90
|
+
* `minutes_to_stations`
|
91
|
+
* `bath_toilet_separated?`
|
92
|
+
* `date_of_construction`
|
93
|
+
* `renovated?`
|
94
|
+
* `date_of_renovation`
|
95
|
+
* `monthly_rent`
|
96
|
+
* `management_fee`
|
97
|
+
* `parking_price`
|
98
|
+
* `deposit`
|
99
|
+
* `finders_reward`
|
100
|
+
* `fixed_term_lease?`
|
101
|
+
* `lease_term`
|
102
|
+
* `renewal_fee`
|
103
|
+
* `to_hash`
|
104
|
+
|
105
|
+
|
54
106
|
### Contributing
|
55
107
|
|
56
108
|
1. Fork it ( https://github.com/Joe-noh/dummy-apartment/fork )
|
data/dummy-apartment.gemspec
CHANGED
@@ -18,7 +18,9 @@ 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.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
24
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
26
|
end
|
data/lib/data.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
prefectures: ["北海道", "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県", "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", "鳥取県", "島根県", "岡山県", "広島県", "山口県", "徳島県", "香川県", "愛媛県", "高知県", "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県"]
|
2
2
|
cities: ["原田市", "熊塚市", "佐々木市", "大応寺市", "野村市", "浦部市", "浦田市", "白田市", "赤田市", "龍ノ浦市", "東海林市", "長谷市", "犬山市", "田所市", "設楽市", "千田市", "大沢市", "名進市", "長郷市", "岡田市", "郷田林市", "遅沢町", "池内町", "東池内町", "高丘町", "泉町", "塚北町", "大井村", "峡谷村", "ドイツ村", "羽生田村", "八つ墓村"]
|
3
3
|
building_name:
|
4
|
-
first_half: ["石井", "山城", "大井台", "片山", "大山", "植木", "長嶺", "東", "南", "西", "北", "市橋", "富岡", "田町", "江頭", "ポール", "牧", "片岡", "鶴", "太郎", "
|
4
|
+
first_half: ["石井", "山城", "大井台", "片山", "大山", "植木", "長嶺", "東", "南", "西", "北", "市橋", "富岡", "田町", "江頭", "ポール", "牧", "片岡", "鶴", "太郎", "メゾン・ド・", "SAKURA", "紫", "碧"]
|
5
5
|
second_half: ["コーポ", "ハイツ", "サンハイツ", "メゾン", "パレス", "ネオパレス", "プロミネンス", "カーサ", "Petit", "プチトマト", "パーク", "ネックス", "エスポワール", "エクセル", "グラン", "コンフォート", "エトワール", "フローラ", "リバティ", "荘"]
|
6
6
|
room_type: ["1R", "1K", "1DK", "1LDK", "2K", "2DK", "2LDK", "3K", "3DK", "3LDK"]
|
7
7
|
station: ["城東駅", "庄内駅", "白浜駅", "白石駅", "武田駅", "望月駅", "和田駅", "久保駅", "心斎橋駅", "仁木駅", "西ヶ原駅", "東駅", "西駅", "南駅", "北駅", "酒田駅", "桜木駅", "鯖江駅", "藤江駅", "富士見駅", "古川駅", "保見駅", "元町駅", "三雲駅", "水沢駅", "緑駅", "峰山駅", "宮下駅", "武蔵駅", "村山駅", "芝田駅", "中島駅", "鳴門駅", "小岩井駅", "郷間駅", "櫛田駅", "広井公園駅", "ヨウ素駅"]
|
data/lib/dummy-apartment.rb
CHANGED
@@ -4,7 +4,7 @@ require 'psych'
|
|
4
4
|
require 'date'
|
5
5
|
|
6
6
|
class DummyApartment
|
7
|
-
VERSION = "0.
|
7
|
+
VERSION = "0.2.1"
|
8
8
|
YML = File.expand_path('../data.yml', __FILE__)
|
9
9
|
|
10
10
|
@@dic ||= Psych.load(File.open(YML).read)
|
@@ -13,7 +13,8 @@ class DummyApartment
|
|
13
13
|
:keeping_pets, :playing_the_instruments, :place_for_washing_machine, :floor_type,
|
14
14
|
:exposure, :air_conditioner_equipped, :self_locking, :manager_patrol, :nearest_stations,
|
15
15
|
:minutes_to_stations, :occupied_area, :bath_toilet_separated, :date_of_construction,
|
16
|
-
:date_of_renovation
|
16
|
+
:date_of_renovation, :monthly_rent, :management_fee, :parking_price, :deposit,
|
17
|
+
:finders_reward, :fixed_term_lease, :lease_term, :renewal_fee]
|
17
18
|
|
18
19
|
attr_accessor *ATTRIBUTES
|
19
20
|
|
@@ -39,6 +40,14 @@ class DummyApartment
|
|
39
40
|
bath_toilet_separated = gen_true_or_false
|
40
41
|
date_of_construction = gen_date_of_construction
|
41
42
|
date_of_renovation = gen_date_of_renovation(date_of_construction)
|
43
|
+
monthly_rent = gen_monthly_rent(occupied_area)
|
44
|
+
management_fee = gen_management_fee
|
45
|
+
parking_price = gen_parking_price
|
46
|
+
deposit = gen_deposit(monthly_rent)
|
47
|
+
finders_reward = gen_finders_reward(monthly_rent)
|
48
|
+
fixed_term_lease = gen_true_or_false
|
49
|
+
lease_term = gen_lease_term(fixed_term_lease)
|
50
|
+
renewal_fee = gen_renewal_fee(fixed_term_lease, monthly_rent)
|
42
51
|
|
43
52
|
values = ATTRIBUTES.map{ |attr| eval "#{attr}" }
|
44
53
|
DummyApartment.new(Hash[ATTRIBUTES.zip values])
|
@@ -76,6 +85,10 @@ class DummyApartment
|
|
76
85
|
!@date_of_renovation.nil?
|
77
86
|
end
|
78
87
|
|
88
|
+
def fixed_term_lease?
|
89
|
+
@fixed_term_lease
|
90
|
+
end
|
91
|
+
|
79
92
|
def to_hash
|
80
93
|
Hash[ATTRIBUTES.map{|attr| [attr, instance_variable_get("@#{attr}")] }]
|
81
94
|
end
|
@@ -155,6 +168,39 @@ class DummyApartment
|
|
155
168
|
[true, false].sample ? rand(older_limit .. Date.today) : nil
|
156
169
|
end
|
157
170
|
|
171
|
+
def self.gen_monthly_rent(occupied_area)
|
172
|
+
# base(15m^2) == 20000
|
173
|
+
# base(65^m2) == 340000
|
174
|
+
base = 80*occupied_area**2 + 2000
|
175
|
+
base.round(-3) + rand(-5 .. 5)*1000
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.gen_management_fee
|
179
|
+
rand(0 .. 10) * 1000
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.gen_parking_price
|
183
|
+
rand(0 .. 10) * 1000
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.gen_deposit(monthly_rent)
|
187
|
+
[0, 1, 1, 1, 1, 2].sample * monthly_rent
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.gen_finders_reward(monthly_rent)
|
191
|
+
[0, 1, 1, 1, 1, 2].sample * monthly_rent
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.gen_lease_term(fixed)
|
195
|
+
return nil unless fixed
|
196
|
+
rand(1 .. 3)
|
197
|
+
end
|
198
|
+
|
199
|
+
def self.gen_renewal_fee(fixed, monthly_rent)
|
200
|
+
return nil unless fixed
|
201
|
+
rand(1 .. 3) * monthly_rent
|
202
|
+
end
|
203
|
+
|
158
204
|
private_class_method *self.public_methods.grep(/\Agen_/)
|
159
205
|
|
160
206
|
private
|
@@ -31,8 +31,8 @@ describe DummyApartment do
|
|
31
31
|
|
32
32
|
it 'should have the accessor methods' do
|
33
33
|
DummyApartment::ATTRIBUTES.each do |attr|
|
34
|
-
expect(@apartment.respond_to? attr).to
|
35
|
-
expect(@apartment.respond_to? "#{attr}=").to
|
34
|
+
expect(@apartment.respond_to? attr).to be_truthy
|
35
|
+
expect(@apartment.respond_to? "#{attr}=").to be_truthy
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -183,11 +183,11 @@ describe DummyApartment do
|
|
183
183
|
|
184
184
|
case apartment.floor_type
|
185
185
|
when :flooring
|
186
|
-
expect(apartment.flooring?).to
|
187
|
-
expect(apartment.tatami?).to
|
186
|
+
expect(apartment.flooring?).to be_truthy
|
187
|
+
expect(apartment.tatami?).to be_falsey
|
188
188
|
when :tatami
|
189
|
-
expect(apartment.flooring?).to
|
190
|
-
expect(apartment.tatami?).to
|
189
|
+
expect(apartment.flooring?).to be_falsey
|
190
|
+
expect(apartment.tatami?).to be_truthy
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
@@ -237,7 +237,7 @@ describe DummyApartment do
|
|
237
237
|
|
238
238
|
it 'should be an Array of Strings' do
|
239
239
|
expect(nearest_stations).to be_an Array
|
240
|
-
expect(nearest_stations.all?{|s| String === s}).to
|
240
|
+
expect(nearest_stations.all?{|s| String === s}).to be_truthy
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should be an Array whose size is one or two' do
|
@@ -249,7 +249,7 @@ describe DummyApartment do
|
|
249
249
|
describe "Stations' Name" do
|
250
250
|
it "should end with '駅'" do
|
251
251
|
100.times do
|
252
|
-
expect(Build.nearest_stations.all?{|name| name.end_with? '駅'}).to
|
252
|
+
expect(Build.nearest_stations.all?{|name| name.end_with? '駅'}).to be_truthy
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -260,7 +260,7 @@ describe DummyApartment do
|
|
260
260
|
|
261
261
|
it 'should be an Array of Hashes' do
|
262
262
|
expect(minutes_to_stations).to be_an Array
|
263
|
-
expect(minutes_to_stations.all?{|h| Hash === h}).to
|
263
|
+
expect(minutes_to_stations.all?{|h| Hash === h}).to be_truthy
|
264
264
|
end
|
265
265
|
|
266
266
|
it 'should be an Array the size of which is equal to of nearest_stations' do
|
@@ -325,4 +325,78 @@ describe DummyApartment do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
end
|
328
|
+
|
329
|
+
describe 'Monthly Rent' do
|
330
|
+
it 'should be between 15000 and 305000' do
|
331
|
+
100.times do
|
332
|
+
expect(15000 .. 345000).to include Build.monthly_rent
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe 'Management Fee' do
|
338
|
+
it 'should be less than or equal to 10000' do
|
339
|
+
expect(Build.management_fee).to be <= 10000
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe 'Parking Price' do
|
344
|
+
it 'should be less than or equal to 10000' do
|
345
|
+
expect(Build.management_fee).to be <= 10000
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe 'Deposit' do
|
350
|
+
it 'should be less than or equal to 2*monthly_rent' do
|
351
|
+
100.times do
|
352
|
+
rent, fee = Build[:monthly_rent, :management_fee]
|
353
|
+
expect(fee).to be <= 2*rent
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
describe "Finder's Reward" do
|
359
|
+
it 'should be less than or equal to 2*monthly_rent' do
|
360
|
+
100.times do
|
361
|
+
rent, reward = Build[:monthly_rent, :finders_reward]
|
362
|
+
expect(reward).to be <= 2*rent
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe 'Fixed Term Lease' do
|
368
|
+
it 'should be equal to #fixed_term_lease?' do
|
369
|
+
100.times do
|
370
|
+
apartment = DummyApartment.generate
|
371
|
+
expect(apartment.fixed_term_lease).to eql apartment.fixed_term_lease?
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe 'Lease Term' do
|
376
|
+
it 'should be between 1 and 3' do
|
377
|
+
100.times do
|
378
|
+
apartment = DummyApartment.generate
|
379
|
+
if apartment.fixed_term_lease?
|
380
|
+
expect(apartment.lease_term).to be_between(1, 3)
|
381
|
+
else
|
382
|
+
expect(apartment.lease_term).to be_nil
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe 'Renewal Fee' do
|
389
|
+
it 'should be between monthly_fee and 3*monthly_rent' do
|
390
|
+
100.times do
|
391
|
+
apartment = DummyApartment.generate
|
392
|
+
if apartment.fixed_term_lease?
|
393
|
+
candidates = (1..3).map { |i| i * apartment.monthly_rent }
|
394
|
+
expect(candidates).to include apartment.renewal_fee
|
395
|
+
else
|
396
|
+
expect(apartment.renewal_fee).to be_nil
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
328
402
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dummy-apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '3.0'
|
55
55
|
description: This gem generates dummy information of apartment, including address,
|
56
56
|
name, room number, geo and more.
|
57
57
|
email:
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -82,17 +82,17 @@ require_paths:
|
|
82
82
|
- lib
|
83
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
87
|
+
version: 1.9.3
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.0
|
95
|
+
rubygems_version: 2.2.0
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Generator of Japanese Apartment Dummy Data
|