geoplugin 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 +3 -0
- data/Gemfile +4 -0
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/geoplugin.gemspec +37 -0
- data/lib/geoplugin.rb +12 -0
- data/lib/geoplugin/version.rb +3 -0
- data/spec/geoplugin_spec.rb +36 -0
- data/spec/spec_helper.rb +2 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4b2a2bbe5aa2ffa0f6de65b06d6a02c8a0555c86
|
4
|
+
data.tar.gz: c417cb9c1722d9d90d6bc81d137e6d006658b633
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e62da5de980427e6e865d311a335562b2615746ccfe9bebd5742c26c0e2591be5a87c3fbf70e3968b29e02bc3bac5ea20411b6df576b9d2e05faece2019dbce
|
7
|
+
data.tar.gz: 33c69dcb4e2e39844bc4ea9218ddd9f656ddd4907078ab7272e9166af08379031f425f13f6a471c52d0394ace053c819f9c8b6510972522be65c8272b32c878d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Geoplugin
|
2
|
+
|
3
|
+
This is a Ruby wrapper library around the API provided by Geoplugin. Geoplugin is the easiest way for you to know where your visitors are from so that you can provide them with content more relevant to their geographical location.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'geoplugin'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install geoplugin
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'geoplugin'
|
25
|
+
|
26
|
+
# Find my location without ssl
|
27
|
+
location = Geoplugin.me
|
28
|
+
|
29
|
+
# Find my location with ssl
|
30
|
+
location = Geoplugin.me(:ssl => true, :key => 'your geoplugin key')
|
31
|
+
|
32
|
+
|
33
|
+
# Find ip location with ssl
|
34
|
+
location = Geoplugin.new('8.8.8.8')
|
35
|
+
|
36
|
+
# Find my location with ssl
|
37
|
+
location = Geoplugin.new('8.8.8.8', :ssl => true, :key => 'your geoplugin key')
|
38
|
+
|
39
|
+
|
40
|
+
```
|
41
|
+
## Attributes
|
42
|
+
|
43
|
+
request,
|
44
|
+
status,
|
45
|
+
city,
|
46
|
+
region,
|
47
|
+
areacode,
|
48
|
+
dmacode,
|
49
|
+
countrycode,
|
50
|
+
countryname,
|
51
|
+
continentcode,
|
52
|
+
latitude,
|
53
|
+
longitude,
|
54
|
+
regioncode,
|
55
|
+
regionname,
|
56
|
+
currencycode,
|
57
|
+
currencysymbol,
|
58
|
+
currencysymbol_utf,
|
59
|
+
currencyconverter
|
60
|
+
|
61
|
+
## Credits
|
62
|
+
Many thanks to Geoplugin for his implementation of the API.
|
63
|
+
|
64
|
+
## License
|
65
|
+
The restcountry GEM is released under the MIT License.
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it ( https://github.com/[my-github-username]/geoplugin/fork )
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "geoplugin"
|
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
data/geoplugin.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'geoplugin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "geoplugin"
|
8
|
+
spec.version = Geoplugin::VERSION
|
9
|
+
spec.authors = ["Davide Santangelo"]
|
10
|
+
spec.email = ["davide.santangelo@gmail.com"]
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = %q{This is a Ruby wrapper library around the API provided by Geoplugin (http://www.geoplugin.com) API.}
|
17
|
+
spec.description = %q{This is a Ruby wrapper library around the API provided by Geoplugin. Geoplugin is the easiest way for you to know where your visitors are from so that you can provide them with content more relevant to their geographical location.}
|
18
|
+
spec.homepage = ""
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files`.split($/)
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency 'rspec'
|
29
|
+
spec.add_development_dependency "vcr"
|
30
|
+
spec.add_development_dependency "typhoeus"
|
31
|
+
|
32
|
+
spec.required_ruby_version = ">= 1.9.3"
|
33
|
+
|
34
|
+
spec.add_dependency "faraday"
|
35
|
+
spec.add_dependency "json"
|
36
|
+
spec.add_dependency "ipaddress"
|
37
|
+
end
|
data/lib/geoplugin.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "geoplugin/version"
|
2
|
+
require "geoplugin/locate"
|
3
|
+
|
4
|
+
module Geoplugin
|
5
|
+
def self.me(options = {})
|
6
|
+
location = options[:ssl] ? Geoplugin::Locate.ssl_locate_no_ip(options[:key]) : Geoplugin::Locate.locate_no_ip
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.new(ip, options = {})
|
10
|
+
location = options[:ssl] ? Geoplugin::Locate.ssl_locate(options[:key], ip) : Geoplugin::Locate.locate(ip)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vcr'
|
3
|
+
|
4
|
+
describe Geoplugin do
|
5
|
+
it 'has a version number' do
|
6
|
+
expect(Geoplugin::VERSION).not_to be nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'expect status 200' do
|
10
|
+
VCR.use_cassette 'locate my ip without ssl' do
|
11
|
+
response = Geoplugin.me
|
12
|
+
expect(response.status).to eq(200)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'expect status 200' do
|
17
|
+
VCR.use_cassette 'locate my ip with ssl' do
|
18
|
+
response = Geoplugin.me(:ssl => true, :key => 'your geoplugin key')
|
19
|
+
expect(response.status).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'get countryName United States with ip 8.8.8.8' do
|
24
|
+
VCR.use_cassette 'locate ip 8.8.8.8 without ssl' do
|
25
|
+
response = Geoplugin.new('8.8.8.8')
|
26
|
+
expect(response.countryname).to eq('United States')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'get countryName United States with ip 8.8.8.8 with SSL' do
|
31
|
+
VCR.use_cassette 'locate ip 8.8.8.8 with ssl' do
|
32
|
+
response = Geoplugin.new('8.8.8.8', :ssl => true, :key => 'your geoplugin key')
|
33
|
+
expect(response.countryname).to eq('United States')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geoplugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Davide Santangelo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-16 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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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: '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: vcr
|
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: typhoeus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ipaddress
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: This is a Ruby wrapper library around the API provided by Geoplugin.
|
126
|
+
Geoplugin is the easiest way for you to know where your visitors are from so that
|
127
|
+
you can provide them with content more relevant to their geographical location.
|
128
|
+
email:
|
129
|
+
- davide.santangelo@gmail.com
|
130
|
+
executables:
|
131
|
+
- console
|
132
|
+
- setup
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- ".gitignore"
|
137
|
+
- ".rspec"
|
138
|
+
- ".travis.yml"
|
139
|
+
- Gemfile
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- geoplugin.gemspec
|
145
|
+
- lib/geoplugin.rb
|
146
|
+
- lib/geoplugin/version.rb
|
147
|
+
- spec/geoplugin_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
homepage: ''
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata:
|
153
|
+
allowed_push_host: https://rubygems.org
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 1.9.3
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 2.4.6
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: This is a Ruby wrapper library around the API provided by Geoplugin (http://www.geoplugin.com)
|
174
|
+
API.
|
175
|
+
test_files:
|
176
|
+
- spec/geoplugin_spec.rb
|
177
|
+
- spec/spec_helper.rb
|