salesforce_fsdb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/VERSION +1 -1
- data/lib/salesforce_fsdb/client.rb +13 -23
- data/lib/salesforce_fsdb/rest_client.rb +5 -16
- data/salesforce_fsdb.gemspec +2 -2
- data/test/test_setup.rb +1 -1
- metadata +10 -8
- checksums.yaml +0 -7
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -9,31 +9,21 @@ module SalesforceFsdb
|
|
9
9
|
@oSfRestClient = SalesforceFsdb::RestClient.new(dParamsGeneral,dParamsToken)
|
10
10
|
@sFsdbBaseDir = dParamsGeneral[:data_dir] || '.'
|
11
11
|
@iMaxAgeSec = dParamsGeneral[:max_age] || 3600*24*7
|
12
|
-
@dType3ToType = {
|
13
|
-
'Account' => 'act',
|
14
|
-
'Contact' => 'con',
|
15
|
-
'Opportunity' => 'opp',
|
16
|
-
'User' => 'usr'
|
17
|
-
}
|
18
12
|
end
|
19
|
-
def getFileForSfidAndType(sSfid=nil,
|
20
|
-
|
21
|
-
sFile = %Q{sf_#{sType3}_#{sSfid}.json}
|
13
|
+
def getFileForSfidAndType(sSfid=nil,sType=nil)
|
14
|
+
sFile = %Q{sf_#{sType}_#{sSfid}.json}
|
22
15
|
return sFile
|
23
16
|
end
|
24
|
-
def getDirForType(
|
25
|
-
|
26
|
-
sDir = File.join(@sFsdbBaseDir,sType3)
|
17
|
+
def getDirForType(sType=nil)
|
18
|
+
sDir = File.join(@sFsdbBaseDir,sType)
|
27
19
|
return sDir
|
28
20
|
end
|
29
|
-
def getPathForSfidAndType(sSfid=nil,
|
30
|
-
|
31
|
-
sPath = File.join( self.getDirForType(sType3), self.getFileForSfidAndType(sSfid,sType3))
|
21
|
+
def getPathForSfidAndType(sSfid=nil,sType=nil)
|
22
|
+
sPath = File.join( self.getDirForType(sType), self.getFileForSfidAndType(sSfid,sType))
|
32
23
|
return sPath
|
33
24
|
end
|
34
|
-
def getSobjectForSfidAndType(sSfid=nil,
|
35
|
-
|
36
|
-
sPath = self.getPathForSfidAndType(sSfid,sType3)
|
25
|
+
def getSobjectForSfidAndType(sSfid=nil,sType=nil)
|
26
|
+
sPath = self.getPathForSfidAndType(sSfid,sType)
|
37
27
|
dObj = { :meta => { :iEpochRetrieved => -1, :iStatus => 404 } }
|
38
28
|
iEpochNow = Time.now.to_i
|
39
29
|
if File.exists?(sPath)
|
@@ -49,13 +39,13 @@ module SalesforceFsdb
|
|
49
39
|
end
|
50
40
|
end
|
51
41
|
end
|
52
|
-
return self.getSobjectForSfidAndTypeFromRemote(sSfid,
|
42
|
+
return self.getSobjectForSfidAndTypeFromRemote(sSfid,sType)
|
53
43
|
end
|
54
|
-
def getSobjectForSfidAndTypeFromRemote(sSfid=nil,
|
55
|
-
dObj = @oSfRestClient.getSobjectForSfidAndType(sSfid,
|
44
|
+
def getSobjectForSfidAndTypeFromRemote(sSfid=nil,sType=nil)
|
45
|
+
dObj = @oSfRestClient.getSobjectForSfidAndType(sSfid,sType)
|
56
46
|
if dObj.has_key?(:Id)
|
57
|
-
sDir = self.getDirForType(
|
58
|
-
sPath = self.getPathForSfidAndType(sSfid,
|
47
|
+
sDir = self.getDirForType(sType)
|
48
|
+
sPath = self.getPathForSfidAndType(sSfid,sType)
|
59
49
|
FileUtils.mkdir_p(sDir) if ! Dir.exists?(sDir)
|
60
50
|
File.open(sPath,'w') do |fTop|
|
61
51
|
dTop = {
|
@@ -12,12 +12,6 @@ module SalesforceFsdb
|
|
12
12
|
@sApiFqdn = dParamsGeneral.has_key?(:api_fqdn) ? dParamsGeneral[:api_fqdn] : 'na5.salesforce.com'
|
13
13
|
@sApiVersion = dParamsGeneral.has_key?(:api_version) ? dParamsGeneral[:api_version] : '27.0'
|
14
14
|
@dTokenRes = {}
|
15
|
-
@dType3ToType = {
|
16
|
-
'act' => 'Account',
|
17
|
-
'con' => 'Contact',
|
18
|
-
'opp' => 'Opportunity',
|
19
|
-
'usr' => 'User'
|
20
|
-
}
|
21
15
|
self.loadToken()
|
22
16
|
end
|
23
17
|
def loadToken()
|
@@ -35,19 +29,14 @@ module SalesforceFsdb
|
|
35
29
|
return dHeaders
|
36
30
|
end
|
37
31
|
def getSoqlResults(sSoql=nil)
|
38
|
-
dQry
|
39
|
-
sUrl
|
40
|
-
|
41
|
-
|
32
|
+
dQry = { :q => sSoql}
|
33
|
+
sUrl = "https://#{@sApiFqdn}/services/data/v#{@sApiVersion}/query"
|
34
|
+
dHead = self.getHeaders()
|
35
|
+
oRes = Faraday.get(sUrl,dQry,dHead)
|
36
|
+
dRes = JSON.parse(oRes.body,:symbolize_names=>true)
|
42
37
|
return dRes
|
43
38
|
end
|
44
|
-
def getNormalizedType(sType=nil)
|
45
|
-
#sType = @dType3ToType[sType] if @dType3ToType.has_key?(sType)
|
46
|
-
sType = @dType3ToType[sType] || sType
|
47
|
-
return sType
|
48
|
-
end
|
49
39
|
def getSfUrlForSfidAndType(sSfid=nil,sType=nil)
|
50
|
-
sType = self.getNormalizedType(sType)
|
51
40
|
sUrl = "https://#{@sApiFqdn}/services/data/v#{@sApiVersion}/sobjects/#{sType}/#{sSfid}/"
|
52
41
|
return sUrl
|
53
42
|
end
|
data/salesforce_fsdb.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'salesforce_fsdb'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2014-01-
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.date = '2014-01-28'
|
5
5
|
s.summary = 'Salesforce Filesystem DB'
|
6
6
|
s.description = 'Filesystem cache manager for Salesforce sObjects'
|
7
7
|
s.authors = ['John Wang']
|
data/test/test_setup.rb
CHANGED
@@ -21,7 +21,7 @@ class SalesforceFsdbTest < Test::Unit::TestCase
|
|
21
21
|
sfFsdbClient = SalesforceFsdb::Client.new(paramsGeneral,paramsToken)
|
22
22
|
accountDir = sfFsdbClient.getDirForType('Account')
|
23
23
|
|
24
|
-
assert_equal accountDir, File.join(paramsGeneral[:data_dir],'
|
24
|
+
assert_equal accountDir, File.join(paramsGeneral[:data_dir],'Account')
|
25
25
|
|
26
26
|
tokenUrl = 'https://login.salesforce.com/services/oauth2/token'
|
27
27
|
assert_equal tokenUrl, sfFsdbClient.oSfRestClient.sSfTokenUrl
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_fsdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- John Wang
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Filesystem cache manager for Salesforce sObjects
|
14
15
|
email: johncwang@gmail.com
|
@@ -21,32 +22,33 @@ files:
|
|
21
22
|
- README.rdoc
|
22
23
|
- Rakefile
|
23
24
|
- VERSION
|
25
|
+
- salesforce_fsdb.gemspec
|
24
26
|
- lib/salesforce_fsdb/client.rb
|
25
27
|
- lib/salesforce_fsdb/rest_client.rb
|
26
|
-
- salesforce_fsdb.gemspec
|
27
28
|
- test/test_setup.rb
|
28
29
|
homepage: http://johnwang.com/
|
29
30
|
licenses:
|
30
31
|
- MIT
|
31
|
-
metadata: {}
|
32
32
|
post_install_message:
|
33
33
|
rdoc_options: []
|
34
34
|
require_paths:
|
35
35
|
- lib
|
36
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
37
38
|
requirements:
|
38
|
-
- -
|
39
|
+
- - ! '>='
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
42
44
|
requirements:
|
43
|
-
- -
|
45
|
+
- - ! '>='
|
44
46
|
- !ruby/object:Gem::Version
|
45
47
|
version: '0'
|
46
48
|
requirements: []
|
47
49
|
rubyforge_project:
|
48
|
-
rubygems_version:
|
50
|
+
rubygems_version: 1.8.23
|
49
51
|
signing_key:
|
50
|
-
specification_version:
|
52
|
+
specification_version: 3
|
51
53
|
summary: Salesforce Filesystem DB
|
52
54
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b9202234becb758cb247e79a0c299c33718f3cb5
|
4
|
-
data.tar.gz: 5e2049d2b4f535dc1841128c479040678e809466
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: a570ecbd949fb17204ea58681c5a4bb7100bbfc3113f40d46e7dd20bed05fde7e5d8640916e5661bc05e41e9d2077656783b7f37b5681c9a5ee274964f79d5c4
|
7
|
-
data.tar.gz: a5df11edcd11aa61c5dfa4965be04dbe69a3db18c9be6cdb48b923dba1dbba844b22269f899d62fe8c84c2158a07e53f63acb5d94b327b9ec895dae6038ae3e1
|