restforce 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of restforce might be problematic. Click here for more details.

data/README.md CHANGED
@@ -81,6 +81,21 @@ client = Restforce.new :username => 'foo',
81
81
  :client_secret => 'client_secret'
82
82
  ```
83
83
 
84
+ You can also set the username, password, security token, client id and client
85
+ secret in environment variables:
86
+
87
+ ```bash
88
+ export SALESFORCE_USERNAME="username"
89
+ export SALESFORCE_PASSWORD="password"
90
+ export SALESFORCE_SECURITY_TOKEN="security token"
91
+ export SALESFORCE_CLIENT_ID="client id"
92
+ export SALESFORCE_CLIENT_SECRET="client secret"
93
+ ```
94
+
95
+ ```ruby
96
+ client = Restforce.new
97
+ ```
98
+
84
99
  #### Sandbox Orgs
85
100
 
86
101
  You can connect to sandbox orgs by specifying a host. The default host is
@@ -96,8 +111,8 @@ You can set any of the options passed into Restforce.new globally:
96
111
 
97
112
  ```ruby
98
113
  Restforce.configure do |config|
99
- config.client_id = ENV['SALESFORCE_CLIENT_ID']
100
- config.client_secret = ENV['SALESFORCE_CLIENT_SECRET']
114
+ config.client_id = 'foo'
115
+ config.client_secret = 'bar'
101
116
  end
102
117
  ```
103
118
 
@@ -27,7 +27,7 @@ module Restforce
27
27
  # client.api_delete 'sobjects/Account/001D000000INjVe'
28
28
  #
29
29
  # Returns the Faraday::Response.
30
- define_verbs :get, :post, :put, :delete, :patch
30
+ define_verbs :get, :post, :put, :delete, :patch, :head
31
31
 
32
32
  # Public: Get the names of all sobjects on the org.
33
33
  #
@@ -66,9 +66,35 @@ module Restforce
66
66
  # Set to true if you want responses from Salesforce to be gzip compressed.
67
67
  attr_accessor :compress
68
68
 
69
- def initialize
70
- @api_version ||= '26.0'
71
- @host ||= 'login.salesforce.com'
69
+ def api_version
70
+ @api_version ||= '26.0'
71
+ end
72
+
73
+ def username
74
+ @username ||= ENV['SALESFORCE_USERNAME']
75
+ end
76
+
77
+ def password
78
+ @password ||= ENV['SALESFORCE_PASSWORD']
79
+ end
80
+
81
+ def security_token
82
+ @security_token ||= ENV['SALESFORCE_SECURITY_TOKEN']
83
+ end
84
+
85
+ def client_id
86
+ @client_id ||= ENV['SALESFORCE_CLIENT_ID']
87
+ end
88
+
89
+ def client_secret
90
+ @client_secret ||= ENV['SALESFORCE_CLIENT_SECRET']
91
+ end
92
+
93
+ def host
94
+ @host ||= 'login.salesforce.com'
95
+ end
96
+
97
+ def authentication_retries
72
98
  @authentication_retries ||= 3
73
99
  end
74
100
 
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -1,6 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Restforce do
4
+ before do
5
+ ENV['SALESFORCE_USERNAME'] = nil
6
+ ENV['SALESFORCE_PASSWORD'] = nil
7
+ ENV['SALESFORCE_SECURITY_TOKEN'] = nil
8
+ ENV['SALESFORCE_CLIENT_ID'] = nil
9
+ ENV['SALESFORCE_CLIENT_SECRET'] = nil
10
+ end
11
+
4
12
  after do
5
13
  Restforce.instance_variable_set :@configuration, nil
6
14
  end
@@ -19,6 +27,30 @@ describe Restforce do
19
27
  its(attr) { should be_nil }
20
28
  end
21
29
  end
30
+
31
+ context 'when environment variables are defined' do
32
+ before do
33
+ ENV['SALESFORCE_USERNAME'] = 'foo'
34
+ ENV['SALESFORCE_PASSWORD'] = 'bar'
35
+ ENV['SALESFORCE_SECURITY_TOKEN'] = 'foobar'
36
+ ENV['SALESFORCE_CLIENT_ID'] = 'client id'
37
+ ENV['SALESFORCE_CLIENT_SECRET'] = 'client secret'
38
+ end
39
+
40
+ after do
41
+ ENV.delete('SALESFORCE_USERNAME')
42
+ ENV.delete('SALESFORCE_PASSWORD')
43
+ ENV.delete('SALESFORCE_SECURITY_TOKEN')
44
+ ENV.delete('SALESFORCE_CLIENT_ID')
45
+ ENV.delete('SALESFORCE_CLIENT_SECRET')
46
+ end
47
+
48
+ its(:username) { should eq 'foo' }
49
+ its(:password) { should eq 'bar'}
50
+ its(:security_token) { should eq 'foobar' }
51
+ its(:client_id) { should eq 'client id' }
52
+ its(:client_secret) { should eq 'client secret' }
53
+ end
22
54
  end
23
55
 
24
56
  describe '#configure' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-23 00:00:00.000000000 Z
12
+ date: 2012-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday