rbdash 0.2.0 → 0.2.1

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: d0032fd88d5487c15247c31d98ae4883afbd0379
4
- data.tar.gz: e5ad4dab9923fc3d2d0479e7c62d4b9d5eca362d
3
+ metadata.gz: 7bd45279cad296b0dc993904fa6bfc2ee3cf5089
4
+ data.tar.gz: 2db662d897905f8bc1949191c3e759b937905706
5
5
  SHA512:
6
- metadata.gz: c645b8f82347177df23f5fb563f8da5b1fb080b58f83207453c3fcec1756a524f3b13f92d09304c284c6670fca4228ed3ec9bf83cd4821cd5fa605bf48b8746e
7
- data.tar.gz: 8c767ed9ce5873cd2bbeca816cfc23ce66edb7c20630c5bcc130fcfe0e02ae62c507f62e440720aedf64096a62f6067527376ce6d24f35fd3a79e36284d2361d
6
+ metadata.gz: 2aa862983c38f4af37dda8abab348bcca917b3dd2ea4a7caf8991ee6242d196310a16b582bd5de296bd94f83e4f5cef19434f5cfff1ac84185ecdfd552af6649
7
+ data.tar.gz: 9c140bb5f4c5cce93e7b57c82662c7b0106be23b5736ae16e9f7ad819993ddfa83bdbdea5684dfd6f9d27566efe8c25f67d5320fa04da7c44c86f02340110962
data/.gitignore CHANGED
@@ -9,7 +9,7 @@
9
9
  /tmp/
10
10
 
11
11
  queries
12
- config.yml
12
+ .rbdash.yml
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
- NOTE: work in progress. :construction_worker:
2
1
 
3
2
  # Rbdash
4
3
 
5
- 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/rbdash`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+ Rbdash is a configuration management CLI tool for [Redash](https://redash.io/).
6
5
 
7
- TODO: Delete this and the text above, and describe your gem
6
+ NOTE: work in progress. :construction_worker:
8
7
 
9
8
  ## Installation
10
9
 
@@ -24,7 +23,30 @@ Or install it yourself as:
24
23
 
25
24
  ## Usage
26
25
 
27
- TODO: Write usage instructions here
26
+
27
+ #### setup
28
+
29
+ ```sh
30
+ $ rbdash init
31
+ create config_test.yml
32
+ Type your redash server uri: https://example.redash.com
33
+ Type your redash API token: xxxxxxxxxxxxxxxx
34
+ ```
35
+
36
+ #### fetch remote configurations
37
+
38
+ ```sh
39
+ $ rbdash pull
40
+ # create queries/query-1.json
41
+ # create queries/query-2.json
42
+ # ...
43
+ ```
44
+
45
+ #### push configs to remote
46
+
47
+ ```
48
+ $ rbdash push <id>
49
+ ```
28
50
 
29
51
  ## Development
30
52
 
@@ -34,4 +56,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
56
 
35
57
  ## Contributing
36
58
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rbdash.
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shotat/rbdash.
@@ -6,7 +6,7 @@ module Rbdash
6
6
 
7
7
  desc 'init', 'create a configuration file.'
8
8
  def init
9
- create_file 'config.yml' do
9
+ create_file '.rbdash.yml' do
10
10
  base_uri = ask('Type your redash server uri:')
11
11
  token = ask('Type your redash API token:')
12
12
  "base_uri: #{base_uri}\ntoken: #{token}"
@@ -14,17 +14,23 @@ module Rbdash
14
14
  end
15
15
 
16
16
  desc 'pull', 'pulls existing configurations.'
17
+ method_option 'dry-run'
17
18
  def pull
18
19
  CLI::Pull.new.run
19
20
  end
20
21
 
22
+ desc 'push <id1> <id2> ...', 'push configurations'
21
23
  method_option 'dry-run'
22
- desc 'push <id>', 'push configurations'
23
- def push(id)
24
- CLI::Push.new.run(id)
24
+ def push(*ids)
25
+ if options['dry-run']
26
+ CLI::Push.new.dry_run(*ids)
27
+ return
28
+ end
29
+ CLI::Push.new.run(*ids)
25
30
  end
26
31
 
27
32
  desc 'push_all', 'push all configurations'
33
+ method_option 'dry-run'
28
34
  def push_all
29
35
  CLI::PushAll.new.run
30
36
  end
@@ -1,8 +1,34 @@
1
+ require 'diffy'
1
2
  module Rbdash
2
3
  class CLI::Push
3
- def run(id)
4
+
5
+ def run(*ids)
6
+ ids.each do |id|
7
+ show_diff(id)
8
+ update(id)
9
+ end
10
+ end
11
+
12
+ def dry_run(*ids)
13
+ ids.each do |id|
14
+ show_diff(id)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def update(id)
4
21
  Rbdash::Models::Query.update(id)
5
- puts 'complete!'
22
+ end
23
+
24
+ def show_diff(id)
25
+ remote_state = Rbdash::Models::Query.find(id)
26
+ local_state = Rbdash::Models::Query.load(id)
27
+ puts Diffy::Diff.new(remote_state.to_json, local_state.to_json, diff_opt).to_s(:color)
28
+ end
29
+
30
+ def diff_opt
31
+ { include_diff_info: true, context: 2 }
6
32
  end
7
33
  end
8
34
  end
@@ -8,7 +8,8 @@ module Rbdash
8
8
  # debug_output $stdout
9
9
 
10
10
  def initialize
11
- config = YAML.load_file('./config.yml')
11
+ conf_file = './.rbdash.yml'
12
+ config = YAML.load_file(conf_file)
12
13
  self.class.base_uri(config['base_uri'])
13
14
  @default_options = {
14
15
  verify: false,
@@ -1,3 +1,3 @@
1
1
  module Rbdash
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ gem_name='rbdash'
3
+ version=$(grep VERSION lib/rbdash/version.rb | grep -Eo '\d+\.\d+.\d+')
4
+ rake build
5
+ gem install "pkg/${gem_name}-${version}.gem"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbdash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shotat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -124,7 +124,6 @@ files:
124
124
  - Rakefile
125
125
  - bin/console
126
126
  - bin/setup
127
- - config.sample.yml
128
127
  - exe/rbdash
129
128
  - lib/rbdash.rb
130
129
  - lib/rbdash/cli.rb
@@ -135,6 +134,7 @@ files:
135
134
  - lib/rbdash/models/query.rb
136
135
  - lib/rbdash/request.rb
137
136
  - lib/rbdash/version.rb
137
+ - local_install.sh
138
138
  - rbdash.gemspec
139
139
  homepage: https://github.com/shotat/rbdash
140
140
  licenses: []
@@ -1,2 +0,0 @@
1
- base_uri: 'example.com'
2
- token: 'xxxxxxxxxxxxxxxxxxxxxxxxxx'