dyna 0.1.8 → 0.1.9

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: e9a4fd21f8722b9dd15010855a735ce3654a7367
4
- data.tar.gz: '0139bc8b1a21d8297db048c82dcae35f270e33ae'
3
+ metadata.gz: bf7e0af4635d19cc04464734c752ec8f68032ea3
4
+ data.tar.gz: 68e76221165d0268c622001e07190ca753894c81
5
5
  SHA512:
6
- metadata.gz: 2a90044411ff9c1dca04650e365c29e0be5d84e56b7d31cd0f2923286766c147b1885d3e1169bc0d7248f5556f0c142292e17b35c9d9c74e3add6c7b2d788c18
7
- data.tar.gz: 79a66929725e50978f204df808da497c15db070ee36eb8102c23c823a8d307ae600b200385d921ea20b40754208d0dbbe6ea068270140f321cc7dd9ff55bee11
6
+ metadata.gz: 9940c92ee88b999d0a9a5a8ba7f745b4d9afd900773fdd7b512c85d289318dbbd81877c4217e569a7ee2b697dabcb0c61d9ac2be45c67cc3ff464dc01def0914
7
+ data.tar.gz: 0a2aee89b5f14f22171dfd4a43b9235d9143af4b39b44e66023b0137b53037874b57d89975d70ec9f7864c74ed440f17d5108dbc706c023d5e02b2924a055e0b
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Dyna
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dyna`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Dyna is a tool to manage DynamoDB Table.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ It defines the state of DynamoDB Table using DSL, and updates DynamoDB Table according to DSL.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,20 +22,89 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ```sh
26
+ export AWS_ACCESS_KEY_ID='...'
27
+ export AWS_SECRET_ACCESS_KEY='...'
28
+ export AWS_REGION='ap-northeast-1'
29
+ dyna -e -o Dynafile # export DynamoDB Table
30
+ vi Dynafile
31
+ dyna -a --dry-run
32
+ dyna -a # apply `Dyanfile` to DynamoDB
33
+ ```
26
34
 
27
- ## Development
35
+ ## Help
28
36
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+ ```
38
+ Usage: dyna [options]
39
+ -p, --profile PROFILE_NAME
40
+ --credentials-path PATH
41
+ -k, --access-key ACCESS_KEY
42
+ -s, --secret-key SECRET_KEY
43
+ -r, --region REGION
44
+ -a, --apply
45
+ -f, --file FILE
46
+ -n, --table_names TABLE_LIST
47
+ -x, --exclude_table_names TABLE_LIST
48
+ --dry-run
49
+ -e, --export
50
+ -o, --output FILE
51
+ --split
52
+ --no-color
53
+ --debug
54
+ ```
30
55
 
31
- 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).
56
+ ## Dynafile example
32
57
 
33
- ## Contributing
58
+ ```ruby
59
+ require 'other/dynafile'
60
+
61
+ dynamo_db "ap-northeast-1" do
62
+ table "test_table" do
63
+ key_schema(
64
+ hash: "ForumName",
65
+ range: "Subject"
66
+ )
67
+
68
+ attribute_definition(
69
+ attribute_name: "ForumName",
70
+ attribute_type: "S",
71
+ )
72
+ attribute_definition(
73
+ attribute_name: "Subject",
74
+ attribute_type: "S",
75
+ )
76
+
77
+ provisioned_throughput(
78
+ read_capacity_units: 1,
79
+ write_capacity_units: 2,
80
+ )
81
+
82
+ local_secondary_index "LocalIndexName" do
83
+ key_schema hash: "ForumName", range: "Subject"
84
+ projection projection_type: "ALL"
85
+ end
86
+
87
+ global_secondary_index "GlobalIndexName" do
88
+ key_schema hash: "ForumName", range: "Subject"
89
+ projection projection_type: "ALL"
90
+ provisioned_throughput read_capacity_units: 1, write_capacity_units: 2
91
+ end
92
+
93
+ stream_specification(
94
+ stream_enabled: true,
95
+ stream_view_type: "NEW_AND_OLD_IMAGES",
96
+ )
97
+ end
98
+ ```
99
+
100
+ ## Similar tools
34
101
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dyna.
102
+ * [Codenize.tools](http://codenize.tools/)
36
103
 
104
+ ## Contributing
105
+
106
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wata-gh/dyna.
37
107
 
38
108
  ## License
39
109
 
40
110
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
data/bin/dyna CHANGED
@@ -44,21 +44,26 @@ ARGV.options do |opt|
44
44
  opt.on('-k', '--access-key ACCESS_KEY') {|v| access_key = v }
45
45
  opt.on('-s', '--secret-key SECRET_KEY') {|v| secret_key = v }
46
46
  opt.on('-r', '--region REGION') {|v| region = v }
47
- opt.on('-a', '--apply') {|v| mode = :apply }
47
+ opt.on('-l', '--use-local') { options[:use_local] = true }
48
+ opt.on('-a', '--apply') { mode = :apply }
48
49
  opt.on('-f', '--file FILE') {|v| file = v }
49
50
  opt.on('', '--table_names TABLE_NAMES', Array) {|v| options[:table_names] = v }
50
51
  opt.on('', '--exclude_table_names TABLE_NAMES', Array) {|v| options[:exclude_table_names] = v }
51
- opt.on('', '--dry-run') {|v| options[:dry_run] = true }
52
- opt.on('-e', '--export') {|v| mode = :export}
52
+ opt.on('', '--dry-run') { options[:dry_run] = true }
53
+ opt.on('-e', '--export') { mode = :export}
53
54
  opt.on('-o', '--output FILE') {|v| output_file = v }
54
- opt.on('', '--split') {|v| split = true }
55
- opt.on('', '--split-more') {|v| split = :more }
55
+ opt.on('', '--split') { split = true }
56
+ opt.on('', '--split-more') { split = :more }
56
57
  opt.on('' , '--no-color') { options[:color] = false }
57
58
  opt.on('' , '--debug') { options[:debug] = true }
58
59
  opt.parse!
59
60
 
60
61
  aws_opts = {}
61
- if access_key and secret_key
62
+ if options[:use_local]
63
+ options[:access_key_id] = access_key if access_key
64
+ options[:secret_access_key] = secret_key if secret_key
65
+ options[:region] = region if region
66
+ elsif access_key and secret_key
62
67
  aws_opts = {
63
68
  :access_key_id => access_key,
64
69
  :secret_access_key => secret_key,
data/lib/dyna/client.rb CHANGED
@@ -6,7 +6,16 @@ module Dyna
6
6
  def initialize(options = {})
7
7
  @options = OpenStruct.new(options)
8
8
  @options_hash = options
9
- @options.ddb = Aws::DynamoDB::Client.new
9
+ if @options.use_local
10
+ @options.ddb = Aws::DynamoDB::Client.new(
11
+ endpoint: @options.dynamo_endpoint || 'http://127.0.0.1:8000',
12
+ region: @options.region || 'ap-northeast-1',
13
+ access_key_id: @options.access_key_id || 'dummy',
14
+ secret_access_key: @options.secret_access_key || 'dummy',
15
+ )
16
+ else
17
+ @options.ddb = Aws::DynamoDB::Client.new
18
+ end
10
19
  end
11
20
 
12
21
  def apply(file)
data/lib/dyna/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dyna
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - wata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk