dian_ping 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbb29e776796798619371bebbabb1260202081bc
4
- data.tar.gz: 88d14fce31fc65a5fff91942644caeddc737c63d
3
+ metadata.gz: f6bf7cc63e34e78a42602bedee1286d7b73e5928
4
+ data.tar.gz: e82b3e8501c34b398f7e9c19dca851538d505f33
5
5
  SHA512:
6
- metadata.gz: dd84f5b900f29ae86a84d95708c16cdfe5e4e3257988bd5be7e5114e038c51f47ea42bfab76d193054b1228cc9692c06c95802a9bd8a6de99bc8db222cbfc061
7
- data.tar.gz: a3366ff7ec4e39478e38c0d55b40c280da8e295d229e606ace59c5f9add676931af24e351810e6490aa2519b9cb8be934f240fe956b53de8c8e6df99abdcdd3d
6
+ metadata.gz: 51a4c49e1d0eb4915698c29f2dfad69ad65619b3119b5c4057b478d21d96ddc8a15ee6832e5a9ca765020ccfc515dbf34c06b7f8847bd3481beafcb4be92ad8c
7
+ data.tar.gz: 4a4981d2cd5b784514c7adeaf5f16ea98464090255908ecc43224d277c84518f0690dffaf8a59f7f5dbf9177b8bccdda755c15beebd18333e12df836526ea6ba
@@ -6,7 +6,7 @@ require 'dianping/parameter'
6
6
  class DianPing
7
7
  include HTTParty
8
8
 
9
- VERSION = '0.0.1'
9
+ VERSION = '0.0.2'
10
10
 
11
11
  attr_accessor :key, :secret
12
12
 
@@ -31,7 +31,7 @@ class DianPing
31
31
  end
32
32
 
33
33
  def parameter
34
- DP::Parameter.new(self)
34
+ Parameter.new(self)
35
35
  end
36
36
 
37
37
  def method_missing(method_name, *args, &block)
@@ -44,3 +44,5 @@ class DianPing
44
44
  end
45
45
 
46
46
  end
47
+
48
+ require 'dianping/railtie' if defined?(Rails)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- module DP
2
+ class DianPing
3
3
  module Business
4
4
 
5
5
  # coordinate[31.2204200000392, 121.41163000018]
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- module DP
2
+ class DianPing
3
3
  module Common
4
4
 
5
5
  # 根据是否有优惠券来筛选返回的商户
@@ -2,10 +2,10 @@
2
2
  require 'dianping/common'
3
3
  require 'dianping/business'
4
4
 
5
- module DP
5
+ class DianPing
6
6
  class Parameter < Hash
7
- include DP::Common
8
- include DP::Business
7
+ include Common
8
+ include Business
9
9
 
10
10
  attr_reader :client
11
11
 
@@ -22,6 +22,11 @@ module DP
22
22
  client.get(route, self)
23
23
  end
24
24
 
25
+ def business(id)
26
+ add :business_id, id
27
+ get '/v1/business/get_single_business'
28
+ end
29
+
25
30
  end
26
31
  end
27
32
 
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ class DianPing
3
+ class Railtie < ::Rails::Railtie
4
+ generators do
5
+ require "generators/dianping/install_generator"
6
+ end
7
+
8
+ initializer "dian_ping.setup" do
9
+ config_file = Rails.root.join("config", "dian_ping.yml")
10
+ if config_file.file?
11
+ begin
12
+ options = YAML.load_file(config_file)[Rails.env]
13
+ ::DP = DianPing.new(key: options['appkey'], secret: options['appSecret'])
14
+ rescue Exception => e
15
+ puts "There is a configuration error with the current dian_ping.yml"
16
+ puts e.message
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ class DianPing
3
+ module Generators
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+ # Create dian_ping.yml under config/initializers/
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates a ThemePark initializer file."
9
+ def copy_initializer
10
+ template "dian_ping.yml", "config/dian_ping.yml"
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # dian_ping configruation.
2
+ # see http://developer.dianping.com/
3
+ development:
4
+ appkey:
5
+ appSecret:
6
+
7
+ test:
8
+ appkey:
9
+ appSecret:
10
+
11
+ production:
12
+ appkey:
13
+ appSecret:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dian_ping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zires
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2013-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -105,6 +105,9 @@ files:
105
105
  - lib/dianping/business.rb
106
106
  - lib/dianping/common.rb
107
107
  - lib/dianping/parameter.rb
108
+ - lib/dianping/railtie.rb
109
+ - lib/generators/dianping/install_generator.rb
110
+ - lib/generators/templates/dian_ping.yml
108
111
  - LICENSE
109
112
  - Rakefile
110
113
  - README.md