motion-wechat 0.0.1 → 0.0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTEwNDE5OGQyYzJhMmQ2NTY2OWFiMjEzYWU4NmYwMzQ3NTcwNjhmNg==
4
+ ZGExN2E3MDA5Mzc4YjFmZmMyNjE3NjQ4ZTI4NzdjNjg4OTVmN2MxNg==
5
5
  data.tar.gz: !binary |-
6
- OTQ4OTlhN2I1ZWY3ZGVhMWFmNTVhMjNlNjM0NjFkZDgyODk0ZTY4NQ==
6
+ NGQwOTMxYzNhNzI3ZDQxNTk5YWNmMDdkNmU0NWQ3ODEwZWEyMDNjMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWQ5OTY0YjI3NjgzMDhlMGRhMDQ0NTcxODlhMmJhZjQ1NzQ5NmIxOTc1MWVl
10
- NjI0ZmM4OWZjMWM5NTVjNDgyY2Q3NDAwYjRlMjc2NzcwNjNjMWVhOTBmNGVi
11
- OWVhMzZjMzJhMzU4ZTAzNTQ3OThkYTBiNmNiY2Q0YjcyMDgzMGM=
9
+ M2NlMGI1ODJkYTgzNTFjNDc1NzA3ZTUyOTFmYjFjMWI4MjQxNWJmMzVmNjBm
10
+ ZGZlZWZkNzA2YjFhNjIzNDAzMjE2NGJhNDc0N2MyODRiZDZlZjgyZjA3MTAw
11
+ ZTNkZTNlOGQ0ODE4MjUyM2RjZGJhMjViNWUzMzJlNGQ5NzNkODA=
12
12
  data.tar.gz: !binary |-
13
- NmE0YzhkYTAxY2FjNjM5MWJlZWUwYjhhYWY0YjBhZDhmYTdmMjRjYWVhNWJi
14
- Y2I3YTBlMTFkNWQzMWExYWE3N2U0OGRlNjYxODYzZmNiYjZjYWVhZDE1MmY0
15
- ZWY1N2NhYmM2YjAxZjhiNmM3YzFlMjg2MzIwZmUwMTgzOTk1ZWM=
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
- - delegete helpers, i.e. `WXApi.handleOpenURL(url, delegate:self)`
42
+ - delegate helpers, i.e. `WXApi.handleOpenURL(url, delegate:self)`
48
43
 
49
44
  ## Contributions
50
45
 
@@ -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
- @config ||= NSBundle.mainBundle.objectForInfoDictionaryKey MotionWechat::Config.info_plist_key
23
- @instance = new @config["key"], @config["secret"]
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
@@ -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
- if app.info_plist['CFBundleURLTypes']
38
- app.info_plist['CFBundleURLTypes'] += bundle_url_types
39
- else
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,3 +1,3 @@
1
1
  module MotionWechat
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  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
- @mv.register
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.register }
16
+ before { @mv = MotionWechat::API.instance }
15
17
 
16
18
  it 'sends web page url' do
17
19
  WXApi.stub!(:sendReq) do |req|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-wechat
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
  - Qi He