mirage 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
@@ -11,7 +11,7 @@ Feature: Mirage is started from the command line.
11
11
 
12
12
 
13
13
  Scenario: Starting with help option
14
- Given I run 'mirage start --help'
14
+ Given I run 'mirage --help'
15
15
  Then the usage information should be displayed
16
16
 
17
17
 
@@ -4,18 +4,43 @@ require 'mirage'
4
4
  require 'cucumber'
5
5
  require 'rspec'
6
6
  require 'mechanize'
7
+ require 'childprocess'
8
+
9
+ ENV['RUBYOPT'] =''
7
10
 
8
11
  include Mirage::Util
9
12
  SCRATCH = './scratch'
10
13
  RUBY_CMD = RUBY_PLATFORM == 'JAVA' ? 'jruby' : 'ruby'
14
+
15
+
11
16
  BLANK_RUBYOPT_CMD = windows? ? 'set RUBYOPT=' : "export RUBYOPT=''"
12
- $log_file_marker = 0
17
+
18
+ if 'regression' == ENV['mode']
19
+ MIRAGE_CMD = windows? ? `where mirage.bat`.chomp : 'mirage'
20
+ else
21
+ MIRAGE_CMD = "#{RUBY_CMD} ../bin/mirage"
22
+ end
13
23
 
14
24
  module CommandLine
15
- def execute command
16
- command_line_output_path = "#{SCRATCH}/commandline_output.txt"
17
- system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && #{command} > #{File.basename(command_line_output_path)}"
18
- File.read(command_line_output_path)
25
+ COMAND_LINE_OUTPUT_PATH = "#{File.dirname(__FILE__)}/../../#{SCRATCH}/commandline_output.txt"
26
+ module Windows
27
+ def run command
28
+ command = "#{MIRAGE_CMD} #{command.split(' ').drop(1).join(' ')}" if command =~ /^mirage/
29
+ command = "#{command} > #{COMAND_LINE_OUTPUT_PATH}"
30
+ Dir.chdir(SCRATCH)
31
+ `#{BLANK_RUBYOPT_CMD}`
32
+ process = ChildProcess.build(*(command.split(' ')))
33
+ process.start
34
+ sleep 0.5 until process.exited?
35
+ Dir.chdir('../')
36
+ File.read(COMAND_LINE_OUTPUT_PATH)
37
+ end
38
+ end
39
+
40
+ module Linux
41
+ def run command
42
+ `#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && #{command}`
43
+ end
19
44
  end
20
45
  end
21
46
 
@@ -46,40 +71,52 @@ end
46
71
  module Regression
47
72
  include CommandLine
48
73
 
49
- def stop_mirage
50
- system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && mirage stop"
51
- end
52
-
53
- def start_mirage
54
- system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && mirage start"
55
- end
56
-
57
74
  def run command
58
75
  execute(command)
59
76
  end
60
77
  end
61
78
 
79
+ module Mirage
80
+ module Runner
81
+ include Mirage::Util
82
+
83
+ def stop_mirage
84
+ system "cd #{SCRATCH} && #{MIRAGE_CMD} stop"
85
+ end
86
+
87
+ def start_mirage
88
+ if windows?
89
+
90
+ puts "starting mirage"
91
+ Dir.chdir(SCRATCH)
92
+ process = ChildProcess.build(MIRAGE_CMD, "start")
93
+ process.start
94
+ sleep 0.5 until process.exited?
95
+ Dir.chdir '../'
96
+ puts "finished starting mirage"
97
+ else
98
+ system "cd #{SCRATCH} && #{MIRAGE_CMD} start"
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+
62
105
  module IntelliJ
63
106
  include CommandLine
64
107
  include Mirage::Util
65
108
 
66
- def stop_mirage
67
- system "cd #{SCRATCH} && #{RUBY_CMD} ../bin/mirage stop"
68
- end
69
-
70
- def start_mirage
71
- system "cd #{SCRATCH} && #{RUBY_CMD} ../bin/mirage start"
72
- end
73
-
74
109
  def run command
75
110
  execute "#{RUBY_CMD} #{command}"
76
111
  end
77
112
  end
78
113
 
79
- 'regression' == ENV['mode'] ? World(Regression) : World(IntelliJ)
80
- 'regression' == ENV['mode'] ? include(Regression) : include(IntelliJ)
114
+ include Mirage::Runner
81
115
 
82
116
  World(Web)
117
+ World(Mirage::Runner)
118
+ windows? ? World(CommandLine::Windows) : World(CommandLine::Linux)
119
+
83
120
 
84
121
 
85
122
  Before do
data/lib/mirage/web.rb CHANGED
@@ -13,16 +13,9 @@ module Mirage
13
13
  def http_get url, params={}
14
14
  uri = URI.parse(url)
15
15
  if params[:body]
16
- response = Net::HTTP.start(uri.host, uri.port) do |http|
17
- request = Net::HTTP::Get.new(uri.path)
18
- request.body=params[:body]
19
- http.request(request)
20
- end
21
-
22
- def response.code
23
- @code.to_i
16
+ response = using_mechanize do |browser|
17
+ browser.put(url, params[:body])
24
18
  end
25
-
26
19
  else
27
20
  response = using_mechanize do |browser|
28
21
  browser.get(url, params)
data/mirage.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mirage}
8
- s.version = "1.3.4"
8
+ s.version = "1.3.5"
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"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mirage
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.4
5
+ version: 1.3.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Leon Davis
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - ">="
182
182
  - !ruby/object:Gem::Version
183
- hash: 2550934964107386131
183
+ hash: -4386511618372435286
184
184
  segments:
185
185
  - 0
186
186
  version: "0"