tinternet 0.0.4 → 0.4.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZThjYzEzMDQ4NjVhYzE0ZDZlMzA3NjA5NDc2YzcyMDA2MTViNDZkOQ==
4
+ NDJlZjE5OGNkMGE0OTgyYzI4YTQ1YWZiYzdkZmRmMDE2NzdkMmU0ZA==
5
5
  data.tar.gz: !binary |-
6
- NTAzYzRiY2E2MGI2YTAyZGQxNDQ5NTRmNDg5Y2ZlNzgwYmUyMmVjYQ==
6
+ YjQ4ZTRjN2JkMTA2YmY0YWNhYzk4OGVhNzEzM2JlNjNjMGI1NDg1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzEyYzFlNDAxYjkzYjk3N2UzOTQ4ZTliOTZiNWUyMGVhYWI0ZWI1MTQ5YmRm
10
- ZTc1MmM0ZGU1NmI4NGUwODI0MzJhNjNkZDg2ZmY4MjMzNTg4MzM5M2M2N2Fm
11
- OWZmMTQ3MTQxZWNkZGFlODk3NTU4ZTZlZjRmYzMxMTkwNDMyZjA=
9
+ ZmFkMzE1NzVkNTBjZGMyMTBiMWNiMzRjZTUzMjZkN2YzYTNhNDE1YTY3ZjQ5
10
+ MTNkMDMyZGIwODUyYzI0ZDJjOTE1Yjg0OWZjNWJlNmQxNjc4MmVkMGE0NWVh
11
+ NTc4MjIzZDIxOThjNDMyYTQ0YmMyODhhZjdkY2E0OTFmYzMwZjE=
12
12
  data.tar.gz: !binary |-
13
- MmRjZmJlMDhlNzBhNDBhZTVkYTVkMzY5Y2M4MzIwMjIzN2IwZjFiZGQzNmYx
14
- OTAyODBkN2ZkNDliMjUyMDM1YTQ2NTIzZmU3ZWJiMGQ1Y2I2OTUxYTk0MTI0
15
- Y2UyOGMzMWMyZTBmZDY0NjU1NDk4MjkyMGU1MGZlYTc4YzViNGY=
13
+ MmYyZjc1NzBlZTIxODcxZDU2MDA4NzQ3M2VkNmExMGJkOTUyMjRmYmExYmJl
14
+ N2FiOTc1MzVkYzY0NDU3ZWYxY2UyMjIyMGIyYjZkMTEzOGM5NWFjOGRiNzk4
15
+ ZjQwYTQyNDYwMmFhZGEyMmU5Y2E2OGJiNjA3ZDkxNWU1N2M0YjE=
@@ -1,72 +1,72 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- addressable (2.3.5)
5
- audible (0.1.0)
6
- builder (3.2.2)
7
- diff-lcs (1.2.5)
8
- faraday (0.8.8)
9
- multipart-post (~> 1.2.0)
10
- git (1.2.6)
11
- github_api (0.10.1)
12
- addressable
13
- faraday (~> 0.8.1)
14
- hashie (>= 1.2)
15
- multi_json (~> 1.4)
16
- nokogiri (~> 1.5.2)
17
- oauth2
18
- hashie (2.0.5)
19
- highline (1.6.20)
20
- httpauth (0.2.0)
21
- jeweler (1.8.8)
22
- builder
23
- bundler (~> 1.0)
24
- git (>= 1.2.5)
25
- github_api (= 0.10.1)
26
- highline (>= 1.6.15)
27
- nokogiri (= 1.5.10)
28
- rake
29
- rdoc
30
- json (1.8.1)
31
- jwt (0.1.8)
32
- multi_json (>= 1.5)
33
- mime-types (2.0)
34
- multi_json (1.8.2)
35
- multi_xml (0.5.5)
36
- multipart-post (1.2.0)
37
- nokogiri (1.5.10)
38
- nokogiri (1.5.10-x86-mingw32)
39
- oauth2 (0.9.2)
40
- faraday (~> 0.8)
41
- httpauth (~> 0.2)
42
- jwt (~> 0.1.4)
43
- multi_json (~> 1.0)
44
- multi_xml (~> 0.5)
45
- rack (~> 1.2)
46
- rack (1.5.2)
47
- rake (10.1.0)
48
- rdoc (4.0.1)
49
- json (~> 1.4)
50
- rest-client (1.6.7)
51
- mime-types (>= 1.16)
52
- rsettings (0.4.0)
53
- audible
54
- rspec (2.14.1)
55
- rspec-core (~> 2.14.0)
56
- rspec-expectations (~> 2.14.0)
57
- rspec-mocks (~> 2.14.0)
58
- rspec-core (2.14.7)
59
- rspec-expectations (2.14.4)
60
- diff-lcs (>= 1.1.3, < 2.0)
61
- rspec-mocks (2.14.4)
62
-
63
- PLATFORMS
64
- x86-mingw32
65
-
66
- DEPENDENCIES
67
- audible
68
- bundler (~> 1.0)
69
- jeweler (~> 1.8.7)
70
- rest-client
71
- rsettings
72
- rspec
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ audible (0.1.0)
6
+ builder (3.2.2)
7
+ diff-lcs (1.2.5)
8
+ faraday (0.8.8)
9
+ multipart-post (~> 1.2.0)
10
+ git (1.2.6)
11
+ github_api (0.10.1)
12
+ addressable
13
+ faraday (~> 0.8.1)
14
+ hashie (>= 1.2)
15
+ multi_json (~> 1.4)
16
+ nokogiri (~> 1.5.2)
17
+ oauth2
18
+ hashie (2.0.5)
19
+ highline (1.6.20)
20
+ httpauth (0.2.0)
21
+ jeweler (1.8.8)
22
+ builder
23
+ bundler (~> 1.0)
24
+ git (>= 1.2.5)
25
+ github_api (= 0.10.1)
26
+ highline (>= 1.6.15)
27
+ nokogiri (= 1.5.10)
28
+ rake
29
+ rdoc
30
+ json (1.8.1)
31
+ jwt (0.1.8)
32
+ multi_json (>= 1.5)
33
+ mime-types (2.0)
34
+ multi_json (1.8.2)
35
+ multi_xml (0.5.5)
36
+ multipart-post (1.2.0)
37
+ nokogiri (1.5.10)
38
+ nokogiri (1.5.10-x86-mingw32)
39
+ oauth2 (0.9.2)
40
+ faraday (~> 0.8)
41
+ httpauth (~> 0.2)
42
+ jwt (~> 0.1.4)
43
+ multi_json (~> 1.0)
44
+ multi_xml (~> 0.5)
45
+ rack (~> 1.2)
46
+ rack (1.5.2)
47
+ rake (10.1.0)
48
+ rdoc (4.0.1)
49
+ json (~> 1.4)
50
+ rest-client (1.6.7)
51
+ mime-types (>= 1.16)
52
+ rsettings (0.4.0)
53
+ audible
54
+ rspec (2.14.1)
55
+ rspec-core (~> 2.14.0)
56
+ rspec-expectations (~> 2.14.0)
57
+ rspec-mocks (~> 2.14.0)
58
+ rspec-core (2.14.7)
59
+ rspec-expectations (2.14.4)
60
+ diff-lcs (>= 1.1.3, < 2.0)
61
+ rspec-mocks (2.14.4)
62
+
63
+ PLATFORMS
64
+ x86-mingw32
65
+
66
+ DEPENDENCIES
67
+ audible
68
+ bundler (~> 1.0)
69
+ jeweler (~> 1.8.7)
70
+ rest-client
71
+ rsettings
72
+ rspec
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
- = t
1
+ # TInternet
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ben-biddington/tinternet.png)](http://travis-ci.org/ben-biddington/tinternet)
2
4
 
3
5
  The internet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.4.0
@@ -1,10 +1,23 @@
1
+ class RestClientObserver
2
+ require 'audible'; extend Audible
3
+ require 'restclient'
4
+ RestClient.log = self
5
+
6
+ class << self
7
+ def <<(message)
8
+ notify :progress, message
9
+ end
10
+ end
11
+ end
12
+
1
13
  class RestClientInternet
2
14
  require "rest_client"
3
- require "audible"; include Audible
4
-
15
+ require "audible"; include Audible; extend Audible
16
+
5
17
  def initialize(opts ={})
6
18
  @ssl_client_cert = opts[:ssl_client_cert]
7
19
  @proxy = opts[:proxy]
20
+ RestClientObserver.on(:progress) {|e,args| notify :progress, args.first}
8
21
  end
9
22
 
10
23
  def execute(request); try_execute request; end
@@ -43,11 +56,12 @@ class RestClientInternet
43
56
 
44
57
  def opts_for(request)
45
58
  {
46
- :method => request.verb,
47
- :url => request.uri.to_s,
48
- :headers => request.headers,
49
- :payload => request.body,
50
- :timeout => request_timeout_in_seconds
59
+ :method => request.verb,
60
+ :url => request.uri.to_s,
61
+ :headers => request.headers,
62
+ :payload => request.body ? request.body.to_hash : nil,
63
+ :timeout => request_timeout_in_seconds,
64
+ :multipart => request.body && request.body.respond_to?(:files)
51
65
  }.merge ssl_opts
52
66
  end
53
67
 
@@ -0,0 +1,12 @@
1
+ module T
2
+ class MultipartFormData # https://www.ietf.org/rfc/rfc2388.txt
3
+ attr_reader :fields, :files
4
+
5
+ def initialize(fields={}, files={})
6
+ @fields = fields
7
+ @files = files
8
+ end
9
+
10
+ def to_hash; @fields.merge(@files); end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module T
2
+ class XWwwFormUrlencoded # https://www.ietf.org/rfc/rfc2388.txt
3
+ attr_reader :fields
4
+
5
+ def initialize(fields={})
6
+ @fields = fields
7
+ end
8
+
9
+ def to_hash; @fields; end
10
+
11
+ private
12
+
13
+ def encode(what)
14
+ URI.escape(what)
15
+ end
16
+ end
17
+ end
@@ -20,7 +20,13 @@ module T
20
20
  def auth_header_name; "Authorization"; end
21
21
  end
22
22
 
23
- Response = Struct.new "Response", :code, :headers, :body
23
+ class Response
24
+ attr_reader :code, :headers, :body
25
+
26
+ def initialize(code, headers, body)
27
+ @code, @headers, @body = code, headers, body
28
+ end
29
+ end
24
30
 
25
- SslClientCertificate = Struct.new "SslClientCertificate", :cert, :key, :verify_ssl
31
+ T::SslClientCertificate = Struct.new "SslClientCertificate", :cert, :key, :verify_ssl
26
32
  end
@@ -13,6 +13,10 @@ describe "The basics" do
13
13
  it.on :requesting do |e,args|
14
14
  puts "Requesting <#{args.first.uri}>"
15
15
  end
16
+
17
+ it.on :progress do |e,args|
18
+ puts "#{e} -- #{args}"
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -25,4 +29,25 @@ describe "The basics" do
25
29
  it "fails when host cannot be found" do
26
30
  expect{internet.execute(T::Request.new :uri => "http://a.com/")}.to raise_error SocketError
27
31
  end
32
+
33
+ it "can <application/x-www-form-urlencoded> post" do
34
+ reply = internet.execute T::Request.new(
35
+ :uri => "http://www.hashemian.com/tools/form-post-tester.php",
36
+ :verb => :post,
37
+ :body => T::XWwwFormUrlencoded.new("name" => "Ben")
38
+ )
39
+
40
+ expect(reply.code).to eql 200
41
+ expect(reply.body).to match /name=Ben/
42
+ end
43
+
44
+ it "can <multipart> post" do
45
+ reply = internet.execute T::Request.new(
46
+ :uri => "http://www.hashemian.com/tools/form-post-tester.php",
47
+ :verb => :post,
48
+ :body => T::MultipartFormData.new({"name" => "Ben"}, {"README" => File.new("README.md", 'rb')})
49
+ )
50
+
51
+ expect(reply.code).to eql 200
52
+ end
28
53
  end
@@ -2,15 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: tinternet 0.0.4 ruby lib
5
+ # stub: tinternet 0.4.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tinternet"
9
- s.version = "0.0.4"
9
+ s.version = "0.4.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
12
13
  s.authors = ["Ben Biddington"]
13
- s.date = "2013-12-20"
14
+ s.date = "2015-01-27"
14
15
  s.description = "The internet"
15
16
  s.email = "ben.biddington@xero.com"
16
17
  s.extra_rdoc_files = [
@@ -29,6 +30,8 @@ Gem::Specification.new do |s|
29
30
  "lib/t.rb",
30
31
  "lib/tinternet/adapters/rest_client_internet.rb",
31
32
  "lib/tinternet/internet.rb",
33
+ "lib/tinternet/payload/multipart_form_data.rb",
34
+ "lib/tinternet/payload/www_form_url_encoded.rb",
32
35
  "lib/tinternet/request.rb",
33
36
  "spec/spec_helper.rb",
34
37
  "spec/system.tests/introduction_spec.rb",
@@ -36,8 +39,7 @@ Gem::Specification.new do |s|
36
39
  ]
37
40
  s.homepage = "http://github.com/ben-biddington/tinternet"
38
41
  s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "2.1.11"
42
+ s.rubygems_version = "2.4.5"
41
43
  s.summary = "The internet"
42
44
 
43
45
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinternet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: !binary |-
5
+ MC40LjA=
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ben Biddington
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
12
+ date: 2015-01-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rest-client
@@ -117,6 +118,8 @@ files:
117
118
  - lib/t.rb
118
119
  - lib/tinternet/adapters/rest_client_internet.rb
119
120
  - lib/tinternet/internet.rb
121
+ - lib/tinternet/payload/multipart_form_data.rb
122
+ - lib/tinternet/payload/www_form_url_encoded.rb
120
123
  - lib/tinternet/request.rb
121
124
  - spec/spec_helper.rb
122
125
  - spec/system.tests/introduction_spec.rb
@@ -141,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
144
  version: '0'
142
145
  requirements: []
143
146
  rubyforge_project:
144
- rubygems_version: 2.1.11
147
+ rubygems_version: 2.4.5
145
148
  signing_key:
146
149
  specification_version: 4
147
150
  summary: The internet