spot2fish 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f8c48cb14c5f4be38fdfc474c14b1aee964e0ce
4
+ data.tar.gz: fc2b7df9ecbaac7607cb3eb321ffa4eb64bbc297
5
+ SHA512:
6
+ metadata.gz: 3c8c0bc70b3e30ae443332ded173e279575d8e5dc7a38680b165cdb370240f262e15a4d5bba5f3c9a8fcd936d03525fe2326963ce16b5b5f8e8938073177755f
7
+ data.tar.gz: ad05b7c75083585aa8907376b4a04c0f577b36468745d41cee6f208429551ebc74c506a1835aaf5062013a289697913edd329e85561c570d9955f8cf063461bb
@@ -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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spot2fish.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Scott Mascio
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.
@@ -0,0 +1,100 @@
1
+ ![alt tag](https://pbs.twimg.com/profile_images/492814839643787264/lewtdkhX_200x200.png)
2
+
3
+ # Spot2fish Gem
4
+
5
+
6
+ A Ruby library for the Spot2fish API.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'spot2fish'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install spot2fish
21
+
22
+ ## Usage
23
+
24
+ ##### Retrieve the first 15 fishing spots.
25
+
26
+ `Spot2fish.all`
27
+
28
+ *Pass a page number as an arguement, to paginate.*
29
+
30
+ `Spot2fish.all(2)`
31
+
32
+ ##### Search
33
+
34
+ `Spot2fish.search('Columbus, Ohio')`
35
+
36
+ `Spot2fish.search('Ohio')`
37
+
38
+ ##### Search Social Media
39
+
40
+ `Spot2fish.search_social_media('Columbus, Ohio')`
41
+
42
+ `Spot2fish.search_social_media('Ohio')`
43
+
44
+ ##### *Search* versus *Search Social Media*
45
+
46
+ `Spot2fish.search('Ohio')` will search the Spot2fish API for any spots near the location passed.
47
+
48
+ `Spot2fish.search_social_media('Columbus, Ohio')` will search the Twitter API as well as the Instagram API for any fishing realated posts within a 60 mile radious of the location passed.
49
+
50
+ > The `search` method may be perferable due to the rate limiting restrictions on both the Twitter API as well as the Instagram API.
51
+
52
+
53
+ ##### Response
54
+
55
+ **Metadata**
56
+
57
+ "metadata": {
58
+ "api_for": "Spot2fish.com",
59
+ "total_spots": 4500,
60
+ "spots_on_current_page": 15,
61
+ "current_page": 2,
62
+ "total_pages": 300,
63
+ "next_page": 3,
64
+ "next_page_link": "?page=3",
65
+ "previous_page": 1,
66
+ "previous_page_link": "?page=1"
67
+ }
68
+
69
+ **Array of Spot objects**
70
+
71
+ "spots": [
72
+ {
73
+ "id": 9000,
74
+ "social_media": "twitter",
75
+ "name": "_s_mas",
76
+ "social_media_id": "1234567890.0",
77
+ "image": "https://pbs.twimg.com/media/CLuki9uUkAE-jGV.png",
78
+ "text": "\"Let's go fishing"\",
79
+ "lat": "48.8489689",
80
+ "long": "2.3057026",
81
+ "location": "Columbus, Ohio",
82
+ "date": null,
83
+ "rank": 1,
84
+ "created_at": null,
85
+ "updated_at": null,
86
+ "avatar": "https://pbs.twimg.com/profile_images/492814839643787264/lewtdkhX_normal.png",
87
+ "extlocation": null,
88
+ "social_media_id_str": "674175896752947200",
89
+ "nfr": false
90
+ }
91
+ ]
92
+
93
+
94
+ ## Contributing
95
+
96
+ 1. Fork it
97
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
98
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
99
+ 4. Push to the branch (`git push origin my-new-feature`)
100
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ require_relative "spot2fish/version"
2
+ require_relative "spot2fish/response"
3
+
4
+ module Spot2fish
5
+ def self.all(page = 1)
6
+
7
+ Spot2fishResponse.new('/spots', nil, page).api_response
8
+ end
9
+
10
+ def self.search(city, page = 1)
11
+
12
+ Spot2fishResponse.new('/spots/saved_spots', city, page).api_response
13
+ end
14
+
15
+ def self.search_social_media(city, page = 1)
16
+
17
+ Spot2fishResponse.new('/spots/search', city, page).api_response
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ require "httparty"
2
+
3
+ class Spot2fishResponse
4
+ include HTTParty
5
+ base_uri "api.spot2fish.com/api/v1"
6
+
7
+ def initialize(path, city, page = 1)
8
+ @path = path
9
+ @city = city
10
+ @page = page
11
+ @params = params
12
+ end
13
+
14
+ def api_response
15
+ response = httparty_connection
16
+
17
+ if valid_response?(response.code)
18
+ response.parsed_response
19
+ else
20
+ "ERROR: Status #{response.code}"
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def valid_response?(code)
27
+ code == 200
28
+ end
29
+
30
+ def params
31
+ { query: { city: @city, page: @page} }
32
+ end
33
+
34
+ def httparty_connection
35
+ self.class.get(@path, @params)
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Spot2fish
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spot2fishResponse do
4
+
5
+ it 'should have the base URI set to the proper spot2fish api endpoint' do
6
+
7
+ expect(Spot2fishResponse.base_uri).to eq "http://api.spot2fish.com/api/v1"
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'spot2fish'
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spot2fish do
4
+ it 'should have a version number' do
5
+
6
+ Spot2fish::VERSION.should_not be_nil
7
+ end
8
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'spot2fish/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spot2fish"
8
+ spec.version = Spot2fish::VERSION
9
+ spec.authors = ["Scott Mascio"]
10
+ spec.email = ["scottmascio@gmail.com"]
11
+ spec.summary = %q{Ruby library for the Spot2fish API.}
12
+ spec.description = %q{Search the Spot2fish API for fishing spots.}
13
+ spec.homepage = ""
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 "pry"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_dependency "httparty", "~> 0.13.7"
27
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spot2fish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scott Mascio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-19 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: pry
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.13.7
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.7
83
+ description: Search the Spot2fish API for fishing spots.
84
+ email:
85
+ - scottmascio@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/spot2fish.rb
98
+ - lib/spot2fish/response.rb
99
+ - lib/spot2fish/version.rb
100
+ - spec/response_spec.rb
101
+ - spec/spec_helper.rb
102
+ - spec/spot2fish_spec.rb
103
+ - spot2fish.gemspec
104
+ homepage: ''
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.5.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Ruby library for the Spot2fish API.
128
+ test_files:
129
+ - spec/response_spec.rb
130
+ - spec/spec_helper.rb
131
+ - spec/spot2fish_spec.rb