baidu_map 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 617fd5031829ebfc730fdaa7e0a5cf7e478cd7e3
4
- data.tar.gz: 6d190fe510efc50797e91391cc0d00f501dae1a5
3
+ metadata.gz: f1f9fcee7d190e850628a80bd680d7cd0941e6fa
4
+ data.tar.gz: af7b6d9144ab7a0f087c97608d2b937db15226aa
5
5
  SHA512:
6
- metadata.gz: 106ef1b1a6b34242362362c2c0b9884529123a07133b2f1cd03e0dc62f48212607aee0306cd5f4c3d78acbb88fc61ea53c6509237517d62f949a03b9c75e2e7b
7
- data.tar.gz: 652eca0405d09992d849ee170918faed429501ed6412cd0110b6f73999c396c7391f63896f2c7df2213b05c68ba6987ccb72595f3a7ce912942a522bfc330481
6
+ metadata.gz: 610f892b15e2c488bfc0836496c6c68cb22bdbc3b8562cad611f957df415ac268fe7d54aa692da1e8210ec345c201ec6afe93d01a62f58c6cc86084ec7594456
7
+ data.tar.gz: 859582847f0aa1cafc97a161b4e820dd80c882cb2cd80d4af5db670d371ddeb333d2c8b028674f86e2fc7be693b850d60c5133e50bc14d7b247da8d468bd7cc9
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
- #source 'https://rubygems.org'
2
- source 'http://ruby.taobao.org'
1
+ source 'https://rubygems.org'
3
2
 
4
3
  gem 'eat'
5
4
 
@@ -7,5 +6,5 @@ group :development do
7
6
  gem 'pry'
8
7
  end
9
8
 
10
- # Specify your gem's dependencies in baidumap.gemspec
9
+ # Specify your gem's dependencies in baidu_map.gemspec
11
10
  gemspec
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # Baidumap
2
+ # BaiduMap
3
3
  [Baidu Map(百度地图) API](http://developer.baidu.com/map/index.php?title=webapi/guide/webservice-placeapi) wrapper in Ruby
4
4
 
5
5
 
@@ -19,7 +19,7 @@ And then execute:
19
19
 
20
20
  Or install it yourself as:
21
21
 
22
- $ gem install baidumap
22
+ $ gem install baidu_map
23
23
 
24
24
 
25
25
 
@@ -31,14 +31,23 @@ Or install it yourself as:
31
31
  [ak申请](http://lbsyun.baidu.com/apiconsole/key?application=key)
32
32
 
33
33
  ```ruby
34
- Baidumap.ak = "aaaaaaaaaaaaaaaaaa"
34
+ BaiduMap.ak = "aaaaaaaaaaaaaaaaaa"
35
35
 
36
36
  # or
37
37
 
38
- Baidumap.setup { @ak = "aaaaaaaaaaaaaaaaaa" }
38
+ BaiduMap.setup { @ak = "aaaaaaaaaaaaaaaaaa" }
39
39
  ```
40
40
 
41
41
 
42
+ ### Initialize for Rails
43
+
44
+ run command:
45
+ ```shell
46
+ $ rails generate baidu_map:install
47
+ ```
48
+ and then add your ak to file `config/initializers/baidu_map.rb`.
49
+
50
+
42
51
 
43
52
 
44
53
  ### Example
@@ -50,37 +59,42 @@ Please note that params shouldn't including `output: 'json'` or `output: 'xml'`,
50
59
 
51
60
  ```ruby
52
61
  # Place API
53
- Baidumap.place_search(query: "九亭", region: "上海", scope: '1')
62
+ BaiduMap.place_search(query: "九亭", region: "上海", scope: '1')
54
63
 
55
- Baidumap.place_detail(uid: "5508504d0319eecac6f0259a", scope: '2')
64
+ BaiduMap.place_detail(uid: "5508504d0319eecac6f0259a", scope: '2')
56
65
 
57
- Baidumap.place_detail(uids: "5508504d0319eecac6f0259a, 104274a315f7134fc3f1cfde", output: 'json', scope: '2') # NOTE and TODO: there is a bug that "," in uids's value will be translated, so this method is not usable currently.
66
+ BaiduMap.place_detail(uids: "5508504d0319eecac6f0259a,8ee4560cf91d160e6cc02cd7", output: 'json', scope: '2')
58
67
 
59
68
 
60
69
  # Place Suggestion API
61
- Baidumap.place_suggestion(query: "九亭", region: "全国")
70
+ BaiduMap.place_suggestion(query: "九亭", region: "全国")
62
71
 
63
72
 
64
73
  # Geocoding API
65
- Baidumap.geocoder(address: "九亭")
74
+ BaiduMap.geocoder(address: "九亭")
66
75
 
67
- Baidumap.geocoder(location: '121.33428124857, 31.13491723367') # NOTE and TODO: there is a bug that "," in uids's value will be translated, so this method is not usable currently.
76
+ BaiduMap.geocoder(location: '39.983424,116.322987')
68
77
 
69
78
 
70
79
  # IP定位API
71
- Baidumap.location(ip: "115.172.82.212", coor: "bd09ll")
80
+ BaiduMap.location(ip: "115.172.82.212", coor: "bd09ll")
72
81
  ```
73
82
 
74
83
 
75
84
 
76
85
 
77
- ### Result Debug
86
+ ### Result Debug: show original request url
78
87
 
79
- If the result's return status from Baidu API is not "0", then there is an error. To debug it, you always can attatch a block `{ |debug| debug.inspect }` to show the original url requested from this gem to Baidu just like this:
88
+ If the return status of result from Baidu API is not "0", then there is an error. To debug it, you always can attatch a block `{ |debug| debug.inspect }` to show the original url requested from this gem to Baidu just like this:
80
89
 
81
- `Baidumap.place_detail(uids: [ "5508504d0319eecac6f0259a, 104274a315f7134fc3f1cfde" ], output: 'json', scope: '2') { |deug| debug.inspect } `
90
+ ```ruby
91
+ BaiduMap.place_detail(uids: "5508504d0319eecac6f0259a,8ee4560cf91d160e6cc02cd7", output: 'json', scope: '2') { |deug| debug.inspect }
92
+ ```
82
93
 
83
- You can show your ak value used by this gem through this code `Baidumap.ak`.
94
+ You can show your ak value used by this gem through this code:
95
+ ```ruby
96
+ BaiduMap.ak
97
+ ```
84
98
 
85
99
 
86
100
 
@@ -98,7 +112,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
98
112
 
99
113
  ## Contributing
100
114
 
101
- 1. Fork it ( https://github.com/yanyingwang/baidumap/fork )
115
+ 1. Fork it ( https://github.com/yanyingwang/baidu_map/fork )
102
116
  2. Create your feature branch (`git checkout -b my-new-feature`)
103
117
  3. Commit your changes (`git commit -am 'Add some feature'`)
104
118
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,17 +1,17 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'baidumap/version'
4
+ require 'baidu_map/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "baidu_map"
8
- spec.version = Baidumap::VERSION
8
+ spec.version = BaiduMap::VERSION
9
9
  spec.authors = ["YanyingWang"]
10
10
  spec.email = ["wangyanying@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Baidu Map(百度地图) API in Ruby.}
13
13
  spec.description = %q{Ruby wapper for Baidu Map API used for Place Suggestion and so on.}
14
- spec.homepage = "https://github.com/yanyingwang/baidumap"
14
+ spec.homepage = "https://github.com/yanyingwang/baidu_map"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
@@ -29,4 +29,8 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.9"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "pry", "~> 0.10.1"
33
+ spec.add_runtime_dependency "eat", "~> 0.1.8"
34
+
35
+ spec.require_paths = ["lib"]
32
36
  end
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "pry"
5
- require "baidumap"
5
+ require "baidu_map"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -0,0 +1,3 @@
1
+ module BaiduMap
2
+ VERSION = "0.2.0"
3
+ end
@@ -1,10 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
- require "baidumap/version"
2
+ require "baidu_map/version"
3
3
  require 'eat'
4
4
  require 'json'
5
5
 
6
6
 
7
- module Baidumap
7
+ module BaiduMap
8
8
  class << self
9
9
  alias_method :setup, :instance_eval
10
10
  attr_accessor :ak
@@ -0,0 +1,4 @@
1
+
2
+ BaiduMap.set do
3
+ @ak = ''
4
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+
3
+ module BaiduMap
4
+ class InstallGenerator < Rails::Generators::Base
5
+
6
+ def install
7
+ copy_file('initialize.rb', 'config/initializers/baidu_map.rb')
8
+ end
9
+
10
+ def self.source_root
11
+ File.join(File.dirname(__FILE__), 'config')
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YanyingWang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.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.10.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: eat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.8
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.8
41
69
  description: Ruby wapper for Baidu Map API used for Place Suggestion and so on.
42
70
  email:
43
71
  - wangyanying@gmail.com
@@ -52,12 +80,14 @@ files:
52
80
  - LICENSE
53
81
  - README.md
54
82
  - Rakefile
55
- - baidumap.gemspec
83
+ - baidu_map.gemspec
56
84
  - bin/console
57
85
  - bin/setup
58
- - lib/baidumap.rb
59
- - lib/baidumap/version.rb
60
- homepage: https://github.com/yanyingwang/baidumap
86
+ - lib/baidu_map.rb
87
+ - lib/baidu_map/version.rb
88
+ - lib/generators/baidu_map/config/initialize.rb
89
+ - lib/generators/baidu_map/install_generator.rb
90
+ homepage: https://github.com/yanyingwang/baidu_map
61
91
  licenses:
62
92
  - MIT
63
93
  metadata: {}
@@ -1,3 +0,0 @@
1
- module Baidumap
2
- VERSION = "0.1.0"
3
- end