dynamodb-api 0.2.2 → 0.3.0
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 +4 -4
- data/Gemfile.lock +19 -6
- data/README.md +10 -2
- data/dynamodb-api.gemspec +1 -0
- data/lib/dynamodb/api.rb +10 -0
- data/lib/dynamodb/api/adapter.rb +3 -5
- data/lib/dynamodb/api/query.rb +47 -0
- data/lib/dynamodb/api/relation.rb +17 -0
- data/lib/dynamodb/api/relation/filter_clause.rb +17 -0
- data/lib/dynamodb/api/relation/from_clause.rb +15 -0
- data/lib/dynamodb/api/relation/global_secondary_index.rb +15 -0
- data/lib/dynamodb/api/relation/order_clause.rb +30 -0
- data/lib/dynamodb/api/relation/query_methods.rb +39 -0
- data/lib/dynamodb/api/relation/select_clause.rb +15 -0
- data/lib/dynamodb/api/relation/where_clause.rb +19 -0
- data/lib/dynamodb/api/version.rb +1 -1
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e493a4832d1843b505d76d08b9830d2e919e123b2ccf02407ebeff1da90880
|
4
|
+
data.tar.gz: cec7bb6630629e0384e9195583e9e4ecf375d07df609ce7abe0da8fda63c8085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7e74a28b06b41b5bcc394028c812b2d979e411b09e7140a14bd0abcbeccea9af0db69ea9281d00a82ab4dde46fb4909b76d858484e229e3856766557f90f0c
|
7
|
+
data.tar.gz: 7cac1cd51d923ccf69d72718cd1cd8a684327c16c718d37d7dcace0aefa56ef982ca28160b79ea76782f4ac04c3ca2ea344b5e636dd8dc6ed919367975f6dec6
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dynamodb-api (0.
|
4
|
+
dynamodb-api (0.3.0)
|
5
|
+
activesupport (>= 4)
|
5
6
|
aws-sdk (~> 2)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
activesupport (5.2.0)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
aws-sdk (2.11.93)
|
17
|
+
aws-sdk-resources (= 2.11.93)
|
18
|
+
aws-sdk-core (2.11.93)
|
13
19
|
aws-sigv4 (~> 1.0)
|
14
20
|
jmespath (~> 1.0)
|
15
|
-
aws-sdk-resources (2.11.
|
16
|
-
aws-sdk-core (= 2.11.
|
21
|
+
aws-sdk-resources (2.11.93)
|
22
|
+
aws-sdk-core (= 2.11.93)
|
17
23
|
aws-sigv4 (1.0.3)
|
18
24
|
byebug (10.0.2)
|
19
25
|
coderay (1.1.2)
|
26
|
+
concurrent-ruby (1.0.5)
|
20
27
|
diff-lcs (1.3)
|
28
|
+
i18n (1.0.1)
|
29
|
+
concurrent-ruby (~> 1.0)
|
21
30
|
jmespath (1.4.0)
|
22
31
|
method_source (0.9.0)
|
32
|
+
minitest (5.11.3)
|
23
33
|
pry (0.11.3)
|
24
34
|
coderay (~> 1.1.0)
|
25
35
|
method_source (~> 0.9.0)
|
@@ -40,6 +50,9 @@ GEM
|
|
40
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
51
|
rspec-support (~> 3.7.0)
|
42
52
|
rspec-support (3.7.1)
|
53
|
+
thread_safe (0.3.6)
|
54
|
+
tzinfo (1.2.5)
|
55
|
+
thread_safe (~> 0.1)
|
43
56
|
|
44
57
|
PLATFORMS
|
45
58
|
ruby
|
data/README.md
CHANGED
@@ -20,9 +20,17 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install dynamodb-api
|
22
22
|
|
23
|
-
##
|
23
|
+
## Configuration
|
24
24
|
|
25
|
-
|
25
|
+
`config/initializers/dynamodb_api.rb`
|
26
|
+
|
27
|
+
```
|
28
|
+
Dynamodb::Api.config do |config|
|
29
|
+
config.access_key = ''
|
30
|
+
config.secret_key = ''
|
31
|
+
config.region = ''
|
32
|
+
end
|
33
|
+
```
|
26
34
|
|
27
35
|
## Development
|
28
36
|
|
data/dynamodb-api.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_runtime_dependency 'aws-sdk', '~> 2'
|
26
|
+
spec.add_runtime_dependency('activesupport', '>= 4')
|
26
27
|
|
27
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/dynamodb/api.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
require 'aws-sdk'
|
2
|
+
require 'active_support'
|
2
3
|
|
3
4
|
require 'dynamodb/api/version'
|
4
5
|
require 'dynamodb/api/config'
|
5
6
|
require 'dynamodb/api/adapter'
|
7
|
+
require 'dynamodb/api/query'
|
8
|
+
require 'dynamodb/api/relation'
|
9
|
+
require 'dynamodb/api/relation/query_methods'
|
10
|
+
require 'dynamodb/api/relation/from_clause'
|
11
|
+
require 'dynamodb/api/relation/select_clause'
|
12
|
+
require 'dynamodb/api/relation/order_clause'
|
13
|
+
require 'dynamodb/api/relation/where_clause'
|
14
|
+
require 'dynamodb/api/relation/filter_clause'
|
15
|
+
require 'dynamodb/api/relation/global_secondary_index'
|
6
16
|
|
7
17
|
module Dynamodb
|
8
18
|
module Api
|
data/lib/dynamodb/api/adapter.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Dynamodb
|
2
2
|
module Api
|
3
3
|
class Adapter
|
4
|
-
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize
|
5
7
|
@client = Aws::DynamoDB::Client.new(connect_config)
|
6
8
|
end
|
7
9
|
|
@@ -23,10 +25,6 @@ module Dynamodb
|
|
23
25
|
|
24
26
|
@connect_hash
|
25
27
|
end
|
26
|
-
|
27
|
-
def client
|
28
|
-
@client
|
29
|
-
end
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dynamodb
|
4
|
+
module Api
|
5
|
+
class Query # :nodoc:
|
6
|
+
attr_reader :client
|
7
|
+
attr_reader :relation
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@relation = Relation.new
|
11
|
+
@client = Adapter.new.client
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
@client.query(build_query)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def build_query
|
21
|
+
{
|
22
|
+
table_name: @relation.from_clause.name,
|
23
|
+
index_name: @relation.index_clause.name,
|
24
|
+
select: @relation.select_clause.name,
|
25
|
+
scan_index_forward: @relation.order_clause.direct,
|
26
|
+
key_conditions: build_where_clause
|
27
|
+
}.merge(build_filter_clause)
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_where_clause
|
31
|
+
{
|
32
|
+
@relation.where_clause.key => {
|
33
|
+
attribute_value_list: [@relation.where_clause.value],
|
34
|
+
comparison_operator: @relation.where_clause.operator
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_filter_clause
|
40
|
+
{
|
41
|
+
filter_expression: @relation.filter_clause.expression,
|
42
|
+
expression_attribute_values: @relation.filter_clause.values
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dynamodb/api/relation/query_methods'
|
4
|
+
|
5
|
+
module Dynamodb
|
6
|
+
module Api
|
7
|
+
class Relation # :nodoc:
|
8
|
+
include QueryMethods
|
9
|
+
attr_accessor :index_clause
|
10
|
+
attr_accessor :from_clause
|
11
|
+
attr_accessor :select_clause
|
12
|
+
attr_accessor :order_clause
|
13
|
+
attr_accessor :where_clause
|
14
|
+
attr_accessor :filter_clause
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dynamodb
|
4
|
+
module Api
|
5
|
+
class Relation
|
6
|
+
class FilterClause # :nodoc:
|
7
|
+
attr_reader :expression
|
8
|
+
attr_reader :values
|
9
|
+
|
10
|
+
def initialize(expression, values)
|
11
|
+
@expression = expression
|
12
|
+
@values = values
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dynamodb
|
4
|
+
module Api
|
5
|
+
class Relation
|
6
|
+
class OrderClause # :nodoc:
|
7
|
+
attr_reader :direct
|
8
|
+
|
9
|
+
def initialize(direct = nil)
|
10
|
+
@direct = key_map(direct)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def key_map(direct)
|
16
|
+
case direct
|
17
|
+
when nil
|
18
|
+
false
|
19
|
+
when 'desc'
|
20
|
+
false
|
21
|
+
when 'asc'
|
22
|
+
true
|
23
|
+
else
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dynamodb/api/relation/from_clause'
|
4
|
+
|
5
|
+
module Dynamodb
|
6
|
+
module Api
|
7
|
+
module QueryMethods # :nodoc:
|
8
|
+
def from(value)
|
9
|
+
self.from_clause = Relation::FromClause.new(value)
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def index(value)
|
14
|
+
self.index_clause = Relation::GlobalSecondaryIndex.new(value)
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def select(value = nil)
|
19
|
+
self.select_clause = Relation::SelectClause.new(value)
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def order(value = nil)
|
24
|
+
self.order_clause = Relation::OrderClause.new(value)
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def where(key, value, operator)
|
29
|
+
self.where_clause = Relation::WhereClause.new(key, value, operator)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def filter(expression, values)
|
34
|
+
self.filter_clause = Relation::FilterClause.new(expression, values)
|
35
|
+
self
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dynamodb
|
4
|
+
module Api
|
5
|
+
class Relation
|
6
|
+
class WhereClause # :nodoc:
|
7
|
+
attr_reader :key
|
8
|
+
attr_reader :value
|
9
|
+
attr_reader :operator
|
10
|
+
|
11
|
+
def initialize(key, value, operator)
|
12
|
+
@key = key
|
13
|
+
@value = value
|
14
|
+
@operator = operator
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/dynamodb/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WalkerSumida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +117,15 @@ files:
|
|
103
117
|
- lib/dynamodb/api/adapter.rb
|
104
118
|
- lib/dynamodb/api/config.rb
|
105
119
|
- lib/dynamodb/api/config/options.rb
|
120
|
+
- lib/dynamodb/api/query.rb
|
121
|
+
- lib/dynamodb/api/relation.rb
|
122
|
+
- lib/dynamodb/api/relation/filter_clause.rb
|
123
|
+
- lib/dynamodb/api/relation/from_clause.rb
|
124
|
+
- lib/dynamodb/api/relation/global_secondary_index.rb
|
125
|
+
- lib/dynamodb/api/relation/order_clause.rb
|
126
|
+
- lib/dynamodb/api/relation/query_methods.rb
|
127
|
+
- lib/dynamodb/api/relation/select_clause.rb
|
128
|
+
- lib/dynamodb/api/relation/where_clause.rb
|
106
129
|
- lib/dynamodb/api/version.rb
|
107
130
|
homepage: https://github.com/walkersumida/dynamodb-api
|
108
131
|
licenses:
|