motion-wechat 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 +8 -8
- data/README.md +1 -6
- data/lib/motion-wechat/api.rb +7 -6
- data/lib/motion-wechat/config.rb +3 -6
- data/lib/motion-wechat/version.rb +1 -1
- data/spec/motion-wechat/api_spec.rb +6 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGExN2E3MDA5Mzc4YjFmZmMyNjE3NjQ4ZTI4NzdjNjg4OTVmN2MxNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGQwOTMxYzNhNzI3ZDQxNTk5YWNmMDdkNmU0NWQ3ODEwZWEyMDNjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2NlMGI1ODJkYTgzNTFjNDc1NzA3ZTUyOTFmYjFjMWI4MjQxNWJmMzVmNjBm
|
10
|
+
ZGZlZWZkNzA2YjFhNjIzNDAzMjE2NGJhNDc0N2MyODRiZDZlZjgyZjA3MTAw
|
11
|
+
ZTNkZTNlOGQ0ODE4MjUyM2RjZGJhMjViNWUzMzJlNGQ5NzNkODA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjIxMzc2NDI5YmYyMGU2N2Q1MDE1NzlhMjI3MTVjZDNjNGExOTRkMjZiNWY1
|
14
|
+
MmUzZmVhNWMyZmFlYjliZjFjNWEyNmFkNjZmNGFlZDM0MjI5Yzg5YTUxZDYy
|
15
|
+
M2JlYTc5NzZhZTJiNjFmMTEwYzllNmMyYjRlMTFkYTJlYjRiMDQ=
|
data/README.md
CHANGED
@@ -28,11 +28,6 @@ end
|
|
28
28
|
MotionWechat::Config.setup(app, 'app_key', 'app_secret')
|
29
29
|
```
|
30
30
|
|
31
|
-
Initialize in app_delegate.rb
|
32
|
-
```ruby
|
33
|
-
MotionWechat::API.instance.register
|
34
|
-
```
|
35
|
-
|
36
31
|
Usage
|
37
32
|
==========
|
38
33
|
|
@@ -44,7 +39,7 @@ MotionWechat::API.instance.send_webpage "http://www.rubymotion.com", \
|
|
44
39
|
```
|
45
40
|
|
46
41
|
## TODO
|
47
|
-
-
|
42
|
+
- delegate helpers, i.e. `WXApi.handleOpenURL(url, delegate:self)`
|
48
43
|
|
49
44
|
## Contributions
|
50
45
|
|
data/lib/motion-wechat/api.rb
CHANGED
@@ -2,14 +2,12 @@ module MotionWechat
|
|
2
2
|
module API
|
3
3
|
|
4
4
|
InvalidMediaObject = Class.new StandardError
|
5
|
+
def wx; WXApi; end
|
5
6
|
|
7
|
+
# initialize weixin API using key and secret
|
6
8
|
def initialize(key, secret, options={})
|
7
9
|
@key = key
|
8
10
|
@secret = secret
|
9
|
-
end
|
10
|
-
|
11
|
-
# Register WechatAPI
|
12
|
-
def register
|
13
11
|
WXApi.registerApp(@key)
|
14
12
|
end
|
15
13
|
|
@@ -19,8 +17,11 @@ module MotionWechat
|
|
19
17
|
# MotionWechat::API.instance
|
20
18
|
#
|
21
19
|
def self.instance
|
22
|
-
@
|
23
|
-
|
20
|
+
@instance ||= new config["key"], config["secret"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.config
|
24
|
+
NSBundle.mainBundle.objectForInfoDictionaryKey MotionWechat::Config.info_plist_key
|
24
25
|
end
|
25
26
|
|
26
27
|
# Send media objects, i.e. webpage, video, music and image to wechat
|
data/lib/motion-wechat/config.rb
CHANGED
@@ -22,7 +22,6 @@ module MotionWechat
|
|
22
22
|
# other options: (Hash)
|
23
23
|
def setup(app, key, secret, opts={})
|
24
24
|
options = {
|
25
|
-
bundle_url_name: "weixin",
|
26
25
|
key: key,
|
27
26
|
secret: secret
|
28
27
|
}.merge(opts)
|
@@ -34,11 +33,9 @@ module MotionWechat
|
|
34
33
|
'CFBundleURLSchemes' => [app.info_plist[info_plist_key][:key]] }
|
35
34
|
]
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
app.info_plist['CFBundleURLTypes'] = bundle_url_types
|
41
|
-
end
|
36
|
+
app.info_plist['CFBundleURLTypes'] ||= []
|
37
|
+
app.info_plist['CFBundleURLTypes'] << bundle_url_types
|
38
|
+
|
42
39
|
end
|
43
40
|
|
44
41
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
describe MotionWechat::API do
|
2
2
|
|
3
|
-
before { @mv = MotionWechat::API.instance }
|
4
|
-
|
5
3
|
it "should call register key" do
|
6
4
|
WXApi.stub!(:registerApp) do |key|
|
7
5
|
key.should == "app_key"
|
8
6
|
end
|
9
|
-
|
7
|
+
MotionWechat::API.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return WXApi as wx" do
|
11
|
+
MotionWechat::API.instance.wx.should == WXApi
|
10
12
|
end
|
11
13
|
|
12
14
|
describe "Send messages" do
|
13
15
|
|
14
|
-
before { @mv.
|
16
|
+
before { @mv = MotionWechat::API.instance }
|
15
17
|
|
16
18
|
it 'sends web page url' do
|
17
19
|
WXApi.stub!(:sendReq) do |req|
|