open_data_addresses 0.1.3 → 0.1.4

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.
@@ -1,9 +1,9 @@
1
1
  require "open_data_addresses/version"
2
2
 
3
3
  module OpenDataAddresses
4
- def self.address(city='SF')
4
+ def self.address(region='SF')
5
5
  address = ''
6
- csv = get_csv(city);
6
+ csv = get_csv(region);
7
7
  address_line = rand(2..csv[:lines])
8
8
 
9
9
  line_num = 1
@@ -17,9 +17,9 @@ module OpenDataAddresses
17
17
  format_address(address)
18
18
  end
19
19
 
20
- def self.addresses(amount=10, city='SF')
20
+ def self.addresses(amount=10, region='SF')
21
21
  addresses = []
22
- csv = get_csv(city)
22
+ csv = get_csv(region)
23
23
  address_lines = uniq_rand_nums(amount, 2, csv[:lines]).sort
24
24
 
25
25
  address_line = address_lines.shift
@@ -43,18 +43,20 @@ module OpenDataAddresses
43
43
  { street: ary[0], city: ary[1], state: ary[2], zip: ary[3] }
44
44
  end
45
45
 
46
- def self.get_csv(city)
46
+ def self.get_csv(region)
47
47
  files = {
48
48
  'SF' => "#{File.dirname(__FILE__)}/addresses/sanfrancisco_registered_business_locations.csv",
49
- 'NYC' => "#{File.dirname(__FILE__)}/addresses/newyorkcity_legally_operating_businesses.csv"
49
+ 'NYC' => "#{File.dirname(__FILE__)}/addresses/newyorkcity_legally_operating_businesses.csv",
50
+ 'LA' => "#{File.dirname(__FILE__)}/addresses/losangeles_listing_of_active_businesses.csv"
50
51
  }
51
- lines = File.open(files[city], &:readline).to_i;
52
+ raise 'Invalid region argument' if files[region].nil?
53
+ lines = File.open(files[region], &:readline).to_i;
52
54
 
53
- { file: files[city], lines: lines }
55
+ { file: files[region], lines: lines }
54
56
  end
55
57
 
56
58
  def self.uniq_rand_nums(amount, min, max)
57
- raise 'Invalid arguments' if max - min + 1 < amount
59
+ raise 'Invalid amount argument' if max - min + 1 < amount
58
60
  nums = amount.times.map { rand(min..max) }
59
61
  return nums if nums.uniq.length == amount
60
62
 
@@ -1,3 +1,3 @@
1
1
  module OpenDataAddresses
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_data_addresses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim X. Lin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - Rakefile
71
71
  - bin/console
72
72
  - bin/setup
73
+ - lib/addresses/losangeles_listing_of_active_businesses.csv
73
74
  - lib/addresses/newyorkcity_legally_operating_businesses.csv
74
75
  - lib/addresses/sanfrancisco_registered_business_locations.csv
75
76
  - lib/open_data_addresses.rb