sf_mobile_food_facilities 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c1dcf21bb711876f80c13f3ca0d1e0e53486fa5
4
- data.tar.gz: 4ad5c45b17ab2b9b22c99da4e7fb1701df75b5fa
3
+ metadata.gz: 85d5e72393c5c98fc05e00cec390eced000c2f24
4
+ data.tar.gz: 17981aacf843a896abd5b2444bcfaa349c3b7bfb
5
5
  SHA512:
6
- metadata.gz: 3eb5c0570e3956474adc38effcfc310cacb60dc64d35a601139b381ff0ae1382eb90bb0b197553984794cde6326e1d2f88dcec37b3b0bcbc6bb57954d50f7f6a
7
- data.tar.gz: 05c56310752991d8b8f79f1c57450f6530975327b838602d810b33d1da7e59c33d06c13c6577f4558787b3b5c77c2b115ed087b6bb684815e0494fb017d879df
6
+ metadata.gz: 33b955a20295880076ecb17f64e83c07fab848970e45a37bca9f2b79e8b0661d3db02abbd37d272538ec0f6fde51cd02535a413a0a12858efb3f5cf85777e208
7
+ data.tar.gz: 2fd54cb195246c3c939e54ac2fdbc247ae6f850c2f0fd01111c8ecb0eccb0abe1f8de5e8a7d141e3b36ebc05cf1074383a66c7fd56d8618bbef628f92316d48c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SfMobileFoodFacilities
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sf_mobile_food_facilities`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This an api-wrapper gem for SF open data portal - Mobile Food Facility Permits which includes the name of vendor, location, type of food sold, status of permit, and more.
6
4
 
7
5
  ## Installation
8
6
 
@@ -24,6 +22,14 @@ Or install it yourself as:
24
22
 
25
23
  $ SfMobileFoodFacilities::Location.all
26
24
 
25
+ $ SfMobileFoodFacilities::Location.first
26
+
27
+ $ SfMobileFoodFacilities::Location.last
28
+
29
+ $ SfMobileFoodFacilities::Facility::where(address: "400 CALIFORNIA ST", status: "APPROVED")
30
+
31
+ $ SfMobileFoodFacilities::Facility::find_by(:address, "400 CALIFORNIA ST")
32
+
27
33
  ## Development
28
34
 
29
35
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,17 +1,40 @@
1
1
  require "sf_mobile_food_facilities/version"
2
2
  require 'unirest'
3
+ require 'pry'
3
4
 
4
5
  module SfMobileFoodFacilities
5
6
  class Facility
6
-
7
- attr_reader :address, :applicant, :dayshours, :facilitytype, :fooditems
7
+ attr_reader :address, :applicant, :approved,
8
+ :block, :blocklot, :cnn, :dayshours,
9
+ :expirationdate, :facilitytype, :fooditems,
10
+ :latitude, :location, :locationdescription,
11
+ :longitude, :lot, :objectid, :permit,
12
+ :priorpermit, :received, :schedule,
13
+ :status, :x, :y
8
14
 
9
15
  def initialize(hash)
10
16
  @address = hash["address"]
11
17
  @applicant = hash["applicant"]
18
+ @approved = hash["applicant"]
19
+ @block = hash["block"]
20
+ @cnn = hash["cnn"]
12
21
  @dayshours = hash["dayshours"]
22
+ @expirationdate = hash["expirationdate"]
13
23
  @facilitytype = hash["facilitytype"]
14
24
  @fooditems = hash["fooditems"]
25
+ @latitude = hash["latitude"]
26
+ @location = hash["location"]
27
+ @locationdescription = hash["locationdescription"]
28
+ @longitude = hash["longitude"]
29
+ @lot = hash["lot"]
30
+ @objectid = hash["objectid"]
31
+ @permit = hash["permit"]
32
+ @priorpermit = hash["priorpermit"]
33
+ @received = hash["received"]
34
+ @schedule = hash["schedule"]
35
+ @status = hash["status"]
36
+ @x = hash["x"]
37
+ @y = hash["y"]
15
38
  end
16
39
 
17
40
  def self.all
@@ -22,5 +45,33 @@ module SfMobileFoodFacilities
22
45
  end
23
46
  return facilities
24
47
  end
48
+
49
+ def self.first
50
+ facilities_array = Unirest.get("https://data.sfgov.org/resource/6a9r-agq8.json").body
51
+ return facilities_array[0]
52
+ end
53
+
54
+ def self.last
55
+ facilities_array = Unirest.get("https://data.sfgov.org/resource/6a9r-agq8.json").body
56
+ return facilities_array[-1]
57
+ end
58
+
59
+ def self.where(hash)
60
+ domain = "https://data.sfgov.org/resource/6a9r-agq8.json?"
61
+ hash.each_with_index do |(key,value), index|
62
+ domain += "#{key}=#{value}"
63
+ if hash.size-1 > index
64
+ domain += "&"
65
+ end
66
+ end
67
+ domain.gsub!(' ', '%20')
68
+ facilities_array = Unirest.get("#{domain}").body
69
+ return facilities_array
70
+ end
71
+
72
+ def self.find_by(field_name, field_param)
73
+ facilities_array = Unirest.get("https://data.sfgov.org/resource/6a9r-agq8.json?#{field_name}=#{field_param}").body
74
+ return facilities_array[0]
75
+ end
25
76
  end
26
77
  end
@@ -1,3 +1,3 @@
1
1
  module SfMobileFoodFacilities
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -28,8 +28,10 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "unirest", "~> 1.1.2"
31
+ spec.add_dependency 'pry', '~> 0.10.3'
31
32
 
32
33
  spec.add_development_dependency "bundler", "~> 1.12"
33
34
  spec.add_development_dependency "rake", "~> 10.0"
34
35
  spec.add_development_dependency "rspec", "~> 3.0"
36
+
35
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sf_mobile_food_facilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anna Natorilla
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.3
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement