bogo 0.1.18 → 0.1.20

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: cb66080e0bb75b016bba1fd536a8eb4a8d0611d4
4
- data.tar.gz: 93a399ade1b9b81623c62f5447edc4c2e3b27b58
3
+ metadata.gz: 802b39d900a5909611b6aaffd3a419e2a82492a4
4
+ data.tar.gz: 13faec66be7d72b8150a2edb8ad30a5df28adac0
5
5
  SHA512:
6
- metadata.gz: c91c93d92398119d52daa6c79df155870711a06263249d3dce0e8afe3f0327aab5ff22152e520a1fdbccc737e09b481ffc3dcfa7f4470e36961b0fb633611302
7
- data.tar.gz: 114c5444931015075c47db6e9a4709397d2a65bbfde72960691b8c2a624b853a9d652f134a5a5ecf6441820587f5a02c06cfbc101389eea58ee370c13d5f85c4
6
+ metadata.gz: 714a82d0202b13f31c40238104551710a4754b92d25166b76d07b4410a102572f9c0a378ec1173bd2ba69241b9a7f1bada30baa03fd253969a01c0ddb6ba5ec7
7
+ data.tar.gz: 08f764cf4ebac3f9e88b36af71da9696f844c6d51d7a437ff42d0ad473b9888ff0a8c7c24ca9ecdce23a8f34837ef9e8faa176541e13fa128e801106b1523f24
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.20
2
+ * Add lazy proxy support monkey patch for http library
3
+ * [Lazy] Return default values when no data has been loaded
4
+
1
5
  ## v0.1.18
2
6
  * [PriorityQueue] Fix highscore sorting
3
7
 
@@ -0,0 +1,39 @@
1
+ require 'resolv'
2
+ require 'http'
3
+ require 'http/request'
4
+
5
+ # NOTE: This is a simple monkey patch to the httprb library to provide
6
+ # implicit proxy support to requests. It is defined within this
7
+ # library to allow easy sharing. It is the responsibility of the user
8
+ # to ensure the http gem is available!
9
+ class HTTP::Request
10
+
11
+ # Override to implicitly apply proxy as required
12
+ def proxy
13
+ if((@proxy.nil? || @proxy.empty?) && ENV["#{uri.scheme}_proxy"] && proxy_is_allowed?)
14
+ _proxy = URI.parse(ENV["#{uri.scheme}_proxy"])
15
+ Hash.new.tap do |opts|
16
+ opts[:proxy_address] = _proxy.host
17
+ opts[:proxy_port] = _proxy.port
18
+ opts[:proxy_username] = _proxy.user if _proxy.user
19
+ opts[:proxy_password] = _proxy.password if _proxy.password
20
+ end
21
+ else
22
+ @proxy if proxy_is_allowed?
23
+ end
24
+ end
25
+
26
+ # Check `ENV['no_proxy']` and disable proxy if endpoint is listed
27
+ #
28
+ # @return [TrueClass, FalseClass]
29
+ def proxy_is_allowed?
30
+ if(ENV['no_proxy'])
31
+ ENV['no_proxy'].to_s.split(',').map(&:strip).none? do |item|
32
+ File.fnmatch(item, [uri.host, uri.port].compact.join(':'))
33
+ end
34
+ else
35
+ true
36
+ end
37
+ end
38
+
39
+ end
data/lib/bogo/lazy.rb CHANGED
@@ -133,7 +133,13 @@ module Bogo
133
133
  define_method(name) do
134
134
  send(depends_on) if depends_on
135
135
  self.class.on_missing(self) unless data.has_key?(name) || dirty.has_key?(name)
136
- dirty[name] || data[name]
136
+ if(dirty.has_key?(name))
137
+ dirty[name]
138
+ elsif(data.has_key?(name))
139
+ data[name]
140
+ else
141
+ self.class.attributes[name][:default]
142
+ end
137
143
  end
138
144
  define_method("#{name}=") do |val|
139
145
  values = multiple_values && val.is_a?(Array) ? val : [val]
data/lib/bogo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bogo
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.1.18')
3
+ VERSION = Gem::Version.new('0.1.20')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bogo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -81,6 +81,7 @@ files:
81
81
  - lib/bogo/animal_strings.rb
82
82
  - lib/bogo/constants.rb
83
83
  - lib/bogo/ephemeral_file.rb
84
+ - lib/bogo/http_proxy.rb
84
85
  - lib/bogo/lazy.rb
85
86
  - lib/bogo/memoization.rb
86
87
  - lib/bogo/priority_queue.rb