chicago_libraries 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +48 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/chicago_libraries.gemspec +33 -0
- data/lib/chicago_libraries.rb +47 -0
- data/lib/chicago_libraries/version.rb +3 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d4b9629c8e867ab22608408ffbbed5e2e65490f
|
4
|
+
data.tar.gz: 46e3d1096ace8686ac07907cc2674d8c4d594540
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8139a61c5244789ddf3057df07e75824099f133a942ee382d7eaf80b81f4710f9e1e71a99b7cf7940ef7166011afecff74ffbd685c9ce7017f0f67185a37c873
|
7
|
+
data.tar.gz: 15f0f68c2d23d00910affc06a140eeb19267777e843e58c42607f26b5c570b0e1b3e5ee6000f6c1aa99d22d810d32af0f7dbb4d5aaac165af950db94d7abe54f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# ChicagoLibraries
|
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/chicago_libraries`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
Wrapper for the City of Chicago libraries public API. Allows you to access library information from ruby.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'chicago_libraries'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install chicago_libraries
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To get all Chicago public library information, run this code:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
libraries = ChicagoLibraries::Library.all
|
29
|
+
```
|
30
|
+
|
31
|
+
To get all Chicago public library information using a search keyword, run this code:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
libraries = ChicagoLibraries::Library.search('park')
|
35
|
+
```
|
36
|
+
|
37
|
+
replace 'park' with your own search keyword.
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
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.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chicago_libraries.
|
48
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "chicago_libraries"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chicago_libraries/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chicago_libraries"
|
8
|
+
spec.version = ChicagoLibraries::VERSION
|
9
|
+
spec.authors = ["dianacamacho"]
|
10
|
+
spec.email = ["dcam1901@yahoo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Wrapper for the City of Chicago Libraries public API. }
|
13
|
+
spec.description = %q{Allows you to access the City of Chicago public API from ruby.}
|
14
|
+
spec.homepage = "https://github.com/dianacamacho/chicago_libraries"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_dependency "unirest", "~> 1.1.2"
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "chicago_libraries/version"
|
2
|
+
require 'unirest'
|
3
|
+
|
4
|
+
module ChicagoLibraries
|
5
|
+
|
6
|
+
|
7
|
+
class Library
|
8
|
+
attr_accessor :zip_code, :phone, :teacher_in_library, :longitude, :latitude, :website, :address, :hours, :state, :cybernavigator, :name, :city
|
9
|
+
|
10
|
+
def initialize(library_info)
|
11
|
+
@zip_code = library_info["zip"],
|
12
|
+
@phone = library_info["phone"],
|
13
|
+
@teacher_in_library = library_info["teacher_in_the_library"],
|
14
|
+
@longitude = library_info["location"]["longitude"],
|
15
|
+
@latitude = library_info["location"]["latitude"],
|
16
|
+
@website = library_info["website"]["url"],
|
17
|
+
@address = library_info["address"],
|
18
|
+
@hours = library_info["hours_of_operation"],
|
19
|
+
@state = library_info["state"],
|
20
|
+
@cybernavigator = library_info["cybernavigator"],
|
21
|
+
@name = library_info["name_"],
|
22
|
+
@city = library_info["city"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.all
|
26
|
+
api_array = Unirest.get("https://data.cityofchicago.org/resource/x8fc-8rcq.json").body
|
27
|
+
create_libraries(api_array)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.search(search_keyword)
|
31
|
+
api_array = Unirest.get("https://data.cityofchicago.org/resource/x8fc-8rcq.json?$q=#{search_keyword}").body
|
32
|
+
create_libraries(api_array)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create_libraries(api_array)
|
36
|
+
libraries = []
|
37
|
+
|
38
|
+
api_array.each do |library_info|
|
39
|
+
libraries << Library.new(library_info)
|
40
|
+
end
|
41
|
+
libraries
|
42
|
+
end
|
43
|
+
|
44
|
+
private_class_method :create_libraries
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chicago_libraries
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dianacamacho
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-09 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: unirest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.2
|
69
|
+
description: Allows you to access the City of Chicago public API from ruby.
|
70
|
+
email:
|
71
|
+
- dcam1901@yahoo.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- chicago_libraries.gemspec
|
85
|
+
- lib/chicago_libraries.rb
|
86
|
+
- lib/chicago_libraries/version.rb
|
87
|
+
homepage: https://github.com/dianacamacho/chicago_libraries
|
88
|
+
licenses: []
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.0.14
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Wrapper for the City of Chicago Libraries public API.
|
110
|
+
test_files: []
|