ruby-quilt 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/quilt/eventmachine.rb +3 -0
  2. data/lib/quilt.rb +19 -13
  3. metadata +24 -1
@@ -0,0 +1,3 @@
1
+ require 'faraday'
2
+ Faraday.default_adapter = :em_synchrony
3
+ require 'quilt'
data/lib/quilt.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'logger'
2
2
  require 'json'
3
- require 'net/http'
4
3
  require 'popen4'
5
4
  require 'fileutils'
6
5
  require 'ecology'
6
+ require 'faraday'
7
7
  require "#{File.join(File.dirname(__FILE__), "lru_cache")}"
8
8
 
9
9
  class Quilt
@@ -230,15 +230,13 @@ class Quilt
230
230
  log_error("unable to load from host: #{@config[:remote_host]}, path: #{@config[:remote_path]}")
231
231
  return nil
232
232
  end
233
- port = @config[:remote_port] ? @config[:remote_port].to_i : 80
234
233
  # Fetch the version
235
234
  filename = "#{name}#{ARCHIVE_SUFFIX}"
236
235
  version_dir = File.join(@config[:local_path], name)
237
236
  begin
238
- res = Net::HTTP.get_response(@config[:remote_host].to_s,
239
- File.join(@config[:remote_path].to_s, filename), port)
240
- if (res.code != "200")
241
- log_error("no version fetched : #{res.code}")
237
+ res = fetch_remote(filename)
238
+ if (res.status.to_i != 200)
239
+ log_error("no version fetched : #{res.status.to_i}")
242
240
  return nil
243
241
  end
244
242
  FileUtils.mkdir(version_dir) unless File.exists?(version_dir)
@@ -339,21 +337,29 @@ class Quilt
339
337
  "#{(dynamics[position] || '')}#{resolve_dependancies(position, modules, version, {})}"
340
338
  end
341
339
 
340
+ def fetch_remote(file)
341
+ host = @config[:remote_host].to_s
342
+ port = @config[:remote_port] ? @config[:remote_port].to_i : 80
343
+ path = File.join(@config[:remote_path].to_s, file)
344
+ conn = Faraday.new(:url => "http://#{host}:#{port}") do |faraday|
345
+ faraday.adapter Faraday.default_adapter
346
+ end
347
+ conn.get(path)
348
+ end
349
+
342
350
  def health
343
351
  # return true if no remote info
344
352
  return [true, nil, nil] if !@config[:remote_host] || !@config[:remote_path]
345
353
  # fetch health_check.txt from remote URL
346
- host = @config[:remote_host].to_s
347
- port = @config[:remote_port] ? @config[:remote_port].to_i : 80
348
- path = File.join(@config[:remote_path].to_s, 'health_check.txt')
349
354
  begin
350
- res = Net::HTTP.get_response(host, path, port)
351
- if (res.code != "200")
352
- return [false, "Could not fetch heath check file: http://#{host}:#{port}#{path} - status #{res.code}",
355
+ res = fetch_remote('health_check.txt')
356
+ if (res.status.to_i != 200)
357
+ return [false,
358
+ "Could not fetch heath check file: #{res.env.url.to_s} - status #{res.status.to_i}",
353
359
  nil]
354
360
  end
355
361
  rescue Exception => e
356
- return [false, "Could not fetch heath check file: http://#{host}:#{port}#{path} - #{e.message}", e]
362
+ return [false, "Could not fetch heath check file - #{e.message}", e]
357
363
  end
358
364
  [true, nil, nil]
359
365
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -77,6 +77,28 @@ dependencies:
77
77
  - - ! '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: 0.0.14
80
+ - !ruby/object:Gem::Dependency
81
+ name: faraday
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.8'
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.8.1
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '0.8'
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 0.8.1
80
102
  - !ruby/object:Gem::Dependency
81
103
  name: rake
82
104
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +174,7 @@ extra_rdoc_files: []
152
174
  files:
153
175
  - lib/quilt.rb
154
176
  - lib/lru_cache.rb
177
+ - lib/quilt/eventmachine.rb
155
178
  homepage: http://github.com/ooyala/ruby-quilt
156
179
  licenses:
157
180
  - MIT