gc-datastore 0.0.2
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.
- checksums.yaml +7 -0
- data/lib/gc_datastore.rb +9 -0
- data/lib/gc_datastore/client.rb +23 -0
- data/lib/gc_datastore/datastore.rb +32 -0
- data/lib/gc_datastore/datastore_factory.rb +26 -0
- data/lib/gc_datastore/remote_rpc.rb +15 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d498a3a865c777a54fe63335d6fbb9cae0d3f62
|
4
|
+
data.tar.gz: ab98c5bceb3bc1e291ef22d88a7f6799e5754e0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e32df8b37dfbb20858f645b69aeda5cacf786fd56fee543b9ba531dd069b6e3f7015d8c260f68b6cfea06663518b16a21869f471f56f28b2fa1db9bd89c17476
|
7
|
+
data.tar.gz: 7386e41aa6f1f85edaac851325e7b85c8552b72833bdbb8f220e5aa5194a892329b25374bcfd3ec437ab68c19fad2b95f9379c1ca17867e6891594b5a4391724
|
data/lib/gc_datastore.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module GcDatastore
|
2
|
+
class Client
|
3
|
+
SCOPE = ['https://www.googleapis.com/auth/datastore',
|
4
|
+
'https://www.googleapis.com/auth/userinfo.email']
|
5
|
+
|
6
|
+
def initialize(options)
|
7
|
+
@client = Google::APIClient.new(
|
8
|
+
:application_name => options[:app_name],
|
9
|
+
:application_version => options[:version])
|
10
|
+
end
|
11
|
+
|
12
|
+
def authorize(options)
|
13
|
+
private_key = Google::APIClient::KeyUtils.load_from_pkcs12(options[:key_path], 'noasecret')
|
14
|
+
@client.authorization = Signet::OAuth2::Client.new(
|
15
|
+
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
|
16
|
+
:audience => 'https://accounts.google.com/o/oauth2/token',
|
17
|
+
:scope => SCOPE,
|
18
|
+
:issuer => options[:account],
|
19
|
+
:signing_key => private_key)
|
20
|
+
@client.authorization.fetch_access_token!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module GcDatastore
|
2
|
+
class Datastore
|
3
|
+
def initialize(remoteRpc, datastore)
|
4
|
+
@remoteRpc = remoteRpc
|
5
|
+
@datastore = datastore
|
6
|
+
end
|
7
|
+
|
8
|
+
def allocateIds(body_object={})
|
9
|
+
@remoteRpc.call(@datastore.datasets.allocate_ids, body_object)
|
10
|
+
end
|
11
|
+
|
12
|
+
def beginTransaction(body_object={})
|
13
|
+
@remoteRpc.call(@datastore.datasets.begin_transaction, body_object)
|
14
|
+
end
|
15
|
+
|
16
|
+
def commit(body_object={})
|
17
|
+
@remoteRpc.call(@datastore.datasets.commit, body_object)
|
18
|
+
end
|
19
|
+
|
20
|
+
def lookup(body_object={})
|
21
|
+
@remoteRpc.call(@datastore.datasets.lookup, body_object)
|
22
|
+
end
|
23
|
+
|
24
|
+
def rollback(body_object={})
|
25
|
+
@remoteRpc.call(@datastore.datasets.rollback, body_object)
|
26
|
+
end
|
27
|
+
|
28
|
+
def runQuery(body_object={})
|
29
|
+
@remoteRpc.call(@datastore.datasets.run_quert, body_object)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module GcDatastore
|
2
|
+
class DatastoreFactory
|
3
|
+
VERSION = 'v1beta2'
|
4
|
+
@@INSTANCE = nil
|
5
|
+
|
6
|
+
def self.get
|
7
|
+
@@INSTANCE = new unless @@INSTANCE
|
8
|
+
@@INSTANCE
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(options)
|
12
|
+
return GcDatastore::Datastore.new(newRemoteRpc(options))
|
13
|
+
end
|
14
|
+
|
15
|
+
def newRemoteRpc(options)
|
16
|
+
client = makeClient(options)
|
17
|
+
datastore = client.discovered_api('datastore', VERSION)
|
18
|
+
return GcDatastore::Datastore.new(GcDatastore::RemoteRpc.new(client, options))
|
19
|
+
end
|
20
|
+
|
21
|
+
def makeClient(options)
|
22
|
+
client = GcDatastore::Client.new(options).authorize(options)
|
23
|
+
return client
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GcDatastore
|
2
|
+
class RemoteRpc
|
3
|
+
def initialize(client, options)
|
4
|
+
@dataset_id = options[:dataset_id]
|
5
|
+
@client = client
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(method, body_object)
|
9
|
+
@client.execute(
|
10
|
+
:api_method => method,
|
11
|
+
:parameters => {:datasetId => @dataset_id},
|
12
|
+
:body_object => body_object)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gc-datastore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Seungbeom Kim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-api-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: active_support
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Google Cloud Datastore api for ruby
|
56
|
+
email: myksb1223@plokia.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/gc_datastore.rb
|
62
|
+
- lib/gc_datastore/client.rb
|
63
|
+
- lib/gc_datastore/datastore.rb
|
64
|
+
- lib/gc_datastore/datastore_factory.rb
|
65
|
+
- lib/gc_datastore/remote_rpc.rb
|
66
|
+
homepage:
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.2.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Google Cloud Datastore api
|
90
|
+
test_files: []
|