lanxin_open 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
- NDYyZmM5MjQzOTA2NGViZTQ4ZWRhOTcwMTY3NzJiZTAxNmEyZWMyYw==
4
+ NTdhZjE3NTI5NWIwN2FlZTM3YTYxODFmY2NhOGJkZmYwNWJkNTJiNg==
5
5
  data.tar.gz: !binary |-
6
- ODM3NTRlM2FlNTg0YWZjMTQ2MmNkNWU2NjQ3OTUwMjlhYjliNGRmNw==
6
+ MWRjM2MyZDM2NDAzYjY5MDlhMmYxZjk5NGI3Y2U3MjllMGFhMjA3ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDg3MTZlY2ZlZjFmYzAxMGQ5NGQwZjkzMTNmZjcwNzBhMjFiYTNhM2MxYjhk
10
- MjQyNjczNzg2M2Q0YmNjNWZlNjhmOTIyYjFhMWQ4ZWU4YTRkYmUyZmM0MTA2
11
- YjhiZjk1YWZlZGI0ZDYxOTMyYjM0MDFhOGQ3YzdjZDQ3NTUwZmQ=
9
+ Yzg5MWNmNGI3N2UyZWJiNzQzN2MwYzI0YjFkYThhNDkxM2U1NzFjODY0MDZj
10
+ NzE3YjIzM2M3Yjg4ZGQyOGIyY2Q0YmY2YzE1MDg4MDczNWI5YWNjMWI2ODQz
11
+ ZWU2NzY3NDM1NDk4OTE2Y2I1ZDQ3YWJjNmU4YzhmNzE3MTliNTc=
12
12
  data.tar.gz: !binary |-
13
- MTQ0ZmE5ZGQ1YjY0MzJmM2IzYzQxODA1OGU0MjEzYWU2NDkzMjE3YTcwN2Rk
14
- OTBhMzBlY2Y1MTc0MTI3NDgzNTM0M2EyN2ZmOGQ1ODg2MWQ3NDBkZjliZDgz
15
- MTM1ZDdiMzg3ZGRjM2Q2NDIzZjlhZWRkYTAyZWU3NzIyODdhNjM=
13
+ YjAxNjY2ZjM0MWVhZDIxODI0NzQxZjk1NWI0YmZmNDM4OTAyYzM2MjZkYzJl
14
+ MzU2NDFiMDAxZTJmZjdkZDI0MDA4NzBjYzU3OGU0MTJmZjNmYzk1NWJmNGU1
15
+ NWI2ODlkOTQ4ZjI0ODUxMmU1NzQ1MDZlMGI4MjJjOTAwOWYxNWI=
data/lib/lanxin_open.rb CHANGED
@@ -24,8 +24,12 @@ module LanxinOpen
24
24
  instance_eval &block
25
25
  end
26
26
 
27
+ def self.new(args)
28
+ OpenPlatformV1.new(args)
29
+ end
30
+
27
31
  def self.new
28
- OpenPlatformV1.new
32
+ OpenPlatformV1.new({})
29
33
  end
30
34
 
31
35
  def self.dean_hash2xml(p_hash)
@@ -116,13 +120,14 @@ module LanxinOpen
116
120
 
117
121
  module Platform
118
122
  attr_accessor :skey
123
+ attr_accessor :host,:port,:use_new_json
119
124
 
120
125
  def dump_config
121
- puts "test_config #{LanxinOpen.host}, #{LanxinOpen.port}, #{LanxinOpen.use_new_json}"
126
+ puts "test_config #{host}, #{port}, #{use_new_json}"
122
127
  end
123
128
 
124
129
  def host_with_port
125
- "#{LanxinOpen.host}:#{LanxinOpen.port}"
130
+ "#{host}:#{port}"
126
131
  end
127
132
 
128
133
  def lx_url(path)
@@ -156,7 +161,6 @@ module LanxinOpen
156
161
  end
157
162
  end
158
163
  gbk = content_utf8(body,"gbk")
159
- return gbk
160
164
  end
161
165
 
162
166
  def fetch_skey(token,devkey)
@@ -210,6 +214,12 @@ module LanxinOpen
210
214
  class OpenPlatformV1
211
215
  include Platform
212
216
 
217
+ def initialize(args)
218
+ @host = args[:host] || LanxinOpen.host
219
+ @port = args[:port] || LanxinOpen.port
220
+ @use_new_json = args[:use_new_json] || LanxinOpen.use_new_json
221
+ end
222
+
213
223
  def kehu_msg(fieldvalue,from_user)
214
224
  req_url = lx_url("/opc/ishow")
215
225
  params = {
@@ -231,7 +241,7 @@ module LanxinOpen
231
241
  "msgtype" => "text",
232
242
  "text" => text_json.to_json
233
243
  }
234
- base_json["text"] = text_json if LanxinOpen.use_new_json
244
+ base_json["text"] = text_json if use_new_json
235
245
  body = kehu_msg(base_json,from_user)
236
246
  end
237
247
 
@@ -243,7 +253,6 @@ module LanxinOpen
243
253
  "url" => url
244
254
  }
245
255
  body = kehu_msg(base_json,from_user)
246
- return body
247
256
  end
248
257
 
249
258
  def send_pictext_msg(url,open_id,title,from_user)
@@ -255,9 +264,8 @@ module LanxinOpen
255
264
  "title" => title,
256
265
  "news" => news_json
257
266
  }
258
- # base_json["news"] = news_json if LanxinOpen.use_new_json
267
+ # base_json["news"] = news_json if use_new_json
259
268
  body = kehu_msg(base_json,from_user)
260
- return body
261
269
  end
262
270
 
263
271
  def send_mail_msg(url,open_id,title,from_user)
@@ -309,7 +317,7 @@ module LanxinOpen
309
317
  body = encode_resbody(NetUtil.post_req(req_url,params).body)
310
318
  end
311
319
 
312
- end
320
+ end # End of OpenPlatformV1 class
313
321
 
314
322
  end
315
323
 
@@ -1,3 +1,3 @@
1
1
  module LanxinOpen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lanxin_open
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
  - wangdean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler