emmy-http 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0971c78d06be99618226ee14b9eb60c57c5cf535
4
- data.tar.gz: b6a4c6026afbaab8215cea42689bae329b119555
3
+ metadata.gz: 0d2479bde7d0c2af0c66e2d9c66a8ad79bff6533
4
+ data.tar.gz: 891e9521c52bfa46ce8744ccd61d7b97e068107f
5
5
  SHA512:
6
- metadata.gz: 33f5fc5aafa7d59ba0865dbdd3f2ca2c3c45325bdcfd30244b1c4e8e4170252ae67895f99e2ee061a97a8388a3ffd8a3b7e5583bb59e208f166403cb41586fc0
7
- data.tar.gz: 6b499296b451a6bac10b39c872c5bd0bae17cd1cf4faf42c8cdbd96677b20fecbc6cccc66ba6fadb1879389ab0d7e1adbf7a16c883239deab79ead719ec9700d
6
+ metadata.gz: 31f5a82f936ac43cd833b8f2ddcc8972d7581eeea3473fdc99ab4a51ea8356980e7b0f0e1e1a1fc07a45f05a59437fa39bcacccca614b50026eaeb8e18abdb52
7
+ data.tar.gz: 72f6b4e00517e3a50fa56d0756afe1f8566d3267a844c0132a1973a3499c9243cb8d0abf6995b4c97ba14ee7e76ed6721eeb6eac7ec684db5f4aeb826c076d98
@@ -1,72 +1,3 @@
1
- #
2
- # class Google
3
- # include EmmyHttp::Model
4
- # adapter EmmyExtends::EmHttpRequest
5
- # defaults {
6
- # headers: {
7
- # 'Content-Type' => 'application/json'
8
- # }
9
- # }
10
- #
11
- # post ''
12
- # end
13
- #
14
- # google = Google.new(url: 'http://google.com')
15
- # response = google.sync
16
-
17
- #
18
- # module DigitalOcean
19
- # using EventObject
20
- # API_TOKEN = "b7d03a6947b217efb6f3ec3bd3504582"
21
- #
22
- # class DigitalOcean::Error < StandardError; end
23
- #
24
- # class Request
25
- # include EmmyHttp::Model
26
- # adapter EmmyHttp::Client::Adapter
27
- # header 'Content-Type' => 'application/json'
28
- # header "Authorization: Bearer #{API_TOKEN}"
29
- #
30
- # events :success, :error
31
- #
32
- # def sync
33
- # connect
34
- #
35
- # Fiber.sync do |f|
36
- # on :success do |content|
37
- # f.resume content
38
- # end
39
- #
40
- # on :error do |message|
41
- # raise DigitalOcean::Error, message
42
- # end
43
- # end
44
- # end
45
- #
46
- # def request
47
- # op = super(
48
- #
49
- # ).op
50
- #
51
- # op.on :success do |response, operation, conn|
52
- # success!(response.content)
53
- # end
54
- #
55
- # op.on :error do |message, operation, conn|
56
- # error!(message)
57
- # end
58
- # end
59
- # end
60
- #
61
- #
62
- # class Droplets < Request
63
- # get list: '/v2/droplets'
64
- # post new: '/v2/droplets'
65
- # get get: '/v2/:id'
66
- #
67
- #
68
- # end
69
- # end
70
1
  require 'singleton'
71
2
 
72
3
  module EmmyHttp
@@ -87,27 +18,31 @@ module EmmyHttp
87
18
 
88
19
  module ClassMethods
89
20
  def request(a=nil)
90
- instance.request.tap { |req| req.update_attributes(a) if a }
21
+ instance.request.copy.tap { |req| req.update_attributes(a) if a }
22
+ end
23
+
24
+ def request!(a=nil)
25
+ request(a).operation
91
26
  end
92
27
 
93
28
  def adapter(name)
94
- request.adapter = name
29
+ instance.request.adapter = name
95
30
  end
96
31
 
97
32
  def url(uri)
98
- request.url = uri
33
+ instance.request.url = uri
99
34
  end
100
35
 
101
36
  def defaults(attributes)
102
- request.update_attributes(attributes)
37
+ instance.request.update_attributes(attributes)
103
38
  end
104
39
 
105
40
  def headers(head)
106
- request.headers.merge!(head)
41
+ instance.request.headers.merge!(head)
107
42
  end
108
43
 
109
44
  def raise_error(flag)
110
- request.raise_error = flag
45
+ instance.request.raise_error = flag
111
46
  end
112
47
 
113
48
  alias header headers
@@ -115,7 +50,7 @@ module EmmyHttp
115
50
  EmmyHttp::HTTP_METHODS.each do |name|
116
51
  define_method name do |path, as: nil|
117
52
  cdef as.to_s do |*a|
118
- instance.var(as.to_s, request.copy.tap { |r| r.update_attributes(path: path) })
53
+ instance.var(as.to_s, request(path: path))
119
54
  end
120
55
 
121
56
  cdef "#{as}!" do |*a, &b|
@@ -1,3 +1,3 @@
1
1
  module EmmyHttp
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emmy-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - inre