mudbug 0.9.0.1 → 1.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/Rakefile +13 -7
- data/VERSION +1 -1
- data/lib/mudbug.rb +1 -0
- data/mudbug.gemspec +4 -4
- data/test/mudbug.rb +80 -4
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc9de28ee1cc2bc7a3c6ed987a0b1e46d82083b
|
4
|
+
data.tar.gz: 288369cc57db114694c55156fe3e766c888214a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4d0afeee4edec6d8e410affad2042d59e9b775919c65d1a26dc90b205c64656380b7234274c20b30cdddb6bc082c3ac1e045e4b7016c8727d7b4c38c2dfbae7
|
7
|
+
data.tar.gz: dd5ffd9024ea0d7372a57c513d904b349033443716618c37650a21ff5ee7651801c493043163c701e12fcff23422e748f54a880c8ca339dd1a68a78654472144
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/rickhull/mudbug.svg?branch=master)](https://travis-ci.org/rickhull/conway_deathmatch)
|
1
2
|
[![Gem Version](https://badge.fury.io/rb/mudbug.svg)](http://badge.fury.io/rb/mudbug)
|
2
3
|
[![Code Climate](https://codeclimate.com/github/rickhull/mudbug/badges/gpa.svg)](https://codeclimate.com/github/rickhull/mudbug)
|
3
4
|
[![Dependency Status](https://gemnasium.com/rickhull/mudbug.svg)](https://gemnasium.com/rickhull/mudbug)
|
4
|
-
[![Security Status](https://hakiri.io/github/rickhull/mudbug/master.svg)](https://hakiri.io/github/rickhull/mudbug/master)
|
5
|
+
[![Security Status](https://hakiri.io/github/rickhull/mudbug/master.svg?cachebuster)](https://hakiri.io/github/rickhull/mudbug/master)
|
5
6
|
|
6
7
|
Mudbug
|
7
8
|
=======
|
data/Rakefile
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
require 'buildar'
|
2
1
|
require 'rake/testtask'
|
3
2
|
|
4
|
-
Buildar.new do |b|
|
5
|
-
b.gemspec_file = 'mudbug.gemspec'
|
6
|
-
b.version_file = 'VERSION'
|
7
|
-
b.use_git = true
|
8
|
-
end
|
9
|
-
|
10
3
|
Rake::TestTask.new :test do |t|
|
11
4
|
t.pattern = 'test/*.rb'
|
12
5
|
end
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'buildar'
|
11
|
+
Buildar.new do |b|
|
12
|
+
b.gemspec_file = 'mudbug.gemspec'
|
13
|
+
b.version_file = 'VERSION'
|
14
|
+
b.use_git = true
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
warn "buildar tasks not available"
|
18
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0.1
|
data/lib/mudbug.rb
CHANGED
data/mudbug.gemspec
CHANGED
@@ -9,17 +9,17 @@ Gem::Specification.new do |s|
|
|
9
9
|
|
10
10
|
s.executables << 'mb'
|
11
11
|
|
12
|
-
s.add_runtime_dependency "rest-client", "~>
|
12
|
+
s.add_runtime_dependency "rest-client", "~> 2.0"
|
13
13
|
s.add_runtime_dependency "json", ">= 1.7.7"
|
14
14
|
s.add_runtime_dependency "lager", "~> 1"
|
15
15
|
s.add_runtime_dependency "dotcfg", "~> 0.2"
|
16
16
|
s.add_development_dependency "minitest", "~> 5.0"
|
17
17
|
s.add_development_dependency "buildar", "~> 3.0"
|
18
18
|
|
19
|
+
s.required_ruby_version = "~> 2"
|
20
|
+
|
19
21
|
# set version dynamically from version file contents
|
20
|
-
|
21
|
-
version_file = File.join(this_dir, 'VERSION')
|
22
|
-
s.version = File.read(version_file).chomp
|
22
|
+
s.version = File.read(File.join(__dir__, 'VERSION')).chomp
|
23
23
|
|
24
24
|
s.files = %w[
|
25
25
|
mudbug.gemspec
|
data/test/mudbug.rb
CHANGED
@@ -1,9 +1,85 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
|
3
|
-
# require_relative '../lib/mudbug'
|
2
|
+
require 'mudbug'
|
4
3
|
|
5
4
|
describe "Mudbug" do
|
6
|
-
|
7
|
-
|
5
|
+
describe "accept_header" do
|
6
|
+
it "must generate valid headers" do
|
7
|
+
h = Mudbug.accept_header(:json, :xml, :html, :text, :foo)
|
8
|
+
ary = h.split(', ')
|
9
|
+
ary.length.must_equal 5
|
10
|
+
|
11
|
+
# first entry does not have a qspec
|
12
|
+
ary[0].must_equal 'application/json'
|
13
|
+
|
14
|
+
# subsequent entries must have a qspec
|
15
|
+
qspec = /q=\d*\.*\d/ # e.g. q=0.5
|
16
|
+
|
17
|
+
xml_ary = ary[1].split(';')
|
18
|
+
xml_ary[0].must_equal 'application/xml'
|
19
|
+
xml_ary[1].must_match qspec
|
20
|
+
|
21
|
+
html_ary = ary[2].split(';')
|
22
|
+
html_ary[0].must_equal 'text/html'
|
23
|
+
html_ary[1].must_match qspec
|
24
|
+
|
25
|
+
text_ary = ary[3].split(';')
|
26
|
+
text_ary[0].must_equal 'text/plain'
|
27
|
+
text_ary[1].must_match qspec
|
28
|
+
|
29
|
+
foo_ary = ary[4].split(';')
|
30
|
+
foo_ary[0].must_equal 'application/foo'
|
31
|
+
foo_ary[1].must_match qspec
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "process" do
|
36
|
+
def http_response(body, opts = {})
|
37
|
+
opts[:http_ver] ||= 1.1
|
38
|
+
opts[:status_code] ||= '200 OK'
|
39
|
+
opts[:conn] ||= 'close'
|
40
|
+
headers = ["HTTP/#{opts[:http_ver]} #{opts[:status_code]}",
|
41
|
+
"Content-Length: #{body.length}",
|
42
|
+
"Connection: #{opts[:conn]}"]
|
43
|
+
headers << "Content-type: #{opts[:content_type]}" if opts[:content_type]
|
44
|
+
[headers, '', '', body].join("\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def dummy_io(str)
|
48
|
+
Net::BufferedIO.new(StringIO.new(str.gsub("\n", "\r\n")))
|
49
|
+
end
|
50
|
+
|
51
|
+
def net_http_resp(body, opts = {})
|
52
|
+
Net::HTTPResponse.read_new(dummy_io(http_response(body, opts)))
|
53
|
+
end
|
54
|
+
|
55
|
+
def rest_client_resp(body, opts = {})
|
56
|
+
req = RestClient::Request.new(method: 'get', url: 'http://google.com/')
|
57
|
+
RestClient::Response.create(body, net_http_resp(body, opts), req)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "must process an empty response" do
|
61
|
+
empty_resp = rest_client_resp('', content_type: 'text/html')
|
62
|
+
body = Mudbug.process(empty_resp)
|
63
|
+
body.wont_be_nil
|
64
|
+
body.must_be_empty
|
65
|
+
end
|
66
|
+
|
67
|
+
it "must process a nonempty response" do
|
68
|
+
resp_body = 'foo: bar'
|
69
|
+
resp = rest_client_resp(resp_body, content_type: 'text/html')
|
70
|
+
body = Mudbug.process(resp)
|
71
|
+
body.wont_be_nil
|
72
|
+
body.wont_be_empty
|
73
|
+
body.must_equal resp_body
|
74
|
+
end
|
75
|
+
|
76
|
+
it "must warn about missing content-type" do
|
77
|
+
resp = rest_client_resp('')
|
78
|
+
out, err = capture_subprocess_io do
|
79
|
+
Mudbug.process(resp)
|
80
|
+
end
|
81
|
+
out.must_be_empty
|
82
|
+
err.wont_be_empty
|
83
|
+
end
|
8
84
|
end
|
9
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mudbug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Hull
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.8.0
|
19
|
+
version: '2.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.8.0
|
26
|
+
version: '2.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: json
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,9 +121,9 @@ require_paths:
|
|
127
121
|
- lib
|
128
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
123
|
requirements:
|
130
|
-
- - "
|
124
|
+
- - "~>"
|
131
125
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
126
|
+
version: '2'
|
133
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - ">="
|