glom 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 329b0af99850b0e75c722c273e06c2d934f672f7
4
- data.tar.gz: 5d89a1a8ed6c19d7ec3fdcff4731c3851ec1b0ad
3
+ metadata.gz: f17d2dde712e504a70d6c19f7d1f4e0e8b0137d1
4
+ data.tar.gz: d55f8be1e98b2f55a8b804ee7042b51403f290c2
5
5
  SHA512:
6
- metadata.gz: e8ac46a0105036989ea8fddcf81a892cb16c45ec747f3d8386b12e8e33d393c9ff6be945313d14492c132ec86b702685b2fce702553ac8375d5f02e4c2b9f2a6
7
- data.tar.gz: 51b2b6494f613f32704ae4c73ff562a01b809fee0d809f5a4576c82561b011cfe44714e552954ea9b46ee54200399c1604dc1a4b22d8808db361a2a5d76340a8
6
+ metadata.gz: 3d04ab4ea3faf44bc6ce4a71c7b3ff473e254cad10c6ab28225d4988edeefadc0bbe08c9a27599481a1d28ca7fa48854b4994e7645014e6fb839d6dc769dfc2c
7
+ data.tar.gz: 13749c4e82be8d32cc9741524a1f7fa53c1b69fc0c43ce6065890d90d4df81c937ce5a1b8d0ef689e486bbd0de71977c5219e146b66a0fc4e068efe80aceec44
data/lib/glom.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'glom/version'
2
+ require 'net/http'
2
3
  require 'json'
3
4
  require 'tmpdir'
4
5
 
@@ -63,13 +64,23 @@ module Glom
63
64
  end
64
65
 
65
66
  def get(address)
66
- cache = "#{Dir.tmpdir}/#{address.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')}.json"
67
+ cache = "#{Dir.tmpdir}/#{address.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_').gsub('.json', '')}.json"
67
68
 
68
69
  if File.exist? cache
69
70
  json = IO.read(cache)
70
71
  else
71
- uri = URI(address)
72
- json = Net::HTTP.get(uri)
72
+ url = URI.parse(address)
73
+
74
+ http = Net::HTTP.new(url.host, url.port)
75
+ if address =~ /^https/
76
+ http.use_ssl = true
77
+ # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
+ end
79
+
80
+ req = Net::HTTP::Get.new(url.request_uri)
81
+ res = http.request(req)
82
+
83
+ json = res.body
73
84
 
74
85
  output = File.new(cache, 'w')
75
86
  output.puts json
@@ -1,4 +1,3 @@
1
- require 'net/http'
2
1
  require 'json'
3
2
  require 'time'
4
3
  require 'glom/time/time_ago_in_words'
@@ -1,4 +1,3 @@
1
- require 'net/http'
2
1
  require 'json'
3
2
  require 'time'
4
3
  require 'glom/time/time_ago_in_words'
data/lib/glom/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Glom
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Gariety