dummy-apartment 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bcd99e1fe4217d02817e2520ee29720279797317
4
+ data.tar.gz: 81f13232754fdab7da1145e864cad78c2549330f
5
+ SHA512:
6
+ metadata.gz: 56febfb9b8a3b00568596e751b4207b2f6db04f5bda24852499b47fbc9f76c08dfe81c6acc91b2bc8d5fac9df280f0fc4844a195ab63adf38adc9b53df24f832
7
+ data.tar.gz: 36f309dc705fbcb0af98e964fdfdd5d83fc34e77aaa5d07e5bccc90def576096ec2292ab093e36efd636e95f282f819bd08351225fd575d6147e45dac3966e2c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in random-apartment.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Joe-noh
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,42 @@
1
+ ## Dummy::Apartment
2
+
3
+ This gem generates dummy information of apartment including
4
+
5
+ * address
6
+ * building name
7
+ * latitude/longitude
8
+ * floor/top
9
+ * room number
10
+
11
+ ### Installation
12
+
13
+ Add this line to Gemfile:
14
+
15
+ gem 'dummy-apartment'
16
+
17
+ And then:
18
+
19
+ $ bundle
20
+
21
+ Or just:
22
+
23
+ $ gem install dummy-apartment
24
+
25
+ ### Usage
26
+
27
+ DummyApartment.generate
28
+ #=> {:address => "群馬県長谷市60",
29
+ # :building_name => "江頭Petit",
30
+ # :geo => [36.878327083956236, 139.92838722714708],
31
+ # :top_floor => 4,
32
+ # :room_floor => 2,
33
+ # :room_number => "203"}
34
+
35
+
36
+ ### Contributing
37
+
38
+ 1. Fork it ( https://github.com/Joe-noh/dummy-apartment/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request, will be welcomed.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dummy-apartment/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dummy-apartment"
8
+ spec.version = DummyApartment::VERSION
9
+ spec.authors = ["Joe-noh"]
10
+ spec.email = ["goflb.jh@gmail.com"]
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 geo}
13
+ spec.homepage = "https://github.com/Joe-noh/dummy-apartment"
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_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/lib/data.yml ADDED
@@ -0,0 +1,5 @@
1
+ prefectures: ["北海道", "青森県", "岩手県", "宮城県", "秋田県", "山形県", "福島県", "茨城県", "栃木県", "群馬県", "埼玉県", "千葉県", "東京都", "神奈川県", "新潟県", "富山県", "石川県", "福井県", "山梨県", "長野県", "岐阜県", "静岡県", "愛知県", "三重県", "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", "鳥取県", "島根県", "岡山県", "広島県", "山口県", "徳島県", "香川県", "愛媛県", "高知県", "福岡県", "佐賀県", "長崎県", "熊本県", "大分県", "宮崎県", "鹿児島県", "沖縄県"]
2
+ cities: ["原田市", "熊塚市", "佐々木市", "大応寺市", "野村市", "浦部市", "浦田市", "白田市", "赤田市", "龍ノ浦市", "東海林市", "長谷市", "犬山市", "田所市", "設楽市", "千田市", "大沢市", "名進市", "長郷市", "岡田市", "郷田林市", "遅沢町", "池内町", "東池内町", "高丘町", "泉町", "塚北町", "大井村", "峡谷村", "ドイツ村", "羽生田村", "八つ墓村"]
3
+ building_name:
4
+ first_half: ["石井", "山城", "大井台", "片山", "大山", "植木", "長嶺", "東", "南", "西", "北", "市橋", "富岡", "田町", "江頭", "ポール", "牧", "片岡", "鶴", "太郎", "メゾン・ド", "SAKURA", "紫", "碧"]
5
+ second_half: ["コーポ", "ハイツ", "サンハイツ", "メゾン", "パレス", "ネオパレス", "プロミネンス", "カーサ", "Petit", "プチトマト", "パーク", "ネックス", "エスポワール", "エクセル", "グラン", "コンフォート", "エトワール", "フローラ", "リバティ", "荘"]
@@ -0,0 +1,66 @@
1
+ require "dummy-apartment/version"
2
+
3
+ require 'psych'
4
+
5
+ class DummyApartment
6
+ YML = File.expand_path('../data.yml', __FILE__)
7
+
8
+ NON_ZERO = (1..9).to_a.map(&:to_s)
9
+ NUM = NON_ZERO + ['0']
10
+ NUM_DASH = NUM + ['-']
11
+
12
+ @@dic ||= Psych.load(File.open(YML).read)
13
+
14
+ def self.generate
15
+ address = gen_address
16
+ name = gen_building_name
17
+ geo = gen_long_lat
18
+ top_floor = gen_top_floor
19
+ room_floor = gen_room_floor(top_floor)
20
+ room_number = gen_room_number(room_floor)
21
+
22
+ {
23
+ address: address, building_name: name, geo: geo,
24
+ top_floor: top_floor, room_floor: room_floor,
25
+ room_number: room_number
26
+ }
27
+ end
28
+
29
+ def self.gen_address
30
+ prefs = @@dic['prefectures']
31
+ cities = @@dic['cities']
32
+ number = NON_ZERO.sample
33
+ number += rand(5).times.select{ NUM_DASH.sample }.join
34
+ number.gsub!(/\-0|0\-/, '-')
35
+
36
+ [prefs.sample, cities.sample, number].join
37
+ end
38
+
39
+ def self.gen_building_name
40
+ names = @@dic['building_name']
41
+ names['first_half'].sample + names['second_half'].sample
42
+ end
43
+
44
+ def self.gen_long_lat
45
+ # only around Kanto
46
+ longitude = rand( 35.668559 .. 37.276341)
47
+ latitude = rand(138.419373 .. 140.572693)
48
+
49
+ [longitude, latitude]
50
+ end
51
+
52
+ def self.gen_top_floor
53
+ rand(2 .. 4)
54
+ end
55
+
56
+ def self.gen_room_floor(limit)
57
+ rand(1 .. limit)
58
+ end
59
+
60
+ def self.gen_room_number(floor)
61
+ "#{floor}0#{rand(0..9)}"
62
+ end
63
+
64
+ private_class_method *self.public_methods.grep(/\Agen_/)
65
+ end
66
+
@@ -0,0 +1,4 @@
1
+ class DummyApartment
2
+ VERSION = "0.0.1"
3
+ end
4
+
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'data.yml' do
4
+ let(:dic){ DummyApartment.class_variable_get :@@dic }
5
+
6
+ it 'should not have duplicated items' do
7
+ expect(dic['prefectures'] - dic['prefectures'].uniq).to be_empty
8
+ expect(dic['cities'] - dic['cities'].uniq ).to be_empty
9
+ expect(dic['building_name'][ 'first_half'] - dic['building_name'][ 'first_half'].uniq).to be_empty
10
+ expect(dic['building_name']['second_half'] - dic['building_name']['second_half'].uniq).to be_empty
11
+ end
12
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe DummyApartment do
4
+ let(:apartment) { DummyApartment.generate }
5
+
6
+ it 'should generate a hash' do
7
+ expect(apartment).to be_a Hash
8
+ end
9
+
10
+ it 'should have no public class method starts with "gen_"' do
11
+ public_methods = DummyApartment.public_methods(false)
12
+ expect(public_methods.grep /\Agen_/).to be_empty
13
+ end
14
+
15
+ describe 'Building Name' do
16
+ let(:name){ apartment[:building_name] }
17
+
18
+ it 'should not be empty' do
19
+ expect(name).not_to be_empty
20
+ end
21
+ end
22
+
23
+ describe 'Address' do
24
+ let(:address){ apartment[:address] }
25
+
26
+ it 'should match address format' do
27
+ expect(address).to match /[都道府県].+[市町村].*[0-9]/
28
+ end
29
+ end
30
+
31
+ describe 'Geo' do
32
+ let(:geo){ apartment[:geo] }
33
+
34
+ it 'should be a couple of Float' do
35
+ expect(geo.map(&:class)).to eql [Float, Float]
36
+ end
37
+ end
38
+
39
+ describe 'Room Floor and Top Floor' do
40
+ let(:top_floor) { apartment[:top_floor] }
41
+ let(:room_floor){ apartment[:room_floor] }
42
+
43
+ it 'should have valid floor information' do
44
+ expect( top_floor).to be >= room_floor
45
+ expect( top_floor).to be >= 1
46
+ expect(room_floor).to be >= 1
47
+ end
48
+ end
49
+
50
+ describe 'Room Number' do
51
+ let(:room_floor) { apartment[:room_floor] }
52
+ let(:room_number){ apartment[:room_number] }
53
+
54
+ it 'should be a three-character string' do
55
+ expect(room_number).to be_a String
56
+ expect(room_number.length).to eql 3
57
+ end
58
+
59
+ it 'should be consistent with room floor' do
60
+ expect(room_number).to start_with room_floor.to_s
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'dummy-apartment'
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dummy-apartment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joe-noh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem generates dummy information of apartment, including address,
56
+ name, room number and geo
57
+ email:
58
+ - goflb.jh@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - dummy-apartment.gemspec
69
+ - lib/data.yml
70
+ - lib/dummy-apartment.rb
71
+ - lib/dummy-apartment/version.rb
72
+ - spec/data-yml_spec.rb
73
+ - spec/dummy-apartment_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: https://github.com/Joe-noh/dummy-apartment
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.0
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Generator of Japanese Apartment Dummy Data
99
+ test_files:
100
+ - spec/data-yml_spec.rb
101
+ - spec/dummy-apartment_spec.rb
102
+ - spec/spec_helper.rb