em-sessions 0.2.1 → 0.3.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97c1738cb29d068308ae318dd52f2a824d8628b1
4
- data.tar.gz: b785c46e65fcc3b9d9b103678544c209ff2da2ae
3
+ metadata.gz: 8683eb90efd579068627bf9eaa03321a63e58ba3
4
+ data.tar.gz: 431b1063140d7957b43323f7ac33cfaa95dfae74
5
5
  SHA512:
6
- metadata.gz: 58cd568cd4885be8a550999efda4eb6b6cc0a54a39f0d8b45b4d9987b0ea74532582efa3bfa6e9d10cbcc665bc6259ce13e4ce31da286507df9df6dce8d88f96
7
- data.tar.gz: 5fb23f27b1bba3c63b0ea021c53a12f653d7091ab5020d45eb8c075b374d75d96fb7135074cdab955e9f3a30e12bc41b81bc4ebc29528def9f16cdc7fbe24d4a
6
+ metadata.gz: c63d640a562ed57b77db6045546749bc907e5e558383c32927bc2837e6e6e6749d9c7a03b180e59644948a9e882b9b90eac9878016126674efcf0728d008b4f2
7
+ data.tar.gz: adc30ab4e3b3e08981ef0e914f0c7ff9e9a0380bfe50236f5e4903a61d737707ce46a39c74ed237e4229da8e162a4a00e06b42ab0d53b04025ef7260d249fa45
data/README.md CHANGED
@@ -28,15 +28,19 @@ and run `bundle install` to install the dependency.
28
28
  # default: init(url = 'localhost:3000', app = 'weapp')
29
29
  Em::Sessions.init
30
30
  client = Em::Sessions.client
31
+
32
+ or
33
+
34
+ client = Em::Sessions.client 'localhost:3000', 'weapp'
31
35
  ```
32
36
  ## Notice ##
33
37
  client`s all methods return two params, one code, one json, such as:
34
38
  ```ruby
35
- client.create('1') # [200, {"token": "9kwi9wu429dkw8urkhr923jrekw32" ]
39
+ client.create '1' # [200, {"token": "9kwi9wu429dkw8urkhr923jrekw32" ]
36
40
  ```
37
41
  you can
38
42
  ```ruby
39
- code, json = client.create('1')
43
+ code, json = client.create '1'
40
44
  json['token'] # 9kwi9wu429dkw8urkhr923jrekw32
41
45
  ```
42
46
 
@@ -4,28 +4,23 @@ require 'em/sessions/client'
4
4
  module Em
5
5
  module Sessions
6
6
  class << self
7
- attr_reader :http_url, :client, :app
8
- def init(http_url = 'localhost:3000', app = 'weapp')
9
- @http_url ||= http_url
10
- @app = app
11
- end
7
+ attr_accessor :last_client, :url, :app
12
8
 
13
- def client
14
- raise 'Please run Em::Sessions.init(http_url, app) method' if @http_url.nil? && @app.nil?
15
- @client ||= Client.new @http_url, @app
16
- end
17
9
 
18
- def modify_url(url)
19
- @http_url = url
20
- @client = nil
10
+ # if use init, every each call client, this client are same
11
+ def init(url = 'localhost:3000', app = 'weapp')
12
+ @url = url
13
+ @app = app
21
14
  end
22
15
 
23
- def modify_app(app)
24
- @app = app
25
- @client = nil
16
+ def client(url = nil, app = nil)
17
+ set_url = url.nil? ? @url : url
18
+ set_app = app.nil? ? @app : app
19
+ raise 'Please input url or app_name,such as: client("localhost:3000", "weapp")' if set_url.nil? || set_app.nil?
20
+ @last_client = Client.new set_url, set_app
21
+ @last_client
26
22
  end
27
23
 
28
- private
29
24
  end
30
25
  end
31
26
  end
@@ -4,7 +4,7 @@ module Em
4
4
  class Client
5
5
 
6
6
 
7
- attr_accessor :http_url, :app
7
+ attr_reader :http_url, :app
8
8
 
9
9
  def initialize(url, app)
10
10
  if url.nil? || app.nil?
@@ -1,5 +1,5 @@
1
1
  module Em
2
2
  module Sessions
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-sessions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - millim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-17 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler