harper 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -2
- data/bin/harper +37 -4
- data/harper.gemspec +1 -0
- data/lib/harper/client.rb +36 -0
- data/lib/harper/version.rb +1 -1
- metadata +30 -18
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
harper (0.0.
|
4
|
+
harper (0.0.4)
|
5
5
|
httparty
|
6
6
|
json (>= 1.4.6)
|
7
7
|
sinatra (>= 1.0.0)
|
8
|
+
trollop
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: http://rubygems.org/
|
@@ -27,7 +28,7 @@ GEM
|
|
27
28
|
multi_json
|
28
29
|
multi_xml
|
29
30
|
json (1.6.5)
|
30
|
-
multi_json (1.0
|
31
|
+
multi_json (1.1.0)
|
31
32
|
multi_xml (0.4.1)
|
32
33
|
rack (1.4.1)
|
33
34
|
rack-protection (1.2.0)
|
@@ -54,6 +55,7 @@ GEM
|
|
54
55
|
highline (>= 1.4.0)
|
55
56
|
term-ansicolor (1.0.7)
|
56
57
|
tilt (1.3.3)
|
58
|
+
trollop (1.16.2)
|
57
59
|
|
58
60
|
PLATFORMS
|
59
61
|
ruby
|
data/bin/harper
CHANGED
@@ -1,11 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "harper"
|
4
|
+
require "trollop"
|
5
|
+
require "open3"
|
4
6
|
|
5
|
-
|
7
|
+
opts = Trollop::options do
|
8
|
+
opt :port, "The port to run Harper on", :default => 4567
|
9
|
+
opt :bg, "Run in the background", :default => false
|
10
|
+
end
|
11
|
+
|
12
|
+
def start(port)
|
13
|
+
server = Rack::Server.new :app => Harper::App, :Port => port, :server => 'webrick'
|
14
|
+
Harper::App.server(server.server)
|
15
|
+
server.start
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_in_background(port)
|
19
|
+
read, write = IO.pipe
|
20
|
+
|
21
|
+
fork do
|
22
|
+
read.close
|
23
|
+
Open3.popen2({}, "harper --port #{port}", {:err => [:child, :out]}) do |i, o|
|
24
|
+
found_start = false
|
25
|
+
while !found_start && line = o.readline
|
26
|
+
if line =~ /WEBrick::HTTPServer#start/
|
27
|
+
write.puts "Harper started"
|
28
|
+
found_start = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
write.close
|
35
|
+
read.readline
|
36
|
+
end
|
6
37
|
|
7
38
|
# Harper needs access to the server hosting itself so that it can shut
|
8
39
|
# it down on demand
|
9
|
-
|
10
|
-
|
11
|
-
|
40
|
+
if opts[:bg]
|
41
|
+
start_in_background(opts[:port])
|
42
|
+
else
|
43
|
+
start(opts[:port])
|
44
|
+
end
|
data/harper.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency "sinatra", ">= 1.0.0"
|
20
20
|
s.add_dependency "httparty"
|
21
21
|
s.add_dependency "json", ">= 1.4.6"
|
22
|
+
s.add_dependency "trollop"
|
22
23
|
|
23
24
|
s.add_development_dependency "rack-test"
|
24
25
|
s.add_development_dependency "sham_rack"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class HarperClient
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
base_uri "localhost:4568"
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@started = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def started?
|
14
|
+
@started
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
system("harper --port 4568 --bg")
|
19
|
+
@started = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
self.class.put "/h/control", :body => {:command => "quit"}.to_json
|
24
|
+
@started = false
|
25
|
+
end
|
26
|
+
|
27
|
+
def mock(mock)
|
28
|
+
mock_body = case mock
|
29
|
+
when String
|
30
|
+
mock
|
31
|
+
else
|
32
|
+
mock.to_json
|
33
|
+
end
|
34
|
+
self.class.post "/h/mocks", :body => mock_body
|
35
|
+
end
|
36
|
+
end
|
data/lib/harper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70306501088500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70306501088500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &70306501087560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70306501087560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70306501086480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,21 @@ dependencies:
|
|
43
43
|
version: 1.4.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70306501086480
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: trollop
|
49
|
+
requirement: &70306501085640 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70306501085640
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rack-test
|
49
|
-
requirement: &
|
60
|
+
requirement: &70306501084920 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: '0'
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70306501084920
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: sham_rack
|
60
|
-
requirement: &
|
71
|
+
requirement: &70306501084320 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70306501084320
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: rspec
|
71
|
-
requirement: &
|
82
|
+
requirement: &70306501083780 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: '0'
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70306501083780
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: cucumber
|
82
|
-
requirement: &
|
93
|
+
requirement: &70306501083040 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,10 +98,10 @@ dependencies:
|
|
87
98
|
version: '0.10'
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70306501083040
|
91
102
|
- !ruby/object:Gem::Dependency
|
92
103
|
name: cucumber-sinatra
|
93
|
-
requirement: &
|
104
|
+
requirement: &70306501075940 !ruby/object:Gem::Requirement
|
94
105
|
none: false
|
95
106
|
requirements:
|
96
107
|
- - ! '>='
|
@@ -98,7 +109,7 @@ dependencies:
|
|
98
109
|
version: '0'
|
99
110
|
type: :development
|
100
111
|
prerelease: false
|
101
|
-
version_requirements: *
|
112
|
+
version_requirements: *70306501075940
|
102
113
|
description: Dead simple mocking for HTTP services, a Sinatra app
|
103
114
|
email:
|
104
115
|
- giles.alexander@gmail.com
|
@@ -123,6 +134,7 @@ files:
|
|
123
134
|
- harper.gemspec
|
124
135
|
- lib/harper.rb
|
125
136
|
- lib/harper/app.rb
|
137
|
+
- lib/harper/client.rb
|
126
138
|
- lib/harper/version.rb
|
127
139
|
- spec/harper_spec.rb
|
128
140
|
- spec/spec_helper.rb
|