emmy-http 0.1.1 → 0.1.2

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: 39764e025c6870fb136cc4a884e6d64431c88095
4
- data.tar.gz: 9562f899182119fcd519d6165e5357078e31a784
3
+ metadata.gz: 70365ac9ad4776b5762ff755c75fdcbd94c7d038
4
+ data.tar.gz: f83c220fede9f1a9583e1e510da5703c79bf5166
5
5
  SHA512:
6
- metadata.gz: e9fe0b8a5b137b27d568d2b88d49b1627ff71cd4e70723fe78087ea50e8838ba960c1b9b5c3f7fd990e261a4bbbe116f3d4306af81f0972497d711e915cd5c85
7
- data.tar.gz: 1c76bdc834cd662247b736b3c1d4001931c1a1e44f287840a9689226b717d2aee5b6bef59a421be8b77c2ba1edf8e46657a425a899a874a10d167a239c9c7ba8
6
+ metadata.gz: a3ef7b3cc76077633ba522cf2e9f629eb166503f18863c92cbea8ddedc20fa8162e7c5c5c363c6bb09a0a4a27e45756331ee5f8c8571485eff2fc25499a0b45a
7
+ data.tar.gz: f2428aacd6bd3545456e9e1d6532147e1b2ff6b042c8682fd971dd147d986cb0792c6c39d590e4a6f3fc59ec309e231d523fd9109befee712bfb27fe16ba6142
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ emmy-http (0.1.2)
5
+ emmy-machine (~> 0.1)
6
+ fibre (~> 0.9.3)
7
+ model_pack (~> 0.9)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ diff-lcs (1.2.5)
13
+ emmy-machine (0.1.6)
14
+ eventmachine (~> 1.0.3)
15
+ fibre (~> 0.9)
16
+ event_object (0.9.0)
17
+ eventmachine (1.0.3)
18
+ fibre (0.9.6)
19
+ event_object (~> 0.9)
20
+ model_pack (0.9.3)
21
+ rake (10.3.2)
22
+ rspec (3.1.0)
23
+ rspec-core (~> 3.1.0)
24
+ rspec-expectations (~> 3.1.0)
25
+ rspec-mocks (~> 3.1.0)
26
+ rspec-core (3.1.3)
27
+ rspec-support (~> 3.1.0)
28
+ rspec-expectations (3.1.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.1.0)
31
+ rspec-mocks (3.1.0)
32
+ rspec-support (~> 3.1.0)
33
+ rspec-support (3.1.0)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler (~> 1.6)
40
+ emmy-http!
41
+ rake (~> 10.0)
42
+ rspec (~> 3)
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 che
1
+ Copyright (c) 2014 Che
2
2
 
3
3
  MIT License
4
4
 
data/emmy-http.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "emmy-http"
8
8
  spec.version = EmmyHttp::VERSION
9
9
  spec.authors = ["che"]
10
- spec.email = ["max@kupibilet.ru"]
10
+ spec.email = ["chelovekov@gmail.com"]
11
11
  spec.summary = %q{Emmy Http}
12
12
  #spec.description = %q{TODO: Write a longer description. Optional.}
13
13
  spec.homepage = ""
@@ -11,5 +11,7 @@ module EmmyHttp
11
11
  raise 'method not implemented'
12
12
  end
13
13
  end
14
+
15
+ #<<<
14
16
  end
15
17
  end
@@ -69,5 +69,7 @@ module EmmyHttp
69
69
  response.status = operation.adapter.status
70
70
  end
71
71
  end
72
+
73
+ #<<<
72
74
  end
73
75
  end
@@ -2,8 +2,10 @@ module EmmyHttp
2
2
  class Request
3
3
  include ModelPack::Document
4
4
 
5
- attribute :method, default: "get"
6
- attribute :url, writer: ->(url) { url.is_a?(URI) ? url : URI.parse(url) }
5
+ attribute :type, default: "get" # word *method* reserved in ruby
6
+ attribute :url,
7
+ writer: ->(url) { url.is_a?(URI) ? url : URI.parse(url) },
8
+ serialize: ->(value) { value.to_s }
7
9
  dictionary :headers
8
10
  attribute :body, default: ""
9
11
  attribute :connect_timeout, default: 5
@@ -19,5 +21,7 @@ module EmmyHttp
19
21
  def timeouts
20
22
  @timeouts ||= Timeouts.new
21
23
  end
24
+
25
+ #<<<
22
26
  end
23
27
  end
@@ -0,0 +1,31 @@
1
+ module EmmyHttp
2
+ class Timeout
3
+ using EventObject
4
+ attr_accessor :interval
5
+
6
+ events :timeout
7
+
8
+ def initialize(interval)
9
+ @interval = interval
10
+ end
11
+
12
+ def start
13
+ EmmyMachine.timeout(interval) do
14
+ timeout!
15
+ end
16
+ end
17
+
18
+ def sync
19
+ Fiber.sync do |fiber|
20
+ # create connection
21
+ start
22
+
23
+ on :timeout do
24
+ fiber.resume true
25
+ end
26
+ end
27
+ end
28
+
29
+ #<<<
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module EmmyHttp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/emmy_http.rb CHANGED
@@ -6,9 +6,10 @@ module EmmyHttp
6
6
  class TimeoutError < ConnectionError; end
7
7
 
8
8
  autoload :Adapter, "emmy_http/adapter"
9
- autoload :Timeouts, "emmy_http/request/timeouts"
10
- autoload :SSL, "emmy_http/request/ssl"
9
+ autoload :Timeouts, "emmy_http/request/timeouts"
10
+ autoload :SSL, "emmy_http/request/ssl"
11
11
  autoload :Request, "emmy_http/request"
12
12
  autoload :Operation, "emmy_http/operation"
13
13
  autoload :Response, "emmy_http/response"
14
+ autoload :Timeout, "emmy_http/timeout"
14
15
  end
Binary file
Binary file
@@ -65,7 +65,7 @@ describe EmmyHttp do
65
65
  it "should do http request with fake adapter" do
66
66
  begin
67
67
  request = EmmyHttp::Request.new(
68
- method: 'get',
68
+ type: 'get',
69
69
  url: 'http://google.com'
70
70
  )
71
71
  operation = EmmyHttp::Operation.new(request, FakeAdapter.new)
@@ -78,4 +78,28 @@ describe EmmyHttp do
78
78
  expect(response.headers).to include("Content-Type")
79
79
  expect(response.body).to eq "OK"
80
80
  end
81
+
82
+ it "should wait a couple seconds" do
83
+ begin
84
+ timeout = EmmyHttp::Timeout.new(2)
85
+ res = timeout.sync
86
+ ensure
87
+ EventMachine.stop
88
+ end
89
+ expect(res).to be true
90
+ end
91
+
92
+ it "should serialize request" do
93
+ begin
94
+ request = EmmyHttp::Request.new(
95
+ type: 'get',
96
+ url: 'http://google.com'
97
+ )
98
+ request_hash = request.serializable_hash
99
+ ensure
100
+ EventMachine.stop
101
+ end
102
+ expect(request_hash).to include(type: 'get', url: 'http://google.com')
103
+
104
+ end
81
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emmy-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - che
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: emmy-machine
@@ -96,13 +96,13 @@ dependencies:
96
96
  version: '3'
97
97
  description:
98
98
  email:
99
- - max@kupibilet.ru
99
+ - chelovekov@gmail.com
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
104
  - Gemfile
105
+ - Gemfile.lock
106
106
  - LICENSE.txt
107
107
  - README.md
108
108
  - Rakefile
@@ -116,7 +116,10 @@ files:
116
116
  - lib/emmy_http/request/timeouts.rb
117
117
  - lib/emmy_http/response.rb
118
118
  - lib/emmy_http/server/options.rb
119
+ - lib/emmy_http/timeout.rb
119
120
  - lib/emmy_http/version.rb
121
+ - pkg/emmy-http-0.1.0.gem
122
+ - pkg/emmy-http-0.1.1.gem
120
123
  - spec/emmy_http_spec.rb
121
124
  - spec/spec_helper.rb
122
125
  homepage: ''
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log