quickbase 0.0.9 → 0.0.10

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4543fb74325f3ad2778b7006634676fe1910d75
4
+ data.tar.gz: a45570aa517bb091ed7818bb46703dd7d5a28d02
5
+ SHA512:
6
+ metadata.gz: f9417e0192389bfb4dc1a97afbb74ee0ad3710d77c3747b579bc848b5c84bcf003ffdffa2a192e3ccd8a369ed197f01b29f60ebcf6d604e7a0e8ae16a9d3306c
7
+ data.tar.gz: bfaaddb27be59ee014606d782d2543ad2f43917e539f6b3ebe09e61bce5edc22754149851237c4600fff3070a98a045fb796aa2fd9ccb6b88096f7b99b3c63ea
@@ -43,9 +43,18 @@ or, in your Gemfile
43
43
 
44
44
  quickbase.api.delete_record(7)
45
45
 
46
+ == Setting a proxy
47
+
48
+ quickbase = Quickbase::Connection.new(:apptoken => "apptoken", :dbid => "dbid", :http_proxy => "http://my.proxy.com:80")
49
+
50
+ the sytem http_proxy, https_proxy and no_proxy environment variable will be respected if you don't explicity pass a proxy
51
+
46
52
  == Changes
47
53
 
54
+ 04/01/2015
55
+ - Added proxy support
56
+
48
57
  01/13/2012
49
58
  - Api was changed to API. Http was changed to HTTP.
50
59
  - RSpec was added for testing.
51
- - Replaced LibXML with Nokogiri
60
+ - Replaced LibXML with Nokogiri
@@ -58,4 +58,8 @@ module Quickbase
58
58
  connection.http.post("API_DeleteRecord", tags)
59
59
  end
60
60
  end
61
+
62
+ class Api < API
63
+ puts "Class Api will be deprecated. Please use API instead."
64
+ end
61
65
  end
@@ -1,10 +1,10 @@
1
1
  module Quickbase
2
2
  class Connection
3
3
  class << self
4
- attr_writer :username, :password, :hours, :apptoken, :dbid, :org
4
+ attr_writer :username, :password, :hours, :apptoken, :dbid, :org, :http_proxy
5
5
  end
6
- attr_reader :username, :password, :hours, :apptoken, :dbid, :org
7
-
6
+ attr_reader :username, :password, :hours, :apptoken, :dbid, :org, :http_proxy
7
+
8
8
  def self.expectant_reader(*attributes)
9
9
  attributes.each do |attribute|
10
10
  (class << self; self; end).send(:define_method, attribute) do
@@ -13,30 +13,31 @@ module Quickbase
13
13
  end
14
14
  end
15
15
  end
16
- expectant_reader :username, :password, :hours, :apptoken, :dbid, :org
17
-
16
+ expectant_reader :username, :password, :hours, :apptoken, :dbid, :org, :http_proxy
17
+
18
18
  def initialize(options = {})
19
- [:username, :password, :hours, :apptoken, :dbid, :org].each do |attr|
19
+ [:username, :password, :hours, :apptoken, :dbid, :org, :http_proxy].each do |attr|
20
20
  instance_variable_set "@#{attr}", (options[attr].nil? ? Quickbase::Connection.send(attr) : options[attr])
21
21
  end
22
22
  instance_variable_set "@org", "www" if org.nil?
23
23
  end
24
-
24
+
25
25
  def instantiate
26
26
  config = {
27
- :username => username,
28
- :password => password,
29
- :hours => hours,
30
- :apptoken => apptoken,
31
- :dbid => dbid,
32
- :org => org
27
+ :username => username,
28
+ :password => password,
29
+ :hours => hours,
30
+ :apptoken => apptoken,
31
+ :dbid => dbid,
32
+ :org => org,
33
+ :http_proxy => http_proxy
33
34
  }
34
35
  end
35
-
36
+
36
37
  def http
37
38
  Quickbase::HTTP.new(instantiate)
38
39
  end
39
-
40
+
40
41
  def api
41
42
  Quickbase::API.new(self)
42
43
  end
@@ -1,17 +1,21 @@
1
+ require 'httparty'
1
2
  module Quickbase
2
3
  class HTTP
3
4
  include HTTParty
4
5
  attr_accessor :qb_params
5
-
6
+
6
7
  def initialize(config)
7
8
  self.class.base_uri "https://#{config[:org]}.quickbase.com"
8
9
  instance_variable_set "@qb_params", {:dbid => "main"}
9
- response = post("API_Authenticate", Quickbase::Helper.hash_to_xml(config))
10
- qb_params[:ticket] = response.xpath("//ticket").first.content
10
+
11
+ http_proxy = config[:http_proxy] || ENV['http_proxy']
12
+ setup_proxy(http_proxy) if http_proxy
13
+
14
+ qb_params[:ticket] = auth_ticket config
11
15
  qb_params[:apptoken] = config[:apptoken]
12
16
  qb_params[:dbid] = config[:dbid]
13
17
  end
14
-
18
+
15
19
  def post(quickbase_action, params = [])
16
20
  params = params.concat(Quickbase::Helper.hash_to_xml(qb_params))
17
21
  clean_xml_string = Quickbase::Helper.generate_xml(params).to_s
@@ -22,19 +26,41 @@ module Quickbase
22
26
  error_handler(response)
23
27
  response
24
28
  end
25
-
29
+
26
30
  private
27
-
31
+ def auth_ticket(config)
32
+ response = post("API_Authenticate", Quickbase::Helper.hash_to_xml(config))
33
+ response.xpath("//ticket").first.content
34
+ end
35
+
36
+ def no_proxy?
37
+ host = URI.parse(self.class.base_uri).host
38
+ ENV.fetch('no_proxy','').split(',').any? do |pattern|
39
+ # convert patterns like `*.example.com` into `.*\.example\.com`
40
+ host =~ Regexp.new(pattern.gsub(/\./,'\\.').gsub(/\*/,'.*'))
41
+ end
42
+ end
43
+
44
+ def setup_proxy(proxy_url)
45
+ return if no_proxy?
46
+
47
+ proxy_url = URI.parse(proxy_url)
48
+
49
+ self.class.http_proxy(proxy_url.host, proxy_url.port,
50
+ proxy_url.user, proxy_url.password)
51
+ end
52
+
28
53
  def error_handler(response)
29
- case response.xpath("//errcode").first.content.to_i
30
- when 0
31
- return true
32
- else
33
- errcode = response.xpath('//errcode').first.content
54
+ errcode = response.xpath("//errcode").first.content
55
+
56
+ unless errcode.to_i.zero?
34
57
  errtext = response.xpath('//errtext').first.content
35
58
  raise "#{errcode}: #{errtext}"
36
- return false
37
59
  end
38
60
  end
39
61
  end
62
+
63
+ class Http < HTTP
64
+ puts "Class Http will be deprecated. Please use HTTP instead."
65
+ end
40
66
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{quickbase}
3
- s.version = "0.0.9"
3
+ s.version = "0.0.10"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Artem Kalinchuk"]
@@ -1,9 +1,7 @@
1
- gem "activerecord"
2
1
  require "active_record"
3
2
  require "cgi"
4
3
  require 'pp'
5
-
6
- require File.dirname(__FILE__) + "/../lib/quickbase.rb"
4
+ require 'spec_helper'
7
5
 
8
6
  #fill in your own quickbase account / database
9
7
  Quickbase::Connection.username = ""
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.0.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - Artem Kalinchuk
@@ -14,49 +13,43 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: httparty
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: activesupport
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: The Quickbase Gem provides integration access to the Intuit Quickbase
@@ -66,40 +59,40 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - lib/quickbase.rb
70
- - quickbase.gemspec
71
62
  - README.rdoc
72
63
  - lib/classes/api.rb
73
64
  - lib/classes/connection.rb
74
65
  - lib/classes/helper.rb
75
66
  - lib/classes/http.rb
67
+ - lib/quickbase.rb
68
+ - quickbase.gemspec
76
69
  - spec/quickbase_spec.rb
77
70
  homepage:
78
71
  licenses: []
72
+ metadata: {}
79
73
  post_install_message:
80
74
  rdoc_options:
81
- - --line-numbers
82
- - --inline-source
83
- - --title
75
+ - "--line-numbers"
76
+ - "--inline-source"
77
+ - "--title"
84
78
  - Quickbase
85
79
  require_paths:
86
80
  - lib
87
81
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
82
  requirements:
90
- - - ! '>='
83
+ - - ">="
91
84
  - !ruby/object:Gem::Version
92
85
  version: '0'
93
86
  required_rubygems_version: !ruby/object:Gem::Requirement
94
- none: false
95
87
  requirements:
96
- - - ! '>='
88
+ - - ">="
97
89
  - !ruby/object:Gem::Version
98
90
  version: '1.2'
99
91
  requirements: []
100
92
  rubyforge_project: quickbase
101
- rubygems_version: 1.8.24
93
+ rubygems_version: 2.2.1
102
94
  signing_key:
103
- specification_version: 3
95
+ specification_version: 4
104
96
  summary: Quickbase Ruby Gem
105
97
  test_files: []
98
+ has_rdoc: