jets 1.4.10 → 1.4.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -2
- data/lib/jets/application.rb +4 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +1 -0
- data/lib/jets/db.rb +11 -5
- data/lib/jets/resource/lambda/function.rb +7 -1
- data/lib/jets/version.rb +1 -1
- data/lib/jets.rb +0 -7
- data/vendor/jets-gems/lib/jets/gems/check.rb +2 -2
- metadata +2 -41
- data/vendor/dynomite/CHANGELOG.md +0 -45
- data/vendor/dynomite/Gemfile +0 -6
- data/vendor/dynomite/Gemfile.lock +0 -61
- data/vendor/dynomite/README.md +0 -141
- data/vendor/dynomite/Rakefile +0 -2
- data/vendor/dynomite/bin/console +0 -14
- data/vendor/dynomite/bin/setup +0 -8
- data/vendor/dynomite/docs/migrations/long-example.rb +0 -123
- data/vendor/dynomite/docs/migrations/short-example.rb +0 -40
- data/vendor/dynomite/dynomite.gemspec +0 -29
- data/vendor/dynomite/lib/dynomite/core.rb +0 -25
- data/vendor/dynomite/lib/dynomite/db_config.rb +0 -107
- data/vendor/dynomite/lib/dynomite/erb.rb +0 -53
- data/vendor/dynomite/lib/dynomite/item.rb +0 -292
- data/vendor/dynomite/lib/dynomite/log.rb +0 -15
- data/vendor/dynomite/lib/dynomite/migration/common.rb +0 -86
- data/vendor/dynomite/lib/dynomite/migration/dsl/base_secondary_index.rb +0 -73
- data/vendor/dynomite/lib/dynomite/migration/dsl/global_secondary_index.rb +0 -4
- data/vendor/dynomite/lib/dynomite/migration/dsl/local_secondary_index.rb +0 -8
- data/vendor/dynomite/lib/dynomite/migration/dsl.rb +0 -194
- data/vendor/dynomite/lib/dynomite/migration/executor.rb +0 -38
- data/vendor/dynomite/lib/dynomite/migration/generator.rb +0 -68
- data/vendor/dynomite/lib/dynomite/migration/templates/create_table.rb +0 -32
- data/vendor/dynomite/lib/dynomite/migration/templates/update_table.rb +0 -26
- data/vendor/dynomite/lib/dynomite/migration.rb +0 -27
- data/vendor/dynomite/lib/dynomite/version.rb +0 -3
- data/vendor/dynomite/lib/dynomite.rb +0 -23
- data/vendor/dynomite/pkg/dynomite-1.0.8.gem +0 -0
- data/vendor/dynomite/pkg/dynomite-1.0.9.gem +0 -0
- data/vendor/dynomite/pkg/dynomite-1.1.0.gem +0 -0
- data/vendor/dynomite/spec/fixtures/app_root/config/dynamodb.yml +0 -7
- data/vendor/dynomite/spec/fixtures/dynamodb/migrate/20190108061826-comments_migration.rb +0 -30
- data/vendor/dynomite/spec/lib/dynomite/item_spec.rb +0 -102
- data/vendor/dynomite/spec/lib/dynomite/migration/dsl/global_secondary_index_spec.rb +0 -106
- data/vendor/dynomite/spec/lib/dynomite/migration/dsl/local_secondary_index_spec.rb +0 -71
- data/vendor/dynomite/spec/lib/dynomite/migration/dsl_spec.rb +0 -76
- data/vendor/dynomite/spec/lib/dynomite/migration/generator_spec.rb +0 -23
- data/vendor/dynomite/spec/lib/dynomite/migration_spec.rb +0 -60
- data/vendor/dynomite/spec/spec_helper.rb +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24d179a8d9f5977280a81d8897cdbb13670a365823e94388f1ccb494aa47507d
|
4
|
+
data.tar.gz: 10ce7863fa659965ff45964ce4fbdb040f104a145dd57a5fdd6b18610afbff5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f01c123b0318172492ba05bb8c86acc9664b303662fb3ba8ef46b841783cc138c316516afa54468506697b4f899308d624de60b728fa6848feb03f6260b76b6
|
7
|
+
data.tar.gz: 3db800311acd08768ddb4a5747c58c1dee6667c59d09e1fe2750253c57805bd3dba6f830df83f5bd580f0356f71f40f2bc842c878ca7039bfd33f58289a82d21
|
data/.gitmodules
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [1.4.11]
|
7
|
+
- #133 from tongueroo/custom-layer add custom lambda layer support
|
8
|
+
- #134 from tongueroo/remove-dynomite-vendor remove vendor/dynomite
|
9
|
+
|
6
10
|
## [1.4.10]
|
7
11
|
- update vendor/dynomite: fix index creation dsl
|
8
12
|
|
data/Gemfile
CHANGED
@@ -8,6 +8,7 @@ gemspec
|
|
8
8
|
# Need both because of jets/application.rb and jets/webpacker/middleware_setup.rb
|
9
9
|
group :development, :test do
|
10
10
|
gem "mysql2", "~> 0.5.2"
|
11
|
+
gem "dynomite"
|
11
12
|
gem "webpacker", git: "https://github.com/tongueroo/webpacker.git", branch: "jets"
|
12
13
|
gem "rspec_junit_formatter"
|
13
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@ GIT
|
|
11
11
|
PATH
|
12
12
|
remote: .
|
13
13
|
specs:
|
14
|
-
jets (1.4.
|
14
|
+
jets (1.4.11)
|
15
15
|
actionpack (>= 5.2.1)
|
16
16
|
actionview (>= 5.2.1)
|
17
17
|
activerecord (>= 5.2.1)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
tzinfo (~> 1.1)
|
68
68
|
arel (9.0.0)
|
69
69
|
aws-eventstream (1.0.1)
|
70
|
-
aws-partitions (1.
|
70
|
+
aws-partitions (1.130.0)
|
71
71
|
aws-sdk-apigateway (1.23.0)
|
72
72
|
aws-sdk-core (~> 3, >= 3.39.0)
|
73
73
|
aws-sigv4 (~> 1.0)
|
@@ -109,6 +109,9 @@ GEM
|
|
109
109
|
crass (1.0.4)
|
110
110
|
diff-lcs (1.3)
|
111
111
|
dotenv (2.6.0)
|
112
|
+
dynomite (1.1.0)
|
113
|
+
activesupport
|
114
|
+
aws-sdk-dynamodb
|
112
115
|
erubi (1.8.0)
|
113
116
|
gems (1.1.1)
|
114
117
|
json
|
@@ -174,6 +177,7 @@ PLATFORMS
|
|
174
177
|
DEPENDENCIES
|
175
178
|
bundler
|
176
179
|
byebug
|
180
|
+
dynomite
|
177
181
|
jets!
|
178
182
|
mysql2 (~> 0.5.2)
|
179
183
|
rake
|
data/lib/jets/application.rb
CHANGED
@@ -85,6 +85,10 @@ class Jets::Application
|
|
85
85
|
# Useful to disable this when user wants to manage the route themself like pointing
|
86
86
|
# it to CloudFront for blue-green deployments instead.
|
87
87
|
|
88
|
+
# Custom user lambda layers
|
89
|
+
config.lambda = ActiveSupport::OrderedOptions.new
|
90
|
+
config.lambda.layers = []
|
91
|
+
|
88
92
|
config
|
89
93
|
end
|
90
94
|
|
@@ -13,6 +13,7 @@ gem "pg", "~> 1.1.3"
|
|
13
13
|
# Include mysql2 gem if you are using ActiveRecord, remove if you are not
|
14
14
|
gem "mysql2", "~> 0.5.2"
|
15
15
|
<% end %>
|
16
|
+
gem "dynomite"
|
16
17
|
|
17
18
|
group :development, :test do
|
18
19
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
data/lib/jets/db.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
module Jets::Db ; end
|
2
2
|
|
3
3
|
# Thanks: https://makandracards.com/makandra/42521-detecting-if-a-ruby-gem-is-loaded
|
4
|
-
|
4
|
+
if File.exist?("#{Jets.root}config/database.yml")
|
5
|
+
require "active_record"
|
6
|
+
specs = Gem.loaded_specs
|
7
|
+
require "mysql2" if specs.key?('mysql2')
|
8
|
+
require "pg" if specs.key?('pg')
|
9
|
+
end
|
5
10
|
|
6
|
-
|
7
|
-
specs = Gem.loaded_specs
|
8
|
-
|
9
|
-
require "
|
11
|
+
if File.exist?("#{Jets.root}config/dynamodb.yml")
|
12
|
+
specs = Gem.loaded_specs
|
13
|
+
specs.key?('dynomite')
|
14
|
+
require "dynomite" if specs.key?('dynomite')
|
15
|
+
end
|
@@ -129,10 +129,16 @@ module Jets::Resource::Lambda
|
|
129
129
|
handler: handler,
|
130
130
|
runtime: runtime,
|
131
131
|
}
|
132
|
-
|
132
|
+
layers = get_layers(runtime)
|
133
|
+
managed[:layers] = layers if layers
|
133
134
|
props.merge!(managed)
|
134
135
|
end
|
135
136
|
|
137
|
+
def get_layers(runtime)
|
138
|
+
return nil unless runtime =~ /^ruby/
|
139
|
+
["!Ref GemLayer"] + Jets.config.lambda.layers
|
140
|
+
end
|
141
|
+
|
136
142
|
def get_runtime(props)
|
137
143
|
props[:runtime] || default_runtime
|
138
144
|
end
|
data/lib/jets/version.rb
CHANGED
data/lib/jets.rb
CHANGED
@@ -61,11 +61,4 @@ require "jets/core_ext/kernel"
|
|
61
61
|
$:.unshift(File.expand_path("../../vendor/jets-gems/lib", __FILE__))
|
62
62
|
require "jets-gems"
|
63
63
|
|
64
|
-
# lazy loaded dependencies: depends what project. Mainly determined by Gemfile
|
65
|
-
# and config files.
|
66
|
-
if File.exist?("#{Jets.root}config/dynamodb.yml")
|
67
|
-
$:.unshift(File.expand_path("../../vendor/dynomite/lib", __FILE__))
|
68
|
-
require "dynomite"
|
69
|
-
end
|
70
|
-
|
71
64
|
Jets::Db # trigger autoload
|
@@ -72,9 +72,9 @@ Your current lambdagems sources:
|
|
72
72
|
|
73
73
|
Jets is unable to build a deployment package that will work on AWS Lambda without the required pre-compiled gems. To remedy this, you can:
|
74
74
|
|
75
|
-
* Build the gem yourself and add it to your own custom lambdagems sources. Refer to the Lambda Gems Docs: http://rubyonjets.com/docs/lambdagems
|
76
75
|
* Use another gem that does not require compilation.
|
77
|
-
*
|
76
|
+
* Create your own custom layer with the gem: http://rubyonjets.com/docs/custom-lambda-layers/
|
77
|
+
* Build the gem yourself and add it to your own custom lambdagems sources. Refer to the Lambda Gems Docs: http://rubyonjets.com/docs/lambdagems
|
78
78
|
<% if agree.yes? -%>
|
79
79
|
* No need to report this to us, as we've already been notified.
|
80
80
|
<% elsif agree.no? -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -798,45 +798,6 @@ files:
|
|
798
798
|
- lib/jets/version.rb
|
799
799
|
- readme/prerelease.md
|
800
800
|
- readme/testing.md
|
801
|
-
- vendor/dynomite/CHANGELOG.md
|
802
|
-
- vendor/dynomite/Gemfile
|
803
|
-
- vendor/dynomite/Gemfile.lock
|
804
|
-
- vendor/dynomite/README.md
|
805
|
-
- vendor/dynomite/Rakefile
|
806
|
-
- vendor/dynomite/bin/console
|
807
|
-
- vendor/dynomite/bin/setup
|
808
|
-
- vendor/dynomite/docs/migrations/long-example.rb
|
809
|
-
- vendor/dynomite/docs/migrations/short-example.rb
|
810
|
-
- vendor/dynomite/dynomite.gemspec
|
811
|
-
- vendor/dynomite/lib/dynomite.rb
|
812
|
-
- vendor/dynomite/lib/dynomite/core.rb
|
813
|
-
- vendor/dynomite/lib/dynomite/db_config.rb
|
814
|
-
- vendor/dynomite/lib/dynomite/erb.rb
|
815
|
-
- vendor/dynomite/lib/dynomite/item.rb
|
816
|
-
- vendor/dynomite/lib/dynomite/log.rb
|
817
|
-
- vendor/dynomite/lib/dynomite/migration.rb
|
818
|
-
- vendor/dynomite/lib/dynomite/migration/common.rb
|
819
|
-
- vendor/dynomite/lib/dynomite/migration/dsl.rb
|
820
|
-
- vendor/dynomite/lib/dynomite/migration/dsl/base_secondary_index.rb
|
821
|
-
- vendor/dynomite/lib/dynomite/migration/dsl/global_secondary_index.rb
|
822
|
-
- vendor/dynomite/lib/dynomite/migration/dsl/local_secondary_index.rb
|
823
|
-
- vendor/dynomite/lib/dynomite/migration/executor.rb
|
824
|
-
- vendor/dynomite/lib/dynomite/migration/generator.rb
|
825
|
-
- vendor/dynomite/lib/dynomite/migration/templates/create_table.rb
|
826
|
-
- vendor/dynomite/lib/dynomite/migration/templates/update_table.rb
|
827
|
-
- vendor/dynomite/lib/dynomite/version.rb
|
828
|
-
- vendor/dynomite/pkg/dynomite-1.0.8.gem
|
829
|
-
- vendor/dynomite/pkg/dynomite-1.0.9.gem
|
830
|
-
- vendor/dynomite/pkg/dynomite-1.1.0.gem
|
831
|
-
- vendor/dynomite/spec/fixtures/app_root/config/dynamodb.yml
|
832
|
-
- vendor/dynomite/spec/fixtures/dynamodb/migrate/20190108061826-comments_migration.rb
|
833
|
-
- vendor/dynomite/spec/lib/dynomite/item_spec.rb
|
834
|
-
- vendor/dynomite/spec/lib/dynomite/migration/dsl/global_secondary_index_spec.rb
|
835
|
-
- vendor/dynomite/spec/lib/dynomite/migration/dsl/local_secondary_index_spec.rb
|
836
|
-
- vendor/dynomite/spec/lib/dynomite/migration/dsl_spec.rb
|
837
|
-
- vendor/dynomite/spec/lib/dynomite/migration/generator_spec.rb
|
838
|
-
- vendor/dynomite/spec/lib/dynomite/migration_spec.rb
|
839
|
-
- vendor/dynomite/spec/spec_helper.rb
|
840
801
|
- vendor/jets-gems/Gemfile
|
841
802
|
- vendor/jets-gems/Gemfile.lock
|
842
803
|
- vendor/jets-gems/LICENSE.txt
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# Change Log
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
|
-
|
6
|
-
## [1.1.0]
|
7
|
-
- Merge pull request #5 from tongueroo/fix-index-creation
|
8
|
-
- fix index creation dsl among other things
|
9
|
-
|
10
|
-
## [1.0.9]
|
11
|
-
- allow item.replace(hash) to work
|
12
|
-
- Merge pull request #3 from mveer99/patch-1 Update comments: Fixed typo in project_name
|
13
|
-
|
14
|
-
## [1.0.8]
|
15
|
-
- scope endpoint option to dynamodb client only vs the entire Aws.config
|
16
|
-
|
17
|
-
## [1.0.7]
|
18
|
-
- update DYNOMITE_ENV var
|
19
|
-
|
20
|
-
## [1.0.6]
|
21
|
-
- rename to dynomite
|
22
|
-
|
23
|
-
## [1.0.5]
|
24
|
-
- fix jets dynamodb:migrate tip
|
25
|
-
|
26
|
-
## [1.0.4]
|
27
|
-
- Add and use log method instead of puts to write to stderr by default
|
28
|
-
|
29
|
-
## [1.0.3]
|
30
|
-
- rename APP_ROOT to JETS_ROOT
|
31
|
-
|
32
|
-
## [1.0.2]
|
33
|
-
- to_json for json rendering
|
34
|
-
|
35
|
-
## [1.0.1]
|
36
|
-
- Check dynamodb local is running when configured
|
37
|
-
|
38
|
-
## [1.0.0]
|
39
|
-
- LSI support
|
40
|
-
- automatically infer table_name
|
41
|
-
- automatically infer create_table and update_table migrations types
|
42
|
-
|
43
|
-
## [0.3.0]
|
44
|
-
- DSL methods now available: create_table, update_table
|
45
|
-
- Also can add GSI indexes within update_table with: i.gsi
|
data/vendor/dynomite/Gemfile
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
dynomite (1.1.0)
|
5
|
-
activesupport
|
6
|
-
aws-sdk-dynamodb
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activesupport (5.2.2)
|
12
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>= 0.7, < 2)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
aws-eventstream (1.0.1)
|
17
|
-
aws-partitions (1.129.0)
|
18
|
-
aws-sdk-core (3.44.2)
|
19
|
-
aws-eventstream (~> 1.0)
|
20
|
-
aws-partitions (~> 1.0)
|
21
|
-
aws-sigv4 (~> 1.0)
|
22
|
-
jmespath (~> 1.0)
|
23
|
-
aws-sdk-dynamodb (1.19.0)
|
24
|
-
aws-sdk-core (~> 3, >= 3.39.0)
|
25
|
-
aws-sigv4 (~> 1.0)
|
26
|
-
aws-sigv4 (1.0.3)
|
27
|
-
concurrent-ruby (1.1.4)
|
28
|
-
diff-lcs (1.3)
|
29
|
-
i18n (1.5.1)
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
jmespath (1.4.0)
|
32
|
-
minitest (5.11.3)
|
33
|
-
rake (12.3.2)
|
34
|
-
rspec (3.8.0)
|
35
|
-
rspec-core (~> 3.8.0)
|
36
|
-
rspec-expectations (~> 3.8.0)
|
37
|
-
rspec-mocks (~> 3.8.0)
|
38
|
-
rspec-core (3.8.0)
|
39
|
-
rspec-support (~> 3.8.0)
|
40
|
-
rspec-expectations (3.8.2)
|
41
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.8.0)
|
43
|
-
rspec-mocks (3.8.0)
|
44
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.8.0)
|
46
|
-
rspec-support (3.8.0)
|
47
|
-
thread_safe (0.3.6)
|
48
|
-
tzinfo (1.2.5)
|
49
|
-
thread_safe (~> 0.1)
|
50
|
-
|
51
|
-
PLATFORMS
|
52
|
-
ruby
|
53
|
-
|
54
|
-
DEPENDENCIES
|
55
|
-
bundler
|
56
|
-
dynomite!
|
57
|
-
rake
|
58
|
-
rspec
|
59
|
-
|
60
|
-
BUNDLED WITH
|
61
|
-
1.17.2
|
data/vendor/dynomite/README.md
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
# Dynomite
|
2
|
-
|
3
|
-
A simple wrapper library to make DynamoDB usage a little more friendly. The modeling is ActiveRecord-ish but not exactly because DynamoDB is a different type of database. Examples below explain it best:
|
4
|
-
|
5
|
-
## Examples
|
6
|
-
|
7
|
-
First define a class:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
class Post < Dynomite::Item
|
11
|
-
# partition_key "id" # optional, defaults to id
|
12
|
-
end
|
13
|
-
```
|
14
|
-
|
15
|
-
### Create
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
post = Post.new
|
19
|
-
post = post.replace(title: "test title")
|
20
|
-
post.attrs # {"id" => "generated-id", title" => "my title"}
|
21
|
-
```
|
22
|
-
|
23
|
-
`post.attrs[:id]` now contain a generated unique partition_key id. Usually the partition_key is 'id'. You can set your own unique id also by specifying id.
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
post = Post.new(id: "myid", title: "my title")
|
27
|
-
post.replace
|
28
|
-
post.attrs # {"id" => "myid", title" => "my title"}
|
29
|
-
```
|
30
|
-
|
31
|
-
Note that the replace method replaces the entire item, so you need to merge the attributes if you want to keep the other attributes. Know this is weird, but this is how DynamoDB works.
|
32
|
-
|
33
|
-
### Find
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
post = Post.find("myid")
|
37
|
-
post.attrs = post.attrs.deep_merge("desc": "my desc") # keeps title field
|
38
|
-
post.replace
|
39
|
-
post.attrs # {"id" => "myid", title" => "my title", desc: "my desc"}
|
40
|
-
```
|
41
|
-
|
42
|
-
The convenience `attrs` method performs a deep_merge:
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
post = Post.find("myid")
|
46
|
-
post.attrs("desc": "my desc 2") # <= does a deep_merge
|
47
|
-
post.replace
|
48
|
-
post.attrs # {"id" => "myid", title" => "my title", desc: "my desc 2"}
|
49
|
-
```
|
50
|
-
|
51
|
-
Note, a race condition edge case can exist when several concurrent replace
|
52
|
-
calls are happening. This is why the interface is called replace to
|
53
|
-
emphasize that possibility.
|
54
|
-
|
55
|
-
### Delete
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
resp = Post.delete("myid") # dynamodb client resp
|
59
|
-
# or
|
60
|
-
post = Post.find("myid")
|
61
|
-
resp = post.delete # dynamodb client resp
|
62
|
-
```
|
63
|
-
|
64
|
-
### Scan
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
options = {}
|
68
|
-
posts = Post.scan(options)
|
69
|
-
posts # Array of Post items. [Post.new, Post.new, ...]
|
70
|
-
```
|
71
|
-
|
72
|
-
### Query
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
posts = Post.query(
|
76
|
-
index_name: 'category-index',
|
77
|
-
expression_attribute_names: { "#category_name" => "category" },
|
78
|
-
expression_attribute_values: { ":category_value" => "Entertainment" },
|
79
|
-
key_condition_expression: "#category_name = :category_value",
|
80
|
-
)
|
81
|
-
posts # Array of Post items. [Post.new, Post.new, ...]
|
82
|
-
```
|
83
|
-
|
84
|
-
### Where
|
85
|
-
|
86
|
-
The where could be prettied up. Appreciate any pull requests.
|
87
|
-
|
88
|
-
```ruby
|
89
|
-
Post.where({category: "Drama"}, {index_name: "category-index"})
|
90
|
-
```
|
91
|
-
|
92
|
-
Examples are also in [item_spec.rb](spec/lib/dynomite/item_spec.rb).
|
93
|
-
|
94
|
-
## Migration Support
|
95
|
-
|
96
|
-
Dynomite supports ActiveRecord-like migrations. Here's a short example:
|
97
|
-
|
98
|
-
```ruby
|
99
|
-
class CreateCommentsMigration < Dynomite::Migration
|
100
|
-
def up
|
101
|
-
create_table :comments do |t|
|
102
|
-
t.partition_key "post_id:string" # required
|
103
|
-
t.sort_key "created_at:string" # optional
|
104
|
-
t.provisioned_throughput(5) # sets both read and write, defaults to 5 when not set
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
```
|
109
|
-
|
110
|
-
More examples are in the [docs/migrations](docs/migrations) folder.
|
111
|
-
|
112
|
-
## Installation
|
113
|
-
|
114
|
-
Add this line to your application's Gemfile:
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
gem 'dynomite'
|
118
|
-
```
|
119
|
-
|
120
|
-
And then execute:
|
121
|
-
|
122
|
-
$ bundle
|
123
|
-
|
124
|
-
Or install it yourself as:
|
125
|
-
|
126
|
-
$ gem install dynomite
|
127
|
-
|
128
|
-
## Development
|
129
|
-
|
130
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
131
|
-
|
132
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
133
|
-
|
134
|
-
## Contributing
|
135
|
-
|
136
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/tongueroo/dynomite.
|
137
|
-
|
138
|
-
### TODO
|
139
|
-
|
140
|
-
* improve Post.where. Something like `Post.index_name("user_id").where(category_name: "Entertainment")` would be nice.
|
141
|
-
* implement `post.update` with `db.update_item` in a Ruby-ish way
|
data/vendor/dynomite/Rakefile
DELETED
data/vendor/dynomite/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "dynomite"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/vendor/dynomite/bin/setup
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
# Note: table name created will be namespaced based on
|
2
|
-
# Dynomite::Migration.table_namespace. This can be set in
|
3
|
-
# config/dynamodb.yml
|
4
|
-
#
|
5
|
-
# development:
|
6
|
-
# table_namespace: "mynamespace"
|
7
|
-
#
|
8
|
-
# This results in:
|
9
|
-
# create_table "posts"
|
10
|
-
# Produces:
|
11
|
-
# table name: "mynamespace-posts"
|
12
|
-
#
|
13
|
-
# When you're in a in Jets project you can set the namespace based on
|
14
|
-
# Jets.config.table_namespace, which is based on the project name and
|
15
|
-
# a short version of the environment. Example:
|
16
|
-
#
|
17
|
-
# `config/dynamodb.yml`:
|
18
|
-
# development:
|
19
|
-
# table_namespace: <%= Jets.config.table_namespace %>
|
20
|
-
#
|
21
|
-
# If your project_name is demo and environment is production:
|
22
|
-
# create_table "posts" => table name: "demo-prod-posts"
|
23
|
-
#
|
24
|
-
# If your project_name is demo and environment is staging:
|
25
|
-
# create_table "posts" => table name: "demo-stag-posts"
|
26
|
-
#
|
27
|
-
# If your project_name is demo and environment is development:
|
28
|
-
# create_table "posts" => table name: "demo-dev-posts"
|
29
|
-
#
|
30
|
-
# If the table_namespace is set to a blank string or nil, then a namespace
|
31
|
-
# will not be prepended at all.
|
32
|
-
|
33
|
-
class CreateCommentsMigration < Dynomite::Migration
|
34
|
-
def up
|
35
|
-
create_table :comments do |t|
|
36
|
-
t.partition_key "post_id:string" # required
|
37
|
-
t.sort_key "created_at:string" # optional
|
38
|
-
t.provisioned_throughput(5) # sets both read and write, defaults to 5 when not set
|
39
|
-
|
40
|
-
# Instead of using partition_key and sort_key you can set the
|
41
|
-
# key schema directly also
|
42
|
-
# t.key_schema([
|
43
|
-
# {attribute_name: "id", :key_type=>"HASH"},
|
44
|
-
# {attribute_name: "created_at", :key_type=>"RANGE"}
|
45
|
-
# ])
|
46
|
-
# t.attribute_definitions([
|
47
|
-
# {attribute_name: "id", attribute_type: "N"},
|
48
|
-
# {attribute_name: "created_at", attribute_type: "S"}
|
49
|
-
# ])
|
50
|
-
|
51
|
-
# other ways to set provisioned_throughput
|
52
|
-
# t.provisioned_throughput(:read, 10)
|
53
|
-
# t.provisioned_throughput(:write, 10)
|
54
|
-
# t.provisioned_throughput(
|
55
|
-
# read_capacity_units: 5,
|
56
|
-
# write_capacity_units: 5
|
57
|
-
# )
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class UpdateCommentsMigration < Dynomite::Migration
|
63
|
-
def up
|
64
|
-
update_table :comments do |t|
|
65
|
-
|
66
|
-
# t.global_secondary_index do
|
67
|
-
# t.gsi(METHOD, INDEX_NAME) do
|
68
|
-
|
69
|
-
# You normally create an index like so:
|
70
|
-
#
|
71
|
-
# t.gsi(:create) do |i|
|
72
|
-
# i.partition_key = "post_id:string" # partition_key is required
|
73
|
-
# i.sort_key = "updated_at:string" # sort_key is optional
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# The index name will be inferred from the partition_key and sort_key when
|
77
|
-
# not explicitly set. Examples:
|
78
|
-
#
|
79
|
-
# index_name = "#{partition_key}-#{sort_key}-index"
|
80
|
-
# index_name = "post_id-index" # no sort key
|
81
|
-
# index_name = "post_id-updated_at-index" # has sort key
|
82
|
-
#
|
83
|
-
# The inference allows you to not have to worry about the index
|
84
|
-
# naming scheme. You can still set the index_name explicitly like so:
|
85
|
-
#
|
86
|
-
# t.gsi(:create, "post_id-updated_at-index") do |i|
|
87
|
-
# i.partition_key = "post_id:string" # partition_key is required
|
88
|
-
# i.sort_key = "updated_at:string" # sort_key is optional
|
89
|
-
# end
|
90
|
-
#
|
91
|
-
t.gsi(:create) do |i|
|
92
|
-
i.partition_key "post_id:string"
|
93
|
-
i.sort_key "updated_at:string" # optional
|
94
|
-
|
95
|
-
# translates to
|
96
|
-
# i.key_schema({...})
|
97
|
-
# also makes sure that the schema_keys are added to the attributes_definitions
|
98
|
-
|
99
|
-
# t.projected_attributes(:all) # default if not called
|
100
|
-
# t.projected_attributes(:keys_only) # other ways to call
|
101
|
-
# t.projected_attributes([:id, :body, :tags, :updated_at])
|
102
|
-
# translates to:
|
103
|
-
# Valid Values: ALL | KEYS_ONLY | INCLUDE
|
104
|
-
# t.projection(
|
105
|
-
# projection_type: :all, # defaults to all
|
106
|
-
# )
|
107
|
-
# t.projection(
|
108
|
-
# projection_type: :include, # defaults to all
|
109
|
-
# non_key_attributes: [:id, :body, :tags, :updated_at], # defaults to all
|
110
|
-
# )
|
111
|
-
|
112
|
-
i.provisioned_throughput(10)
|
113
|
-
end
|
114
|
-
|
115
|
-
t.gsi(:update, "category-index") do |i|
|
116
|
-
i.provisioned_throughput(10)
|
117
|
-
end
|
118
|
-
|
119
|
-
t.gsi(:delete, "category-index")
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|