dinamo 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5a87623eec736f4ade9d8159b6266f582f6f1c6
4
- data.tar.gz: 13601000c2defa1cd05be25af741688989988bc4
3
+ metadata.gz: d9cd6b373ec5452b1dd8376a579372d5b006f926
4
+ data.tar.gz: d4a31a837890869dde716495d151307c2b5e8fdc
5
5
  SHA512:
6
- metadata.gz: 531d04b7abe01ae2ae4242a7d39e21213a90c012ed91231c189a6a8defd601d43d311564736c621b67a24cb04ae89317137165842a4b433114d341eeac9cef3b
7
- data.tar.gz: d79cfc37a67d1e1a7e43caff2cb3393d67998bff8cb71d14c27ed6f55d117374f0a147d2678713f556f8c8a6413a855698d1d06ba51dd6b4934e9cfbe64e4e8e
6
+ metadata.gz: 6d4af004b40517092c57f65ff2515245433e197e72020739880a2a344f137bfd16f248094a3931e599aaae548113f50af3867b21f1b2586f665912db559c231d
7
+ data.tar.gz: 5c5596eaa98c31d66c08215c4a8bfe7e1eab5aa1999c1ada8cdefc26022978e61a2c7dc5b05613db578adefe6efc81d616a9b82c1547136a0be893606f952adf
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.3
3
+ - 2.2.5
4
+ - 2.3.1
4
5
  before_install: gem install bundler -v 1.10.6
5
6
  install:
6
7
  - mkdir /tmp/dynamodb
7
- - wget -O - http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest | tar xz --directory /tmp/dynamodb
8
+ - wget -O - https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/dynamodb_local_latest.tar.gz | tar xz --directory /tmp/dynamodb
8
9
  before_script:
9
10
  - java -Djava.library.path=/tmp/dynamodb/DynamoDBLocal_lib -jar /tmp/dynamodb/DynamoDBLocal.jar -sharedDb -inMemory &
10
11
  - sleep 2
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Dinamo
2
2
 
3
- Dinamo is an simple ORM for Amazon DynamoDB for Ruby applications.
3
+ [![build status](https://img.shields.io/travis/namusyaka/dinamo.svg?style=flat-square)](http://travis-ci.org/namusyaka/dinamo)
4
+ [![gem](https://img.shields.io/gem/v/dinamo.svg?style=flat-square)](https://rubygems.org/gems/dinamo)
5
+ [![license](https://img.shields.io/github/license/namusyaka/dinamo.svg?style=flat-square)](https://github.com/namusyaka/dinamo/blob/master/LICENSE.txt)
6
+
7
+ Dinamo is an ORM for [Dynamo DB](https://aws.amazon.com/dynamodb/), it has followed the behavior of the ORM which is often seen in the Ruby culture.
4
8
 
5
9
  ## Installation
6
10
 
@@ -18,27 +22,68 @@ Or install it yourself as:
18
22
 
19
23
  $ gem install dinamo
20
24
 
21
- ## Usage
25
+ ## Overview
22
26
 
23
- ### Sample
27
+ Dinamo makes it easy to create DynamoDB record from any ruby object. Also, dinamo supports for [data types of Dynamo DB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html) such as scaler types, document types and set types. This means things that you can declare their types on your model.
24
28
 
25
- Your class must inherit `Dinamo::Model` in every Dinamo model.
29
+ Of course, you can use validations, casting and model change tracking smoothly.
30
+ Next section will describe their things with example code.
31
+
32
+ ## Usage
33
+
34
+ ### Model definition
26
35
 
27
36
  ```ruby
28
37
  class User < Dinamo::Model
29
- hash_key :id, type: :number
30
- range_key :kind, type: :string
31
- field :name, type: :string
38
+ hash_key :name, type: :string
39
+ field :age, type: :number
40
+ end
41
+ ```
42
+
43
+ ### Building/Saving
44
+
45
+ ```ruby
46
+ user = User.new(name: 'numb', age: 24)
47
+ user.persisted? #=> false
48
+ user.save
49
+ user.persisted? #=> true
50
+ ```
51
+
52
+ Or you can use `create`.
53
+
54
+ ```ruby
55
+ user = User.create(name: 'numb', age: 24)
56
+ user.persisted? #=> true
57
+ ```
58
+
59
+ ### Dirty (model change tracking)
60
+
61
+ ```ruby
62
+ user = User.new(name: 'numb', age: 24)
63
+ user.changed? #=> false
64
+ user.age = 25
65
+ user.changed? #=> true
66
+ user.save
67
+ user.changed? #=> false
68
+ ```
69
+
70
+ ### Validation
71
+
72
+ ```ruby
73
+ class NameLengthValidator < Dinamo::Model::Validation::Validator
74
+ def validate(record)
75
+ unless options[:length].include?(record.name.length)
76
+ record.errors.add(:name, I18n.t("models.user.error.length"))
77
+ end
78
+ end
32
79
  end
33
80
 
34
- user = User.new
35
- user.id = 1
36
- user.kind = "developer"
37
- user.name = "namusyaka"
81
+ class User < Dinamo::Model
82
+ hash_key :id
83
+ field :name, type: :string
38
84
 
39
- user.valid? #=> true
40
- user.errors #=> {}
41
- user.save #=> true
85
+ validates_with NameLengthValidator, length: 1..30
86
+ end
42
87
  ```
43
88
 
44
89
  ## Contributing
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "activesupport", "~> 5.0.0"
23
- spec.add_dependency "aws-sdk", "~> 2.1.26"
23
+ spec.add_dependency "aws-sdk-core", "~> 3"
24
+ spec.add_dependency "aws-sdk-dynamodb", "~> 1.2"
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.10"
26
27
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,5 +1,5 @@
1
1
  require 'dinamo/exceptions'
2
- require 'aws-sdk'
2
+ require 'aws-sdk-dynamodb'
3
3
 
4
4
  module Dinamo
5
5
  class Adapter
@@ -1,3 +1,3 @@
1
1
  module Dinamo
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dinamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - namusyaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,19 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: aws-sdk
28
+ name: aws-sdk-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.26
33
+ version: '3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.26
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aws-sdk-dynamodb
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -165,4 +179,3 @@ signing_key:
165
179
  specification_version: 4
166
180
  summary: DynamoDB ORM for Ruby
167
181
  test_files: []
168
- has_rdoc: