oop_rails_server 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d59483bdfe97f34e39632230300cf37f6e95737
4
- data.tar.gz: 0b36b1482eec1a6ce5d637bd203bc253bb701257
3
+ metadata.gz: f1893e258310ea8d845e3556e11d4b58b0fc6a68
4
+ data.tar.gz: 9cffe310681d48ba02a1a96c75397afd679f7dd5
5
5
  SHA512:
6
- metadata.gz: 08ad2cadd68042cb72cdac8e99c4b6ae175664ab3ed2f70df16d7427d47b5c903bb40eaefe9cfcc57b9e43d368404f9cbd60a0661b2fcf038ed7bfe93a19d88b
7
- data.tar.gz: dcfa773fad0e8e3f44f9c60549aecc8b4a7789fa56461974f25d8b0c0398910e962a67976d77e7a424191f7dca0cae699a74e122da27d5d121d6291e9ec3e3ff
6
+ metadata.gz: 023a271744abaab2104181a7d052c9aeccd1ba9ce29cb87223790536091fcd02c605ab995fb4533975ff9cacd49d143d20e0c5f6e70f15dc10f33b67c69495e9
7
+ data.tar.gz: 88bfe8d4e47bc66062a6f25ed76c82dba2e5b410cbd13698e2b1352895e61423a1bd564fe0ea1a4a7654ac496545c317db054bd026044a1bad0f9ea987e9ad7e
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # `oop_rails_server` Releases
2
2
 
3
+ ## 0.0.23, 18 October 2016
4
+
5
+ * Allow for POSTs, not just GETs, on the server.
6
+
3
7
  ## 0.0.22, 27 September 2016
4
8
 
5
9
  * Fixed a bug caused by trying to call `Exception#cause` without checking if it exists; this doesn't exist in older
@@ -70,6 +70,10 @@ module OopRailsServer
70
70
  stop_server! if server_pid
71
71
  end
72
72
 
73
+ def post(path_or_uri, options = { })
74
+ send_http_request(path_or_uri, options.merge(:http_method => :post))
75
+ end
76
+
73
77
  def get(path_or_uri, options = { })
74
78
  out = get_response(path_or_uri, options)
75
79
  out.body.strip if out
@@ -93,14 +97,23 @@ module OopRailsServer
93
97
  "127.0.0.1"
94
98
  end
95
99
 
96
- def get_response(path_or_uri, options = { })
97
- options.assert_valid_keys(:ignore_status_code, :nil_on_not_found, :query, :no_layout, :accept_header)
100
+ def send_http_request(path_or_uri, options = { })
101
+ options.assert_valid_keys(:ignore_status_code, :nil_on_not_found, :query, :no_layout, :accept_header, :http_method, :post_variables)
98
102
 
99
103
  uri = uri_for(path_or_uri, options[:query])
100
104
  data = nil
101
105
  accept_header = options.fetch(:accept_header, 'text/html')
106
+
107
+ http_method = options[:http_method] || :get
108
+
102
109
  Net::HTTP.start(uri.host, uri.port) do |http|
103
- request = Net::HTTP::Get.new(uri.to_s)
110
+ klass = Net::HTTP.const_get(http_method.to_s.strip.camelize)
111
+ request = klass.new(uri.to_s)
112
+
113
+ if options[:post_variables]
114
+ request.set_form_data(options[:post_variables])
115
+ end
116
+
104
117
  request['Accept'] = accept_header if accept_header
105
118
  data = http.request(request)
106
119
  end
@@ -117,6 +130,10 @@ module OopRailsServer
117
130
  data
118
131
  end
119
132
 
133
+ def get_response(path_or_uri, options = { })
134
+ send_http_request(path_or_uri, options.merge(:http_method => :get))
135
+ end
136
+
120
137
  def run_command_in_rails_root!(command)
121
138
  Bundler.with_clean_env do
122
139
  with_rails_env do
@@ -382,8 +399,8 @@ The last #{last_lines.length} lines of this log are:
382
399
  raise_startup_failed_error!(Time.now - start_time, "'#{server_verify_url}' returned: #{result.inspect}")
383
400
  end
384
401
  actual_version = $1
385
- ruby_version = $2
386
- ruby_engine = $3
402
+ ruby_version = $3
403
+ ruby_engine = $4
387
404
 
388
405
  if rails_version != :default && (actual_version != rails_version)
389
406
  raise "We seem to have spawned the wrong version of Rails; wanted: #{rails_version.inspect} but got: #{actual_version.inspect}"
@@ -1,3 +1,3 @@
1
1
  module OopRailsServer
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oop_rails_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Geweke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json