weixin_authorize 1.0.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: 597087b2445885d7272fe48b6dfae8b4ade852e7
4
+ data.tar.gz: 091d7d77fa863078e05f9b0a86aa3adc45896723
5
+ SHA512:
6
+ metadata.gz: 0515f0d280d6e995e7857ab3d7f8311b16895e6424755b9f7cc55035d198e75a7687968c7bf816f6365adc59364bc2361e471e4ae0cf3a58feccc430dafe27f7
7
+ data.tar.gz: 8cea693671811943eb41fc4471d83d31a10f79ba3a86f5a937ef8752f766f223839c5ed5e47f0df28d434e06071d14358a14c60700eaacae1111c1a8ae68dc7e
data/.gitignore ADDED
@@ -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 @@
1
+ --format documentation --color spec --drb
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in weixin_authorize.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ # For debugger
8
+ gem "pry-rails", "~> 0.3.2"
9
+ gem "pry-debugger", "~> 0.2.2"
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 lanrion
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.
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # WeixinAuthorize
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ `gem 'weixin_authorize'`
8
+
9
+ And then execute:
10
+
11
+ `$ bundle`
12
+
13
+ Or install it yourself as:
14
+
15
+ `$ gem install weixin_authorize`
16
+
17
+ ## Usage
18
+
19
+ ### Init a `client`
20
+
21
+ ```ruby
22
+
23
+ $client ||= WeixinAuthorize.configure do |config|
24
+ config.app_id = ENV["APPID"]
25
+ config.app_secret = ENV["APPSECRET"]
26
+ config.expired_at = Time.now.to_i
27
+ end
28
+
29
+ # Or
30
+
31
+ $client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
32
+
33
+ ```
34
+
35
+ ### 获取用户管理信息
36
+
37
+ * [获取用户基本信息](http://mp.weixin.qq.com/wiki/index.php?title=获取用户基本信息)
38
+
39
+ `user_info = $client.user(ENV["OPENID"])`
40
+
41
+ * [获取关注者列表](http://mp.weixin.qq.com/wiki/index.php?title=获取关注者列表)
42
+
43
+ `followers = $client.followers`
44
+
45
+
46
+ ### [分组管理接口](http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口)
47
+
48
+ * 创建分组:
49
+
50
+ `group = $client.create_group("test")`
51
+
52
+ * 查询所有分组:
53
+
54
+ `groups = $client.groups`
55
+ * 查询用户所在分组:
56
+
57
+ `group = $client.get_group_for(ENV["OPENID"])`
58
+
59
+ * 修改分组名:
60
+
61
+ `group = $client.update_group_name(ENV["OPENID"], "new_group_name")`
62
+
63
+ * 移动用户分组:
64
+
65
+ `group = $client.update_group_for_openid(ENV["OPENID"], "to_groupid")`
66
+
67
+ ### 自定义菜单
68
+
69
+ * [自定义菜单创建接口](http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口)
70
+
71
+ `response = $client.create_menu(menu)`
72
+
73
+ * [自定义菜单查询接口](http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口)
74
+
75
+ `response = $client.menu`
76
+
77
+ * [自定义菜单删除接口](http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口)
78
+
79
+ `response = $client.delete_menu`
80
+
81
+ ### [发送客服信息](http://mp.weixin.qq.com/wiki/index.php?title=发送客服信息)
82
+
83
+ * 发送文本信息:
84
+
85
+ `$client.send_text_custom(to_user, content)`
86
+
87
+ * 发送图片信息:
88
+
89
+ `$client.send_image_custom(to_user, media_id)`
90
+
91
+ * 发送语音消息:
92
+
93
+ `$client.send_voice_custom(to_user, media_id)`
94
+
95
+ * 发送视频消息:
96
+
97
+ `$client.send_video_custom(to_user, media_id, options)`
98
+
99
+ * 发送音乐消息:
100
+
101
+ `$client.send_music_custom(to_user, media_id, musicurl, hqmusicurl, options)`
102
+
103
+ * 发送图文消息:
104
+
105
+ `$client.send_news_custom(to_user, *articles)`
106
+
107
+ ## Contributing
108
+
109
+ 1. Fork it
110
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
111
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
112
+ 4. Push to the branch (`git push origin my-new-feature`)
113
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,123 @@
1
+ # encoding: utf-8
2
+
3
+ module WeixinAuthorize
4
+ module Api
5
+ module Custom
6
+
7
+ # 发送文本消息
8
+ # {
9
+ # "touser":"OPENID",
10
+ # "msgtype":"text",
11
+ # "text":
12
+ # {
13
+ # "content":"Hello World"
14
+ # }
15
+ # }
16
+ def send_text_custom(to_user, content)
17
+ message = default_options(to_user).merge({text: {content: content}})
18
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
19
+ end
20
+
21
+ # 发送图片消息
22
+ # {
23
+ # "touser":"OPENID",
24
+ # "msgtype":"image",
25
+ # "image":
26
+ # {
27
+ # "media_id":"MEDIA_ID"
28
+ # }
29
+ # }
30
+ def send_image_custom(to_user, media_id)
31
+ message = default_options(to_user).merge({msgtype: image, image: {media_id: media_id}})
32
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
33
+ end
34
+
35
+ # 发送语音消息
36
+ # {
37
+ # "touser":"OPENID",
38
+ # "msgtype":"voice",
39
+ # "voice":
40
+ # {
41
+ # "media_id":"MEDIA_ID"
42
+ # }
43
+ # }
44
+ def send_voice_custom(to_user, media_id)
45
+ message = default_options(to_user).merge({msgtype: voice, voice: {media_id: media_id}})
46
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
47
+ end
48
+
49
+ # 发送视频消息
50
+ # {
51
+ # "touser":"OPENID",
52
+ # "msgtype":"video",
53
+ # "video":
54
+ # {
55
+ # "media_id":"MEDIA_ID"
56
+ # }
57
+ # }
58
+ def send_video_custom(to_user, media_id, options)
59
+ video_options = {media_id: media_id}.merge(options)
60
+ message = default_options(to_user).merge({msgtype: video, video: video_options})
61
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
62
+ end
63
+
64
+ # 发送音乐消息
65
+ # {
66
+ # "touser":"OPENID",
67
+ # "msgtype":"music",
68
+ # "music":
69
+ # {
70
+ # "title":"MUSIC_TITLE",
71
+ # "description":"MUSIC_DESCRIPTION",
72
+ # "musicurl":"MUSIC_URL",
73
+ # "hqmusicurl":"HQ_MUSIC_URL",
74
+ # "thumb_media_id":"THUMB_MEDIA_ID"
75
+ # }
76
+ # }
77
+ def send_music_custom(to_user, media_id, musicurl, hqmusicurl, options)
78
+ music_options = { thumb_media_id: media_id, musicurl: musicurl,
79
+ hqmusicurl: hqmusicurl}.merge(options)
80
+ message = default_options(to_user).merge({msgtype: music, music: music_options})
81
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
82
+ end
83
+
84
+ # 发送图文消息
85
+ # {
86
+ # "touser":"OPENID",
87
+ # "msgtype":"news",
88
+ # "news":{
89
+ # "articles": [
90
+ # {
91
+ # "title":"Happy Day",
92
+ # "description":"Is Really A Happy Day",
93
+ # "url":"URL",
94
+ # "picurl":"PIC_URL"
95
+ # },
96
+ # {
97
+ # "title":"Happy Day",
98
+ # "description":"Is Really A Happy Day",
99
+ # "url":"URL",
100
+ # "picurl":"PIC_URL"
101
+ # }
102
+ # ]
103
+ # }
104
+ # }
105
+ def send_news_custom(to_user, *articles)
106
+ message = default_options(to_user).merge({msgtype: "news", news: {articles: articles}})
107
+ JSON.parse(RestClient.post(custom_base_url, MultiJson.dump(message)))
108
+ end
109
+
110
+ private
111
+
112
+ # https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
113
+ def custom_base_url
114
+ "#{endpoint}/message/custom/send?#{access_token_param}"
115
+ end
116
+
117
+ def default_options(to_user)
118
+ {touser: to_user, msgtype: "text"}
119
+ end
120
+
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ module WeixinAuthorize
3
+ module Api
4
+ module Groups
5
+
6
+ # 创建分组
7
+ # https://api.weixin.qq.com/cgi-bin/groups/create?access_token=ACCESS_TOKEN
8
+ def create_group(group_name)
9
+ create_url = "#{group_base_url}/create?#{access_token_param}"
10
+ group = MultiJson.dump({group: {name: group_name}})
11
+ JSON.parse(RestClient.post(create_url, group))
12
+ end
13
+
14
+ # 查询所有分组
15
+ # https://api.weixin.qq.com/cgi-bin/groups/get?access_token=ACCESS_TOKEN
16
+ def groups
17
+ groups_url = "#{group_base_url}/get?#{access_token_param}"
18
+ JSON.parse(RestClient.get(groups_url))
19
+ end
20
+
21
+ # 查询用户所在分组
22
+ # https://api.weixin.qq.com/cgi-bin/groups/getid?access_token=ACCESS_TOKEN
23
+ def get_group_for(openid)
24
+ group_url = "#{group_base_url}/getid?#{access_token_param}"
25
+ openid = MultiJson.dump({openid: openid})
26
+ JSON.parse(RestClient.post(group_url, openid))
27
+ end
28
+
29
+ # 修改分组名
30
+ # https://api.weixin.qq.com/cgi-bin/groups/update?access_token=ACCESS_TOKEN
31
+ def update_group_name(group_id, new_group_name)
32
+ group_url = "#{group_base_url}/update?#{access_token_param}"
33
+ group = MultiJson.dump({group: {id: openid, name: new_group_name}})
34
+ JSON.parse(RestClient.post(group_url, group))
35
+ end
36
+
37
+ # 移动用户分组
38
+ # https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=ACCESS_TOKEN
39
+ def update_group_for_openid(openid, to_groupid)
40
+ group_url = "#{group_base_url}/members/update?#{access_token_param}"
41
+ group = MultiJson.dump({openid: openid, to_groupid: to_groupid})
42
+ JSON.parse(RestClient.post(group_url, group))
43
+ end
44
+
45
+ private
46
+
47
+ def group_base_url
48
+ "#{endpoint}/groups"
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ module WeixinAuthorize
3
+ module Api
4
+ module Menu
5
+
6
+ # 自定义菜单查询接口
7
+ # https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN
8
+ def menu
9
+ get_menu_url = "#{menu_base_url}/get?#{access_token_param}"
10
+ JSON.parse(RestClient.get(get_menu_url))
11
+ end
12
+
13
+ # 自定义菜单删除接口
14
+ # https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN
15
+ def delete_menu
16
+ delete_menu_url = "#{menu_base_url}/delete?#{access_token_param}"
17
+ JSON.parse(RestClient.get(delete_menu_url))
18
+ end
19
+
20
+ # 自定义菜单创建接口
21
+ # https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
22
+ def create_menu(menu)
23
+ create_menu_url = "#{menu_base_url}/create?#{access_token_param}"
24
+ JSON.parse(RestClient.post(create_menu_url, menu))
25
+ end
26
+
27
+ private
28
+
29
+ def menu_base_url
30
+ "#{endpoint}/menu"
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ module WeixinAuthorize
3
+ module Api
4
+ module User
5
+
6
+ # 获取用户基本信息
7
+ # https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
8
+ # lang: zh_CN, zh_TW, en
9
+ def user(openid, lang="zh_CN")
10
+ user_info_url = "#{user_base_url}/info?#{access_token_param}&openid=#{openid}&lang=#{lang}"
11
+ JSON.parse(RestClient.get(user_info_url))
12
+ end
13
+
14
+ # https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
15
+ # 获取关注者列表
16
+ def followers(next_openid=nil)
17
+ users_url = "#{user_base_url}/get?#{access_token_param}&next_openid#{next_openid}"
18
+ JSON.parse(RestClient.get(users_url))
19
+ end
20
+
21
+ private
22
+
23
+ def user_base_url
24
+ "#{endpoint}/user"
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ module WeixinAuthorize
4
+
5
+ class Client
6
+ include Api::User
7
+ include Api::Menu
8
+ include Api::Custom
9
+ include Api::Groups
10
+
11
+ attr_accessor :app_id, :app_secret, :expired_at # Time.now + expires_in
12
+ attr_accessor :access_token
13
+
14
+ def initialize(app_id="", app_secret="", expired_at=nil)
15
+ @app_id = app_id
16
+ @app_secret = app_secret
17
+ @expired_at = (expired_at.to_i || Time.now.to_i)
18
+ yield self if block_given?
19
+ end
20
+
21
+ # return token
22
+ def get_access_token
23
+ # 如果当前token过期时间小于现在的时间,则重新获取一次
24
+ if @expired_at <= Time.now.to_i
25
+ authenticate
26
+ end
27
+ @access_token
28
+ end
29
+
30
+ # authenticate access_token
31
+ def authenticate
32
+ hash_infos = JSON.parse(RestClient.get(authenticate_url))
33
+ self.access_token = hash_infos["access_token"]
34
+ self.expired_at = Time.now.to_i + hash_infos["expires_in"]
35
+ end
36
+
37
+ private
38
+
39
+ def authenticate_url
40
+ "#{endpoint}/token?grant_type=client_credential&appid=#{app_id}&secret=#{app_secret}"
41
+ end
42
+
43
+ def endpoint
44
+ "https://api.weixin.qq.com/cgi-bin"
45
+ end
46
+
47
+ def access_token_param
48
+ "access_token=#{get_access_token}"
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module WeixinAuthorize
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ require "rest-client"
2
+ require "multi_json"
3
+ require "weixin_authorize/version"
4
+ require "weixin_authorize/api/user"
5
+ require "weixin_authorize/api/menu"
6
+ require "weixin_authorize/api/custom"
7
+ require "weixin_authorize/api/groups"
8
+ require "weixin_authorize/client"
9
+
10
+ module WeixinAuthorize
11
+
12
+ # @client ||= WeixinAuthorize.configure do |config|
13
+ # config.app_id = "app_id-xxxxxxx"
14
+ # config.app_secret = "app_secret-xxxxxxx"
15
+ # end
16
+ #
17
+ class << self
18
+ def configure(&block)
19
+ Client.new(&block)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe WeixinAuthorize::Api::Custom do
4
+ it "can send a text Custom message" do
5
+ response = $client.send_text_custom(ENV["OPENID"], "test send Custom Message")
6
+ puts response
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+ describe WeixinAuthorize::Api::Groups do
3
+ it "create a group" do
4
+ response = $client.create_group("test")
5
+ response
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe WeixinAuthorize::Api::Menu do
5
+
6
+ it "can create a menu" do
7
+ menu = '{"button":[{"type":"click","name":"今日歌曲","key":"V1001_TODAY_MUSIC"},{"type":"click","name":"歌手简介","key":"V1001_TODAY_SINGER"},{"name":"菜单","sub_button":[{"type":"view","name":"搜索","url":"http://www.soso.com/"},{"type":"view","name":"视频","url":"http://v.qq.com/"},{"type":"click","name":"赞一下我们","key":"V1001_GOOD"}]}]}'
8
+ response = $client.create_menu(menu)
9
+ expect(response["errcode"]).to eq(0)
10
+ end
11
+
12
+ it "can get a weixin Menu info" do
13
+ menu_info = $client.menu
14
+ expect(menu_info.keys[0]).to eq("menu")
15
+ end
16
+
17
+ it "can delete weixin Menu" do
18
+ response = $client.delete_menu
19
+ expect(response["errcode"]).to eq(0)
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ describe WeixinAuthorize::Api::User do
4
+ it "can get a weixin User info" do
5
+ user_info = $client.user(ENV["OPENID"])
6
+ puts user_info
7
+ end
8
+
9
+ it "can get followers infos" do
10
+ followers = $client.followers
11
+ puts followers
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # NOTE: the rspec should be test alonely.
2
+ require "spec_helper"
3
+ describe WeixinAuthorize::Client do
4
+ describe "#get access_token" do
5
+ it "return a access_token nil value before authenticate" do
6
+ expect($client.access_token).to eq(nil)
7
+ end
8
+
9
+ it "return access_token after authenticate" do
10
+ $client.authenticate
11
+ expect($client.access_token).not_to eq(nil)
12
+ end
13
+
14
+ it "return the same access_token in the same thing twice" do
15
+ access_token_1 = $client.get_access_token
16
+ sleep 5
17
+ access_token_2 = $client.get_access_token
18
+ expect(access_token_1).to eq(access_token_2)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,93 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # (such as loading up an entire rails app) will add to the boot time of your
9
+ # test suite on EVERY test run, even for an individual file that may not need
10
+ # all of that loaded.
11
+ #
12
+ # The `.rspec` file also contains a few flags that are not defaults but that
13
+ # users commonly want.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ require "rspec"
17
+ require "weixin_authorize"
18
+
19
+ # $client ||= WeixinAuthorize.configure do |config|
20
+ # config.app_id = ENV["APPID"]
21
+ # config.app_secret = ENV["APPSECRET"]
22
+ # config.expired_at = Time.now.to_i
23
+ # end
24
+
25
+ $client = WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
26
+
27
+ RSpec.configure do |config|
28
+ # The settings below are suggested to provide a good initial experience
29
+ # with RSpec, but feel free to customize to your heart's content.
30
+ =begin
31
+ # These two settings work together to allow you to limit a spec run
32
+ # to individual examples or groups you care about by tagging them with
33
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
34
+ # get run.
35
+ config.filter_run :focus
36
+ config.run_all_when_everything_filtered = true
37
+
38
+ # Many RSpec users commonly either run the entire suite or an individual
39
+ # file, and it's useful to allow more verbose output when running an
40
+ # individual spec file.
41
+ if config.files_to_run.one?
42
+ # RSpec filters the backtrace by default so as not to be so noisy.
43
+ # This causes the full backtrace to be printed when running a single
44
+ # spec file (e.g. to troubleshoot a particular spec failure).
45
+ config.full_backtrace = true
46
+
47
+ # Use the documentation formatter for detailed output,
48
+ # unless a formatter has already been configured
49
+ # (e.g. via a command-line flag).
50
+ config.formatter = 'doc' if config.formatters.none?
51
+ end
52
+
53
+ # Print the 10 slowest examples and example groups at the
54
+ # end of the spec run, to help surface which specs are running
55
+ # particularly slow.
56
+ config.profile_examples = 10
57
+
58
+ # Run specs in random order to surface order dependencies. If you find an
59
+ # order dependency and want to debug it, you can fix the order by providing
60
+ # the seed, which is printed after each run.
61
+ # --seed 1234
62
+ config.order = :random
63
+
64
+ # Seed global randomization in this process using the `--seed` CLI option.
65
+ # Setting this allows you to use `--seed` to deterministically reproduce
66
+ # test failures related to randomization by passing the same `--seed` value
67
+ # as the one that triggered the failure.
68
+ Kernel.srand config.seed
69
+
70
+ # rspec-expectations config goes here. You can use an alternate
71
+ # assertion/expectation library such as wrong or the stdlib/minitest
72
+ # assertions if you prefer.
73
+ config.expect_with :rspec do |expectations|
74
+ # Enable only the newer, non-monkey-patching expect syntax.
75
+ # For more details, see:
76
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
77
+ expectations.syntax = :expect
78
+ end
79
+
80
+ # rspec-mocks config goes here. You can use an alternate test double
81
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
82
+ config.mock_with :rspec do |mocks|
83
+ # Enable only the newer, non-monkey-patching expect syntax.
84
+ # For more details, see:
85
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
86
+ mocks.syntax = :expect
87
+
88
+ # Prevents you from mocking or stubbing a method that does not exist on
89
+ # a real object. This is generally recommended.
90
+ mocks.verify_partial_doubles = true
91
+ end
92
+ =end
93
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'weixin_authorize/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "weixin_authorize"
8
+ spec.version = WeixinAuthorize::VERSION
9
+ spec.authors = ["lanrion"]
10
+ spec.email = ["huaitao-deng@foxmail.com"]
11
+ spec.description = %q{weixin api authorize access_token}
12
+ spec.summary = %q{weixin api authorize access_token}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_dependency "rest-client", ">= 1.6.7"
22
+ spec.add_runtime_dependency 'multi_json' , "~> 1.7.2"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.0.0.beta1"
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: weixin_authorize
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - lanrion
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0.beta1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0.beta1
83
+ description: weixin api authorize access_token
84
+ email:
85
+ - huaitao-deng@foxmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/weixin_authorize.rb
97
+ - lib/weixin_authorize/api/custom.rb
98
+ - lib/weixin_authorize/api/groups.rb
99
+ - lib/weixin_authorize/api/menu.rb
100
+ - lib/weixin_authorize/api/user.rb
101
+ - lib/weixin_authorize/client.rb
102
+ - lib/weixin_authorize/version.rb
103
+ - spec/api/custom_spec.rb
104
+ - spec/api/groups_spec.rb
105
+ - spec/api/menu_spec.rb
106
+ - spec/api/user_spec.rb
107
+ - spec/fetch_access_token_spec.rb
108
+ - spec/spec_helper.rb
109
+ - weixin_authorize.gemspec
110
+ homepage: ''
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.2.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: weixin api authorize access_token
134
+ test_files:
135
+ - spec/api/custom_spec.rb
136
+ - spec/api/groups_spec.rb
137
+ - spec/api/menu_spec.rb
138
+ - spec/api/user_spec.rb
139
+ - spec/fetch_access_token_spec.rb
140
+ - spec/spec_helper.rb