aurora-data-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.rake_tasks~ +10 -0
  3. data/.standard.yml +6 -0
  4. data/CHANGELOG.md +3 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +15 -0
  7. data/Gemfile.lock +103 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +236 -0
  10. data/Rakefile +18 -0
  11. data/Steepfile +5 -0
  12. data/aurora-data-api.gemspec +34 -0
  13. data/example/.gitignore +58 -0
  14. data/example/.ruby-version +1 -0
  15. data/example/Dockerfile +26 -0
  16. data/example/Gemfile +9 -0
  17. data/example/Gemfile.lock +48 -0
  18. data/example/README.md +45 -0
  19. data/example/Rakefile +48 -0
  20. data/example/app/depots/comment_depot.rb +6 -0
  21. data/example/app/depots/entry_depot.rb +6 -0
  22. data/example/app/depots/user_depot.rb +6 -0
  23. data/example/app/handlers/main.rb +86 -0
  24. data/example/app/models/comment.rb +10 -0
  25. data/example/app/models/entry.rb +12 -0
  26. data/example/app/models/user.rb +13 -0
  27. data/example/compose.yml +43 -0
  28. data/example/db/.gitignore +2 -0
  29. data/example/db/.keep +0 -0
  30. data/example/package-lock.json +4740 -0
  31. data/example/package.json +17 -0
  32. data/example/serverless.yml +184 -0
  33. data/exe/aurora-data-api +161 -0
  34. data/lib/aurora-data-api/data_service.rb +42 -0
  35. data/lib/aurora-data-api/depot.rb +132 -0
  36. data/lib/aurora-data-api/environment.rb +41 -0
  37. data/lib/aurora-data-api/model.rb +152 -0
  38. data/lib/aurora-data-api/version.rb +5 -0
  39. data/lib/aurora-data-api.rb +14 -0
  40. data/sig/aurora-data-api.rbs +20 -0
  41. data/sig/data_service.rbs +7 -0
  42. data/sig/depot.rbs +23 -0
  43. data/sig/environment.rbs +13 -0
  44. data/sig/model.rbs +39 -0
  45. data/sig/version.rbs +3 -0
  46. metadata +120 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 344043ce8593c877dc10b721e2b1724ea96265ed5411fbef7828a7c670a3d40e
4
+ data.tar.gz: b3b440e30ef5b87abb26d987c8a35951cdb5e4c135181fc20ef9d59142a1f625
5
+ SHA512:
6
+ metadata.gz: dd445671cf4c71684bcc20f24e0eea75d82218dd6959d338cc87e6faafd59a02644fd95fa31e8310645b2796114ea3d541ffd4fa71eb92c81846fd775fcba56e
7
+ data.tar.gz: dcdcf6717773ed3bc9921193eddac358496fc19aa90a4e4b7e3ba41c87096ecdc932e69fdd968f37b269e06e6a3ccf0812f755e87e79ee24af167bb65766cbea
data/.rake_tasks~ ADDED
@@ -0,0 +1,10 @@
1
+ build
2
+ build:checksum
3
+ clean
4
+ clobber
5
+ install
6
+ install:local
7
+ release[remote]
8
+ standard
9
+ standard:fix
10
+ test
data/.standard.yml ADDED
@@ -0,0 +1,6 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.7
4
+
5
+ ignore:
6
+ - 'example/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 - 2022-05-31
2
+
3
+ - Initial release (experimental)
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hasumikin@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in aurora-data-api.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "test-unit", "~> 3.0"
11
+ gem "test-unit-rr"
12
+
13
+ gem "standard", "~> 1.3"
14
+
15
+ gem "steep"
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aurora-data-api (0.1.0)
5
+ aws-sdk-rdsdataservice (~> 1.35.0)
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (7.0.3)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ ast (2.4.2)
17
+ aws-eventstream (1.2.0)
18
+ aws-partitions (1.591.0)
19
+ aws-sdk-core (3.131.1)
20
+ aws-eventstream (~> 1, >= 1.0.2)
21
+ aws-partitions (~> 1, >= 1.525.0)
22
+ aws-sigv4 (~> 1.1)
23
+ jmespath (~> 1, >= 1.6.1)
24
+ aws-sdk-rdsdataservice (1.35.0)
25
+ aws-sdk-core (~> 3, >= 3.127.0)
26
+ aws-sigv4 (~> 1.1)
27
+ aws-sigv4 (1.5.0)
28
+ aws-eventstream (~> 1, >= 1.0.2)
29
+ concurrent-ruby (1.1.10)
30
+ ffi (1.15.5)
31
+ i18n (1.10.0)
32
+ concurrent-ruby (~> 1.0)
33
+ jmespath (1.6.1)
34
+ language_server-protocol (3.16.0.3)
35
+ listen (3.7.1)
36
+ rb-fsevent (~> 0.10, >= 0.10.3)
37
+ rb-inotify (~> 0.9, >= 0.9.10)
38
+ minitest (5.15.0)
39
+ parallel (1.22.1)
40
+ parser (3.1.2.0)
41
+ ast (~> 2.4.1)
42
+ power_assert (2.0.1)
43
+ rainbow (3.1.1)
44
+ rake (13.0.6)
45
+ rb-fsevent (0.11.1)
46
+ rb-inotify (0.10.1)
47
+ ffi (~> 1.0)
48
+ rbs (2.5.0)
49
+ regexp_parser (2.4.0)
50
+ rexml (3.2.5)
51
+ rr (3.0.9)
52
+ rubocop (1.29.1)
53
+ parallel (~> 1.10)
54
+ parser (>= 3.1.0.0)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8, < 3.0)
57
+ rexml (>= 3.2.5, < 4.0)
58
+ rubocop-ast (>= 1.17.0, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 3.0)
61
+ rubocop-ast (1.18.0)
62
+ parser (>= 3.1.1.0)
63
+ rubocop-performance (1.13.3)
64
+ rubocop (>= 1.7.0, < 2.0)
65
+ rubocop-ast (>= 0.4.0)
66
+ ruby-progressbar (1.11.0)
67
+ standard (1.12.1)
68
+ rubocop (= 1.29.1)
69
+ rubocop-performance (= 1.13.3)
70
+ steep (1.0.0)
71
+ activesupport (>= 5.1)
72
+ language_server-protocol (>= 3.15, < 4.0)
73
+ listen (~> 3.0)
74
+ parallel (>= 1.0.0)
75
+ parser (>= 3.0)
76
+ rainbow (>= 2.2.2, < 4.0)
77
+ rbs (>= 2.3.2)
78
+ terminal-table (>= 2, < 4)
79
+ terminal-table (3.0.2)
80
+ unicode-display_width (>= 1.1.1, < 3)
81
+ test-unit (3.5.3)
82
+ power_assert
83
+ test-unit-rr (1.0.5)
84
+ rr (>= 1.1.1)
85
+ test-unit (>= 2.5.2)
86
+ thor (1.2.1)
87
+ tzinfo (2.0.4)
88
+ concurrent-ruby (~> 1.0)
89
+ unicode-display_width (2.1.0)
90
+
91
+ PLATFORMS
92
+ x86_64-linux
93
+
94
+ DEPENDENCIES
95
+ aurora-data-api!
96
+ rake (~> 13.0)
97
+ standard (~> 1.3)
98
+ steep
99
+ test-unit (~> 3.0)
100
+ test-unit-rr
101
+
102
+ BUNDLED WITH
103
+ 2.3.14
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 HASUMI Hitoshi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # AuroraDataApi [![Ruby](https://github.com/hasumikin/aurora-data-api/actions/workflows/main.yml/badge.svg)](https://github.com/hasumikin/aurora-data-api/actions/workflows/main.yml)
2
+
3
+ A kind of ORM for Amazon Aurora Serverless v1.
4
+
5
+ Supposing that you are using Ruby (typically on AWS Lambda) as an application, Aurora Serverless v1 (NOT v2) as a database, and Data API as the database adapter.
6
+
7
+ PostgreSQL is the only target as of now.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'aurora-data-api'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install aurora-data-api
24
+
25
+ ## Usage
26
+
27
+ Let's say we're developing a blog that has three models:
28
+
29
+ - User: able to post an entry and to comment on any entry
30
+ - Entry: an article
31
+ - Comment: a comment on an entry
32
+
33
+ ```ruby
34
+ class User < AuroraDataApi::Model
35
+ schema do
36
+ col :name, String
37
+ col :internet_account, String
38
+ timestamp # Creates :created_at and :updated_at
39
+ end
40
+
41
+ def twitter
42
+ "https://twitter.com/#{internet_account}"
43
+ end
44
+ end
45
+
46
+ class Entry < AuroraDataApi::Model
47
+ schema do
48
+ col :user, :User # User.to_sym
49
+ col :title, String
50
+ col :body, String
51
+ timestamp
52
+ end
53
+ end
54
+
55
+ class Comment < AuroraDataApi::Model
56
+ schema do
57
+ col :user, :User # User.to_sym
58
+ col :entry, :Entry, table: :entries #...(*)
59
+ col :body, String
60
+ timestamp
61
+ end
62
+ end
63
+
64
+ # (*)
65
+ # The plural of "entry" is too difficult for aurora-data-api.
66
+ # So you need to explicitly tell gem the table name.
67
+ ```
68
+
69
+
70
+ ```ruby
71
+ require_relative '../models/user'
72
+ UserDepot = AuroraDataApi::Depot[User] do
73
+ end
74
+
75
+ require_relative '../models/entry'
76
+ EntryDepot = AuroraDataApi::Depot[Entry] do
77
+ end
78
+
79
+ require_relative '../models/comment'
80
+ CommentDepot = AuroraDataApi::Depot[Comment] do
81
+ end
82
+ ```
83
+
84
+ ### Insert a user
85
+
86
+ ```ruby
87
+ user = User.new(name: "HASUMI Hitoshi", internet_account: "hasumikin")
88
+ user.id # => nil
89
+ UserDepot.insert(user) # => 1
90
+ user.id # => 1
91
+ ```
92
+
93
+ ### Update the user
94
+
95
+ ```ruby
96
+ user.internet_account = "HASUMIKIN"
97
+ UserDepot.update(user) # => true (false if failed)
98
+ user.internet_account # => "HASUMIKIN"
99
+ ```
100
+
101
+ ### Delete the user
102
+
103
+ ```ruby
104
+ UserDepot.delete(user) # => true (false if failed)
105
+ user.id # => nil
106
+ ```
107
+
108
+ ### Find a user
109
+
110
+ ```ruby
111
+ hasumikin = UserDepot.select(
112
+ "WHERE internet_account = :internet_account",
113
+ internet_account: "hasumikin"
114
+ ).first
115
+ ```
116
+
117
+ ### Post an entry
118
+
119
+ ```ruby
120
+ my_entry = Entry.new(
121
+ user: hasumikin,
122
+ title: "My first article",
123
+ body: "Hey, this is an article about Ruby."
124
+ )
125
+ EntryDepot.insert(my_entry)
126
+ ```
127
+
128
+ ### Update the entry
129
+
130
+ ```ruby
131
+ my_entry.body = "Hey, this is an article about Ruby whick is a happy language!"
132
+ EntryDepot.update(my_entry)
133
+ ```
134
+
135
+ ### Delete the entry
136
+
137
+ ```ruby
138
+ EntryDepot.delete(my_entry)
139
+ ```
140
+
141
+ ### Count comments
142
+
143
+ ```ruby
144
+ count = CommentDepot.count(
145
+ "WHERE entry_id = :entry_id",
146
+ entry_id: my_entry.id
147
+ )
148
+ ```
149
+
150
+ ### Select comments
151
+
152
+ ```ruby
153
+ comments = CommentDepot.select(<<~SQL, user_id: hasumikin.id)
154
+ INNER JOIN ENTRY ON entry.id = comment.entry_id
155
+ WHERE entry.user_id = :user_id
156
+ ORDER BY comment.created_at
157
+ LIMIT 10 OFFSET 0
158
+ SQL
159
+ comments.class # => Array
160
+ comments.first.class # => Comment
161
+ comments.first.body # => "I have a question, ..."
162
+ comments.first.entry.class # => Entry
163
+ comments.first.entry.title # => "My first article"
164
+ comments.first.entry.user.name # => "HASUMI Hitoshi"
165
+ ```
166
+
167
+ As of the current version, the last call `comments.first.entry.user.name` will execute another query so it may cause an N+1 problem.
168
+
169
+ ## Typical application structure
170
+
171
+ ```sh
172
+ your_app
173
+ ├── Gemfile # It includes `gem 'aurora-data-api'`
174
+ ├── app
175
+ │ ├── handlers # You may have Lambda functions here
176
+ │ ├── models
177
+ │ │ ├── comment.rb
178
+ │ │ ├── entry.rb
179
+ │ │ └── user.rb
180
+ │ └── depots
181
+ │ ├── comment_depot.rb
182
+ │ ├── entry_depot.rb
183
+ │ └── user_depot.rb
184
+ ├── db
185
+ │ └── shcema.sql
186
+ └── serverless.yml # aurora-data-api is perfect for Serverless Framework
187
+ ```
188
+
189
+ aurora-data-api doesn't have a generator to initiate the structure.
190
+ Make it manually instead like:
191
+
192
+ ```sh
193
+ mkdir -p app/models app/depots db
194
+ ```
195
+
196
+ ## Migration
197
+
198
+ The following command overwrites `db/schema.sql` (for only PostgreSQL) by aggregating `app/models/*.rb`
199
+
200
+ ```sh
201
+ bundle exec aurora-data-api export
202
+ ```
203
+
204
+ We recommend to use @k0kubun's sqldef to manage migration.
205
+
206
+ See [k0kubun/sqldef](https://github.com/k0kubun/sqldef)
207
+
208
+ ## Environment variables
209
+
210
+ The following variables should be defined:
211
+
212
+ ```ruby
213
+ ENV['PGDATABASE'] # Database name
214
+ ENV['RDS_RESOURCE_ARN'] # Resource ARN of RDS Aurora Serverless
215
+ ENV['RDS_SECRET_ARN'] # Secret ARN that is stored in AWS Secrets Manager
216
+ ```
217
+
218
+ RDS_SECRET_ARN has to be attached to an IAM role of the "application".
219
+
220
+ ## Development
221
+
222
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
223
+
224
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
225
+
226
+ ## Contributing
227
+
228
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hasumikin/aurora-data-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hasumikin/aurora-data-api/blob/master/CODE_OF_CONDUCT.md).
229
+
230
+ ## License
231
+
232
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
233
+
234
+ ## Code of Conduct
235
+
236
+ Everyone interacting in the AuroraDataApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hasumikin/aurora-data-api/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: %i[test steep standard]
15
+
16
+ task :steep do
17
+ sh "bundle exec steep check"
18
+ end
data/Steepfile ADDED
@@ -0,0 +1,5 @@
1
+ target :lib do
2
+ signature "sig"
3
+ check "lib"
4
+ library "time"
5
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/aurora-data-api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "aurora-data-api"
7
+ spec.version = AuroraDataApi::VERSION
8
+ spec.authors = ["HASUMI Hitoshi"]
9
+ spec.email = ["hasumikin@gmail.com"]
10
+
11
+ spec.summary = "A kind of ORM for Amazon Aurora Serverless v1"
12
+ spec.description = "Assuming you are using AWS Lambda as a backend, Aurora Serverless v1 (NOT v2) as a database, and Data API as an adapter"
13
+ spec.homepage = "https://github.com/hasumikin/aurora-data-api"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/hasumikin/aurora-data-api"
19
+ spec.metadata["changelog_uri"] = "https://github.com/hasumikin/aurora-data-api/blob/master/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "aws-sdk-rdsdataservice", "~> 1.35.0"
33
+ spec.add_dependency "thor"
34
+ end
@@ -0,0 +1,58 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ .env.staging
15
+ .env.production
16
+
17
+ ## Specific to RubyMotion:
18
+ .dat*
19
+ .repl_history
20
+ build/
21
+ *.bridgesupport
22
+ build-iPhoneOS/
23
+ build-iPhoneSimulator/
24
+
25
+ ## Specific to RubyMotion (use of CocoaPods):
26
+ #
27
+ # We recommend against adding the Pods directory to your .gitignore. However
28
+ # you should judge for yourself, the pros and cons are mentioned at:
29
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
30
+ #
31
+ # vendor/Pods/
32
+
33
+ ## Documentation cache and generated files:
34
+ /.yardoc/
35
+ /_yardoc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ # Serverless directories
53
+ .serverless
54
+
55
+ # package directories
56
+ node_modules
57
+
58
+
@@ -0,0 +1 @@
1
+ 2.7.5
@@ -0,0 +1,26 @@
1
+ # syntax = docker/dockerfile:experimental
2
+
3
+ FROM lambci/lambda:build-ruby2.7
4
+
5
+ RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - \
6
+ && yum -y install nodejs postgresql wget && yum -y clean all
7
+
8
+ RUN mkdir /home/ec2-user && chown ec2-user /home/ec2-user
9
+ RUN mkdir /home/ec2-user/bin && chown ec2-user /home/ec2-user/bin
10
+ RUN mkdir /app && chown ec2-user /app
11
+
12
+ WORKDIR /app
13
+ COPY --chown=ec2-user Gemfile Gemfile.lock package.json package-lock.json /app/
14
+ RUN gem install bundler
15
+ RUN bundle install
16
+
17
+ COPY --chown=ec2-user . /app
18
+
19
+ USER ec2-user
20
+ RUN npm install
21
+ RUN wget -O - https://github.com/k0kubun/sqldef/releases/latest/download/psqldef_linux_amd64.tar.gz \
22
+ | tar xvz -C /home/ec2-user/bin
23
+
24
+ EXPOSE 4000
25
+ CMD ["/bin/bash"]
26
+
data/example/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'aurora-data-api', github: 'hasumikin/aurora-data-api'
4
+ gem 'aws-sdk-lambda'
5
+
6
+ group :test, :development do
7
+ gem 'rake'
8
+ gem 'test-unit-rr'
9
+ end