mirage 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -12,5 +12,6 @@ group :development do
12
12
  gem 'mechanize', '1.0.0'
13
13
  gem 'gemcutter'
14
14
  gem "nokogiri", "1.4.7"
15
+ gem "waitforit", "0.0.1.pre8"
15
16
  end
16
17
 
data/HISTORY ADDED
@@ -0,0 +1,2 @@
1
+ V2.0.1/2/3 - tidying up code
2
+ V2.0.0 - Converted to restful interface
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 2.0.3
data/bin/mirage CHANGED
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
4
- require 'mirage/client'
5
3
  require 'childprocess'
4
+ ROOT_DIR = File.dirname(__FILE__)
5
+ $LOAD_PATH.unshift("#{ROOT_DIR}/../lib")
6
+ $LOAD_PATH.unshift("#{ROOT_DIR}/../server")
7
+
8
+ require 'mirage/client'
9
+ require 'waitforit'
10
+ require 'util'
11
+
12
+
6
13
  include Mirage::Util
7
14
  RUBY_CMD = RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby'
8
15
 
9
-
10
16
  def start_mirage(args)
11
17
  puts "Starting Mirage"
12
18
 
@@ -52,7 +58,7 @@ if ARGV.include?('start')
52
58
  rescue Mirage::InternalServerException => e
53
59
  puts "WARN: #{e.message}"
54
60
  end
55
-
61
+
56
62
  elsif ARGV.include?('stop')
57
63
  puts "Stopping Mirage"
58
64
  stop_mirage
@@ -1,6 +1,8 @@
1
1
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../lib")
2
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../../server")
2
3
  require 'rubygems'
3
4
  require 'mirage/client'
5
+ require 'util'
4
6
  require 'cucumber'
5
7
  require 'rspec'
6
8
  require 'mechanize'
@@ -1,8 +1,7 @@
1
1
  $LOAD_PATH.unshift "#{File.dirname(__FILE__)}"
2
2
  require 'uri'
3
3
  require 'open-uri'
4
- require 'util'
5
- require 'web'
4
+ require 'client/web'
6
5
 
7
6
  module Mirage
8
7
 
File without changes
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mirage}
8
- s.version = "2.0.2"
8
+ s.version = "2.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leon Davis"]
12
- s.date = %q{2011-08-14}
12
+ s.date = %q{2011-08-21}
13
13
  s.default_executable = %q{mirage}
14
14
  s.description = %q{Mirage aids testing of your applications by hosting mock responses so that your applications do not have to talk to real endpoints. Its accessible via HTTP and has a RESTful interface.}
15
15
  s.executables = ["mirage"]
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".rvmrc",
21
21
  "Gemfile",
22
+ "HISTORY",
22
23
  "README.md",
23
24
  "VERSION",
24
25
  "bin/mirage",
@@ -46,15 +47,14 @@ Gem::Specification.new do |s|
46
47
  "features/support/env.rb",
47
48
  "full_build.sh",
48
49
  "lib/mirage/client.rb",
49
- "lib/mirage/mock_response.rb",
50
- "lib/mirage/mock_responses_collection.rb",
51
- "lib/mirage/object.rb",
52
- "lib/mirage/util.rb",
53
- "lib/mirage/web.rb",
50
+ "lib/mirage/client/web.rb",
54
51
  "mirage.gemspec",
55
52
  "mirage_server.rb",
56
53
  "rakefile",
57
- "test.rb",
54
+ "server/extensions/object.rb",
55
+ "server/mock_response.rb",
56
+ "server/mock_responses.rb",
57
+ "server/util.rb",
58
58
  "views/index.erb"
59
59
  ]
60
60
  s.homepage = %q{https://github.com/lashd/mirage}
@@ -88,6 +88,7 @@ For more information go to: https://github.com/lashd/mirage/wiki
88
88
  s.add_development_dependency(%q<mechanize>, ["= 1.0.0"])
89
89
  s.add_development_dependency(%q<gemcutter>, [">= 0"])
90
90
  s.add_development_dependency(%q<nokogiri>, ["= 1.4.7"])
91
+ s.add_development_dependency(%q<waitforit>, ["= 0.0.1.pre8"])
91
92
  else
92
93
  s.add_dependency(%q<sinatra>, [">= 0"])
93
94
  s.add_dependency(%q<childprocess>, ["~> 0.1"])
@@ -99,6 +100,7 @@ For more information go to: https://github.com/lashd/mirage/wiki
99
100
  s.add_dependency(%q<mechanize>, ["= 1.0.0"])
100
101
  s.add_dependency(%q<gemcutter>, [">= 0"])
101
102
  s.add_dependency(%q<nokogiri>, ["= 1.4.7"])
103
+ s.add_dependency(%q<waitforit>, ["= 0.0.1.pre8"])
102
104
  end
103
105
  else
104
106
  s.add_dependency(%q<sinatra>, [">= 0"])
@@ -111,6 +113,7 @@ For more information go to: https://github.com/lashd/mirage/wiki
111
113
  s.add_dependency(%q<mechanize>, ["= 1.0.0"])
112
114
  s.add_dependency(%q<gemcutter>, [">= 0"])
113
115
  s.add_dependency(%q<nokogiri>, ["= 1.4.7"])
116
+ s.add_dependency(%q<waitforit>, ["= 0.0.1.pre8"])
114
117
  end
115
118
  end
116
119
 
@@ -1,21 +1,24 @@
1
1
  require 'rubygems'
2
2
  $0='Mirage Server'
3
3
  ROOT_DIR = File.dirname(__FILE__)
4
- $LOAD_PATH.unshift("#{ROOT_DIR}/lib/mirage")
4
+ $LOAD_PATH.unshift("#{ROOT_DIR}/lib")
5
+ $LOAD_PATH.unshift("#{ROOT_DIR}/server")
5
6
 
6
- require 'client'
7
7
  require 'sinatra/base'
8
- require 'object'
8
+
9
+ require 'extensions/object'
9
10
  require 'mock_response'
10
- require 'mock_responses_collection'
11
+ require 'mock_responses'
12
+ require 'util'
13
+
14
+ require 'mirage/client'
11
15
 
12
16
  include Mirage::Util
13
-
14
17
 
15
18
  module Mirage
16
19
 
17
20
  class Server < Sinatra::Base
18
-
21
+
19
22
  configure do
20
23
  options = parse_options(ARGV)
21
24
  set :defaults_directory, options[:defaults_directory]
@@ -58,7 +61,6 @@ module Mirage
58
61
  end
59
62
 
60
63
  delete '/mirage/templates/:id' do
61
- response_id = params[:id].to_i
62
64
  MockResponses.delete(response_id)
63
65
  REQUESTS.delete(response_id)
64
66
  end
@@ -68,7 +70,7 @@ module Mirage
68
70
  end
69
71
 
70
72
  delete '/mirage/requests/:id' do
71
- REQUESTS.delete(params[:id].to_i)
73
+ REQUESTS.delete(response_id)
72
74
  end
73
75
 
74
76
 
@@ -79,13 +81,13 @@ module Mirage
79
81
  end
80
82
 
81
83
  get '/mirage/templates/:id' do
82
- response = MockResponses.find(params[:id].to_i)
84
+ response = MockResponses.find(response_id)
83
85
  return 404 if response.is_a? Array
84
86
  send_response(response)
85
87
  end
86
88
 
87
89
  get '/mirage/requests/:id' do
88
- REQUESTS[params[:id].to_i] || 404
90
+ REQUESTS[response_id] || 404
89
91
  end
90
92
 
91
93
 
@@ -120,22 +122,24 @@ module Mirage
120
122
  #
121
123
  put '/mirage/backup' do
122
124
  MockResponses.backup
125
+ ""
123
126
  end
124
127
 
125
128
 
126
129
  put '/mirage' do
127
130
  MockResponses.revert
131
+ ""
128
132
  end
129
133
 
130
134
 
131
135
  helpers do
132
-
133
- def prime &block
134
- yield Mirage::Client.new "http://localhost:#{settings.port}/mirage"
136
+
137
+ def response_id
138
+ params[:id].to_i
135
139
  end
136
140
 
137
- def response_value
138
- return request['response'] unless request['response'].nil?
141
+ def prime &block
142
+ yield Mirage::Client.new "http://localhost:#{settings.port}/mirage"
139
143
  end
140
144
 
141
145
  def send_response(response, body='', request={}, query_string='')
File without changes
@@ -49,6 +49,7 @@ module Mirage
49
49
  end
50
50
  end
51
51
  end
52
+
52
53
  end
53
54
 
54
55
  def delete(response_id)
@@ -2,15 +2,6 @@ require 'optparse'
2
2
  module Mirage
3
3
  module Util
4
4
 
5
- def wait_until time=45
6
- start_time = Time.now
7
- until Time.now >= start_time + time
8
- sleep 0.1
9
- return if yield
10
- end
11
- raise 'timeout waiting'
12
- end
13
-
14
5
  def parse_options args
15
6
  options = {:port => 7001, :defaults_directory => 'responses', :root_directory => '.'}
16
7
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mirage
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.2
5
+ version: 2.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Leon Davis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-14 00:00:00 +01:00
13
+ date: 2011-08-21 00:00:00 +01:00
14
14
  default_executable: mirage
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -123,6 +123,17 @@ dependencies:
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: waitforit
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - "="
132
+ - !ruby/object:Gem::Version
133
+ version: 0.0.1.pre8
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: *id011
126
137
  description: Mirage aids testing of your applications by hosting mock responses so that your applications do not have to talk to real endpoints. Its accessible via HTTP and has a RESTful interface.
127
138
  email:
128
139
  executables:
@@ -134,6 +145,7 @@ extra_rdoc_files:
134
145
  files:
135
146
  - .rvmrc
136
147
  - Gemfile
148
+ - HISTORY
137
149
  - README.md
138
150
  - VERSION
139
151
  - bin/mirage
@@ -161,15 +173,14 @@ files:
161
173
  - features/support/env.rb
162
174
  - full_build.sh
163
175
  - lib/mirage/client.rb
164
- - lib/mirage/mock_response.rb
165
- - lib/mirage/mock_responses_collection.rb
166
- - lib/mirage/object.rb
167
- - lib/mirage/util.rb
168
- - lib/mirage/web.rb
176
+ - lib/mirage/client/web.rb
169
177
  - mirage.gemspec
170
178
  - mirage_server.rb
171
179
  - rakefile
172
- - test.rb
180
+ - server/extensions/object.rb
181
+ - server/mock_response.rb
182
+ - server/mock_responses.rb
183
+ - server/util.rb
173
184
  - views/index.erb
174
185
  has_rdoc: true
175
186
  homepage: https://github.com/lashd/mirage
@@ -191,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
202
  requirements:
192
203
  - - ">="
193
204
  - !ruby/object:Gem::Version
194
- hash: -2214189456461539388
205
+ hash: 2910117652361580997
195
206
  segments:
196
207
  - 0
197
208
  version: "0"
data/test.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'rubygems'
2
- require 'mirage/client'
3
-
4
-
5
- client = Mirage::Client.new
6
- client.put('greeting', 'hello')
7
- client.save
8
- client.put('leaving', 'goodbye')
9
-