dynamodb-ruby 0.4.0 → 0.5.0

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: 9b99cc1d64a32fc529e155f1dc3ebf5367f36d13
4
- data.tar.gz: 1c435fa098709a27bee35d7eda5c5d12ce1d2afa
3
+ metadata.gz: c257312be4a3b3beb1872f2dbd95b302cc07a5e4
4
+ data.tar.gz: e6ae659246529009d91a8b53df17b557d0e4c628
5
5
  SHA512:
6
- metadata.gz: 42a4cc5f59362040562152601450dfde6ce465e3a0977ee97b729d8a5ecabcd8deaebdc997e928857c4fd37d4053dd6f7cffdbd6ed8acfee66c7a2b07c7ef354
7
- data.tar.gz: ee33d3746e1bb0644014efbcda93a1d2e4e8bd3ff8870f23df7c61af8568dab9324472a244b70df526a293ec71dc695ddc3b9cc4b886c85cbeda32631b725ce3
6
+ metadata.gz: 7cd1c9e747783f8cad8b6c53df6281b8fabc1ded9641ec7504a41fc5c2c2a7002f7ce27800c6c62fee753ed1c0f24ffba3ac5df97bc19dfe840808df00bcacd0
7
+ data.tar.gz: af53e9164e0d03f08eec079229378e534cce3ad09d4b7a3726e5ce2c6b1151c2f226ca922e492c532224ced578767dcc588917c1646eddc618309c190bf22ce8
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency "activesupport", "~> 5.0"
34
34
  spec.add_dependency "aws-sdk-dynamodb", "~> 1"
35
+ spec.add_dependency "thor"
35
36
 
36
37
  spec.add_development_dependency "bundler", "~> 1.15"
37
38
  spec.add_development_dependency "rake", "~> 10.0"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "dynamodb/cli"
4
+ Dynamodb::CLI.start
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dynamodb/version"
4
3
  require "dynamodb/configuration"
5
4
  require "dynamodb/connection"
6
5
  require "dynamodb/table_actions"
6
+ require "dynamodb/version"
7
7
 
8
8
  module Dynamodb
9
9
  extend Connection
@@ -0,0 +1,121 @@
1
+ require "thor"
2
+
3
+ module Dynamodb
4
+ class CLI < Thor
5
+ DIST_DIR = "vendor/DynamoDBLocal-latest"
6
+ PIDFILE = "dynamodb.pid"
7
+ PORT = 8000
8
+ LOG_DIR = "logs"
9
+
10
+ desc "start", "Starts Dynamodb Local"
11
+ method_option :dist_dir, aliases: "-dd"
12
+ method_option :pidfile, aliases: "-pf"
13
+ method_option :port, aliases: "-p"
14
+ method_option :log_dir, aliases: "-ld"
15
+ def start
16
+ %x(
17
+ if [ -z $JAVA_HOME ]; then
18
+ echo >&2 'ERROR: DynamoDBLocal requires JAVA_HOME to be set.'
19
+ fi
20
+ )
21
+
22
+ %x(
23
+ if [ ! -x $JAVA_HOME/bin/java ]; then
24
+ echo >&2 'ERROR: JAVA_HOME is set, but I do not see the java executable there.'
25
+ exit 1
26
+ fi
27
+ )
28
+
29
+ dist_dir = options[:dist_dir] || DIST_DIR
30
+ `cd #{dist_dir}`
31
+
32
+ %x(
33
+ if [ ! -f DynamoDBLocal.jar ] || [ ! -d DynamoDBLocal_lib ]; then
34
+ echo >&2 "ERROR: Could not find DynamoDBLocal files in #{dist_dir}."
35
+ exit 1
36
+ fi
37
+ )
38
+
39
+ log_dir = options[:log_dir] || LOG_DIR
40
+ `mkdir -p #{log_dir}`
41
+
42
+ puts "DynamoDB Local output will save to #{dist_dir}/#{log_dir}/"
43
+
44
+ port = options[:port] || PORT
45
+ `hash lsof 2>/dev/null && lsof -i :#{port} && { echo >&2 "Something is already listening on port #{port}; I will not attempt to start DynamoDBLocal."; exit 1; }`
46
+
47
+ `nohup $JAVA_HOME/bin/java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -delayTransientStatuses -port #{port} -inMemory 1>"#{log_dir}/output.log" 2>"#{log_dir}/error.log" &`
48
+ `PID=$!`
49
+
50
+ puts "Verifying that DynamoDBLocal actually started..."
51
+
52
+ # Allow some seconds for the JDK to start and die.
53
+ %x(
54
+ counter=0
55
+ while [ $counter -le 5 ]; do
56
+ kill -0 $PID
57
+ if [ $? -ne 0 ]; then
58
+ echo >&2 'ERROR: DynamoDBLocal died after we tried to start it!'
59
+ exit 1
60
+ else
61
+ counter=$(($counter + 1))
62
+ sleep 1
63
+ fi
64
+ done
65
+ )
66
+
67
+ puts "DynamoDB Local started with pid #{`$PID`} listening on port #{port}."
68
+
69
+ pidfile = options[:pidfile] || PIDFILE
70
+ puts `$PID > #{pidfile}`
71
+ end
72
+
73
+ desc "stop", "Stops Dynamodb Local"
74
+ method_option :dist_dir, aliases: "-dd"
75
+ method_option :pidfile, aliases: "-pf"
76
+ method_option :port, aliases: "-p"
77
+ method_option :log_dir, aliases: "-ld"
78
+ def stop
79
+ dist_dir = options[:dist_dir] || DIST_DIR
80
+ `cd #{dist_dir}`
81
+
82
+ pidfile = options[:pidfile] || PIDFILE
83
+ %x(
84
+ if [ ! -f #{pidfile} ]; then
85
+ echo 'ERROR: There is no pidfile, below is the list of DynamoDBLocal processes you may need to kill.'
86
+ ps -e | grep DynamoDBLocal | grep -v grep
87
+ exit 1
88
+ fi
89
+ )
90
+
91
+ `pid=$(<#{pidfile})`
92
+
93
+ `echo "Killing DynamoDBLocal at pid $pid..."`
94
+ `kill $pid`
95
+
96
+ %x(
97
+ counter=0
98
+ while [ $counter -le 5 ]; do
99
+ kill -0 $pid 2>/dev/null
100
+ if [ $? -ne 0 ]; then
101
+ echo 'Successfully shut down DynamoDBLocal.'
102
+ rm -f #{pidfile}
103
+ exit 0
104
+ else
105
+ echo 'Still waiting for DynamoDBLocal to shut down...'
106
+ counter=$(($counter + 1))
107
+ sleep 1
108
+ fi
109
+ done
110
+ )
111
+
112
+ puts "Unable to shut down DynamoDBLocal; below is the list of DynamoDBLocal processes you may need to kill."
113
+
114
+ `ps -e | grep DynamoDBLocal | grep -v grep`
115
+
116
+ `rm -f #{pidfile}`
117
+
118
+ `exit 1`
119
+ end
120
+ end
121
+ end
@@ -1,3 +1,3 @@
1
1
  module Dynamodb
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Farrow
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +112,8 @@ description: A small ORM wrapper to make working with AWS Dynamodb easier. Inclu
98
112
  Test helpers.
99
113
  email:
100
114
  - sfarrow@bandsintown.com
101
- executables: []
115
+ executables:
116
+ - dynamodb
102
117
  extensions: []
103
118
  extra_rdoc_files: []
104
119
  files:
@@ -114,9 +129,11 @@ files:
114
129
  - bin/setup
115
130
  - dynamodb-ruby-0.1.0.gem
116
131
  - dynamodb-ruby.gemspec
132
+ - exe/dynamodb
117
133
  - lib/dynamodb.rb
118
134
  - lib/dynamodb/attribute_assignment.rb
119
135
  - lib/dynamodb/base.rb
136
+ - lib/dynamodb/cli.rb
120
137
  - lib/dynamodb/configuration.rb
121
138
  - lib/dynamodb/connection.rb
122
139
  - lib/dynamodb/local.rb