geocore 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 83bceba8a075ce60bde17a7f599faa4e0772d22c
4
+ data.tar.gz: 5c9e1a4b5e4ae153ac19a40c903051281507df6c
5
+ SHA512:
6
+ metadata.gz: 1c9f457de3ffdb8edc333c2e0f384a864637491341a728e1c7e23de9ed9ce7120edfb14a595907406afd837e15790bda4e97fdc10b966d5cee340afef619806c
7
+ data.tar.gz: 2509f5f99c80e1f68858b08ac799d063fefd14a5bc7354b85b3a9f920879213be0c983feeb9668917ca86f101d1251cb3db7e10261bc8b892964d5b076703ee0
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in geocore.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ geocore (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ httparty (0.16.2)
11
+ multi_xml (>= 0.5.2)
12
+ multi_xml (0.6.0)
13
+ rake (10.5.0)
14
+ rspec (3.8.0)
15
+ rspec-core (~> 3.8.0)
16
+ rspec-expectations (~> 3.8.0)
17
+ rspec-mocks (~> 3.8.0)
18
+ rspec-core (3.8.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-expectations (3.8.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-mocks (3.8.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.8.0)
26
+ rspec-support (3.8.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler (~> 1.16)
33
+ geocore!
34
+ httparty
35
+ rake (~> 10.0)
36
+ rspec (~> 3.0)
37
+
38
+ BUNDLED WITH
39
+ 1.16.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Geocore
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/geocore`. 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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'geocore'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install geocore
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/geocore.
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "geocore"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/geocore.gemspec ADDED
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "geocore/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "geocore"
8
+ spec.version = Geocore::VERSION
9
+ spec.authors = ["MapMotion K.K"]
10
+
11
+ spec.summary = %q{Geocore}
12
+ spec.description = %q{Geocore}
13
+ spec.homepage = "http://dev1.geocore.jp/apidocs/"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = 'https://rubygems.org'
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "httparty"
37
+ end
@@ -0,0 +1,106 @@
1
+ require "httparty"
2
+ require "json"
3
+
4
+ module Geocore
5
+ class Builder
6
+ include HTTParty
7
+ base_uri 'http://dev1.geocore.jp:80/api'
8
+
9
+ def initialize(user)
10
+ @url = "http://dev1.geocore.jp/api/auth"
11
+ response = HTTParty.post(@url, body: {'id' => user.api_login, 'password' => user.api_key, 'project_id' => user.project_id})
12
+ if response['status'] == "success"
13
+ @feed_status = 'healthy'
14
+ @token = response["result"]["token"]
15
+ @header = {'Geocore-Access-Token': @token}
16
+ else
17
+ @feed_status = 'Error'
18
+ end
19
+ end
20
+
21
+ def feed_status
22
+ return @feed_status
23
+ end
24
+
25
+ def places
26
+ self.class.get("/places", headers: @header)
27
+ end
28
+
29
+ def level0
30
+ self.class.get("/public/ref/gadm")
31
+ end
32
+
33
+ def level1(level0Id)
34
+ self.class.get("/public/ref/gadm" + level0Id.to_s)
35
+ end
36
+
37
+ def level2(level0Id, level1Id)
38
+ self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s)
39
+ end
40
+
41
+ def level3(level0Id, level1Id, level2Id)
42
+ self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s + '/' + level2Id.to_s)
43
+ end
44
+
45
+ def regions(code_prefix)
46
+ self.class.get('/public/ref/jp/regions/' + code_prefix.to_s)
47
+ end
48
+
49
+ def region_prefectures(region_code)
50
+ self.class.get('/public/ref/jp/regions/' + region_code.to_s + '/prefectures')
51
+ end
52
+
53
+ def prefecture_cities(prefecture_code)
54
+ self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/cities')
55
+ end
56
+
57
+ def prefecture_bounds(prefecture_code)
58
+ self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/bounds')
59
+ end
60
+
61
+ def cities_bounds(city_codes_array)
62
+ self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(city_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
63
+ end
64
+
65
+ def train_line_bounds(line_code)
66
+ self.class.get('/public/ref/jp/lines/' + line_code.to_s + '/bounds')
67
+ end
68
+
69
+ def train_lines_bounds(line_codes_array)
70
+ self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(line_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
71
+ end
72
+
73
+ def prefecture_train_lines(prefecture_code)
74
+ self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines')
75
+ end
76
+
77
+ def prefecture_train_line_stations(prefecture_code, line_code)
78
+ self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines/' + line_code.to_s + '/stations')
79
+ end
80
+
81
+ def stations_bounds(station_codes_array)
82
+ self.class.get('/public/ref/jp/stations/bounds?station_codes=' + URI.escape(station_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
83
+ end
84
+
85
+ def prefecture(prefecture_code)
86
+ self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s)
87
+ end
88
+
89
+ def city(city_code)
90
+ self.class.get('/public/ref/jp/cities/' + city_code.to_s) # Code examples: Shinjuku = 13104, Saiwai(Kawasaki) = 14132, Nishi(Yokohama) = 14103, city_codes_array = [13104, 14132, 14103]
91
+ end
92
+
93
+ def nearest_city(lat, lon)
94
+ self.class.get('/public/ref/jp/cities/nearest?lat=' + lat + '&lon=' + lon)
95
+ end
96
+
97
+ def train_line(line_code)
98
+ self.class.get('/public/ref/jp/lines/' + line_code)
99
+ end
100
+
101
+ def station(station_code)
102
+ self.class.get('/public/ref/jp/stations/' + station_code)
103
+ end
104
+ end
105
+ end
106
+
@@ -0,0 +1,3 @@
1
+ module Geocore
2
+ VERSION = "0.3.0"
3
+ end
data/lib/geocore.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "geocore/version"
2
+ require "geocore/builder"
3
+
4
+
5
+ module Geocore
6
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geocore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - MapMotion K.K
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-18 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: httparty
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
+ description: Geocore
70
+ email:
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".gitignore"
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - README.md
79
+ - Rakefile
80
+ - bin/console
81
+ - bin/setup
82
+ - geocore.gemspec
83
+ - lib/geocore.rb
84
+ - lib/geocore/builder.rb
85
+ - lib/geocore/version.rb
86
+ homepage: http://dev1.geocore.jp/apidocs/
87
+ licenses: []
88
+ metadata:
89
+ allowed_push_host: https://rubygems.org
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.6.14.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Geocore
110
+ test_files: []