proxied 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: c3225511d5ca688c62c4c41138f7dfa135b766a1ca22de15f638c76a4bc805e6
4
- data.tar.gz: ddaa33c4df250b5b868eb98262b0c87dc3c0ad099fd9343989f77c18e16a8d74
3
+ metadata.gz: fb6b1d839edb6a86acc7e15c72ae74e4e94e61d6302fe12d11378c18edadea36
4
+ data.tar.gz: ee71b159f7d46d703a9c819c6d52a79060262ae984999d3083b6fa72d2581371
5
5
  SHA512:
6
- metadata.gz: 107c196e83c9a87d27674c89cb6f6384b5c69a689e3c2c0d818f0241bddec129180bbc39e0e16599abc15e1eb10e76e308e5aa038c13478fd2e74b5ba57b435d
7
- data.tar.gz: 9d5d1cfed81dad98ec888d571e2e1cfcac30cc8e0d6898e60c4edad01538eada8936621363c016b6e0c75998d714771cd8e3bcd6a864794f332c1659a025063f
6
+ metadata.gz: 7115524c83549e66f528dc1764a029e79ea43c9c38f006657b17ae5ef8ba24fc6eaff7abd33756a1122c1d0cd6bb11947ad5322d215032cdab437c2c56d18648
7
+ data.tar.gz: 1ec14f18413f2168f3e437c544d6389171ab5567c0c74375f96bf110b4a41408aa957f84ff3c11cd122c572e2eddab7ca8fb21daaa51c9ec6dad2c3c0ddede96
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- proxied (0.1.0)
4
+ proxied (0.1.3)
5
5
  faraday (>= 0.14)
6
6
  net-ssh (>= 4.0)
7
7
 
data/README.md CHANGED
@@ -28,10 +28,14 @@ Generate the initializer for your Rails app:
28
28
 
29
29
  $ rails generate proxied:install MODEL
30
30
 
31
- Generate the migration and model:
31
+ If you're using ActiveRecord, generate the migration and model:
32
32
 
33
33
  $ rails generate proxied MODEL
34
34
 
35
+ If you're using Mongoid, generate the model using the following command:
36
+
37
+ $ rails generate proxied MODEL --orm=mongoid
38
+
35
39
  ## Features
36
40
 
37
41
  Features:
data/lib/proxied.rb CHANGED
@@ -28,6 +28,7 @@ require "proxied/version"
28
28
 
29
29
  require "proxied/configuration"
30
30
  require "proxied/logger"
31
+ require "proxied/utilities"
31
32
 
32
33
  require "proxied/shared"
33
34
  require "proxied/sql/proxy_methods" if defined?(ActiveRecord)
@@ -10,43 +10,31 @@ module Proxied
10
10
  return proxies
11
11
  end
12
12
 
13
- def format_proxy_address(proxy_host, proxy_port = 80, include_http = false)
14
- proxy_address = "#{proxy_host}:#{proxy_port}"
15
- proxy_address.insert(0, "http://") if (include_http && !proxy_address.start_with?("http://"))
16
- return proxy_address
13
+ # Keep these for compatibility for now, they just wrap the utility functions
14
+ def format_proxy_address(host, port = 80, include_http = false)
15
+ ::Proxied::Utilities.format_proxy_address(host: host, port: port, include_http: include_http)
17
16
  end
18
17
 
19
18
  def format_proxy_credentials(username, password)
20
- return "#{username}:#{password}"
19
+ ::Proxied::Utilities.format_proxy_credentials(username, password)
21
20
  end
22
21
  end
23
22
 
24
23
  module InstanceMethods
25
- def proxy_address(include_http = false)
26
- return self.class.format_proxy_address(self.host, self.port, include_http)
24
+ def proxy_address(include_http: false)
25
+ ::Proxied::Utilities.format_proxy_address(host: self.host, port: self.port, include_http: include_http)
27
26
  end
28
27
 
29
28
  def proxy_credentials
30
- return self.class.format_proxy_credentials(self.username, self.password)
29
+ ::Proxied::Utilities.format_proxy_credentials(self.username, self.password)
31
30
  end
32
31
 
33
32
  def socks_proxy_credentials
34
- credentials = {}
35
-
36
- credentials[:user] = self.username if !self.username.to_s.empty?
37
- credentials[:password] = self.password if !self.password.to_s.empty?
38
-
39
- return credentials
33
+ ::Proxied::Utilities.socks_proxy_credentials(username: self.username, password: self.password)
40
34
  end
41
35
 
42
36
  def proxy_options_for_faraday
43
- proxy_options = {}
44
-
45
- proxy_options[:uri] = self.class.format_proxy_address(self.host, self.port, true)
46
- proxy_options[:user] = self.username if !self.username.to_s.empty?
47
- proxy_options[:password] = self.password if !self.password.to_s.empty?
48
-
49
- return proxy_options
37
+ ::Proxied::Utilities.proxy_options_for_faraday(host: self.host, port: self.port, username: self.username, password: self.password)
50
38
  end
51
39
  end
52
40
 
@@ -0,0 +1,39 @@
1
+ module Proxied
2
+ class Utilities
3
+
4
+ class << self
5
+
6
+ def format_proxy_address(host:, port: 80, include_http: false)
7
+ address = "#{host}:#{port}"
8
+ address = "http://#{address}" if include_http && !address.start_with?("http://")
9
+
10
+ return address
11
+ end
12
+
13
+ def format_proxy_credentials(username, password)
14
+ return "#{username}:#{password}"
15
+ end
16
+
17
+ def socks_proxy_credentials(username: nil, password: nil)
18
+ credentials = {}
19
+
20
+ credentials[:user] = username if !username.to_s.empty?
21
+ credentials[:password] = password if !password.to_s.empty?
22
+
23
+ return credentials
24
+ end
25
+
26
+ def proxy_options_for_faraday(host:, port:, username: nil, password: nil)
27
+ proxy_options = {}
28
+
29
+ proxy_options[:uri] = format_proxy_address(host: host, port: port, include_http: true)
30
+ proxy_options[:user] = username if !username.to_s.empty?
31
+ proxy_options[:password] = password if !password.to_s.empty?
32
+
33
+ return proxy_options
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Proxied
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxied
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-01 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -299,6 +299,7 @@ files:
299
299
  - lib/proxied/railtie.rb
300
300
  - lib/proxied/shared.rb
301
301
  - lib/proxied/sql/proxy_methods.rb
302
+ - lib/proxied/utilities.rb
302
303
  - lib/proxied/version.rb
303
304
  - lib/tasks/tasks.rake
304
305
  - proxied.gemspec