google-maps-stitch-bin 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/tiler/tile.rb +11 -3
  2. metadata +1 -1
data/lib/tiler/tile.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  require "tempfile"
2
+ require 'net/http'
3
+ require 'uri'
4
+
2
5
  class Tile
3
6
 
4
7
  attr_reader :x, :y, :z
@@ -17,12 +20,17 @@ class Tile
17
20
  end
18
21
 
19
22
  def download
20
- open(remote_url) do |image|
21
- file = Tempfile.new("x_#{x}_y_#{y}_z_#{z}")
22
- file.write(image.read)
23
+
24
+ uri = URI.parse(remote_url)
25
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
26
+ resp = http.get(uri.path)
27
+ file = Tempfile.new("x_#{x}_y_#{y}_z_#{z}", Dir.tmpdir, 'wb+')
28
+ file.write(resp.body)
29
+ file.flush
23
30
  puts "downloaded #{remote_url} to #{file.path}"
24
31
  @file = file
25
32
  @local_file_name = file.path
33
+ file
26
34
  end
27
35
  end
28
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-maps-stitch-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: