redash_backup 0.1.2 → 0.2.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
  SHA256:
3
- metadata.gz: c8d3bca0628ca753fa535fc28d092e356afad31b6af555a1cf5c3fc9f81266aa
4
- data.tar.gz: 82d03079e01fcff6efe875e94498f9bee3a0e20a6db56371ae870784cdaeb663
3
+ metadata.gz: 9f36f9eeebbd9fa0be5a711cd32b0675c9ceaa279c8d69995969a60965138ce6
4
+ data.tar.gz: 6f44e27b0139dbfe55d63ed9a6139d77671d733abe074dfed9b6076b52181ca6
5
5
  SHA512:
6
- metadata.gz: 8f9cc4b37d8cd6ca1766ededa603e7afcaad8c24fcc5e97fd6e9a8feb79f53c55c119bae3864a4990add5fe0304dbfc1c8c108da4a510e14754ed45e362563e9
7
- data.tar.gz: 82bf693e88a6fe29229b1d7c02da7a17a50467acaa38c710819418523ecaa40b838beae0dfdd96efcd3687f71f7fa05acc4f6e3aa20399b189688c919004c44d
6
+ metadata.gz: 2935e1f86598239f8fc8d7a91a4d548835faa338bff76636d78b4514c49e81f95bce87482dbc59d762b33f7fbe64bc7498e27c0cfd82fe733430bee120ed0925
7
+ data.tar.gz: 0536d95831121e13a62a9deba8087a7f0a13127f48a0fc52fe6ef2bef5c0a55b4033bd71ed0789831103490d1a45437e0f7a80d2e8d44a6ce5d1d3b83592cc37
data/CHANGELOG.md CHANGED
@@ -2,4 +2,7 @@
2
2
  - init🐣
3
3
 
4
4
  # 0.1.2
5
- - export unused queries
5
+ - export unused queries
6
+
7
+ # 0.2.2
8
+ - add raketask
data/Gemfile CHANGED
@@ -4,9 +4,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in redash_backup.gemspec
6
6
  gemspec
7
-
8
- gem 'pg', '>= 0.18', '< 2.0'
9
-
7
+ gem 'pg'
10
8
  gem 'activerecord'
11
-
12
- gem 'fileutils', '~> 0.7.2'
9
+ gem 'fileutils'
data/Gemfile.lock CHANGED
@@ -1,62 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redash_backup (0.1.2)
5
- activerecord (~> 6.0.2.1)
6
- fileutils (~> 0.7.2)
7
- pg (~> 1.2.2)
4
+ redash_backup (0.2.0)
5
+ activerecord
6
+ fileutils
7
+ pg
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activemodel (6.0.2.1)
13
- activesupport (= 6.0.2.1)
14
- activerecord (6.0.2.1)
15
- activemodel (= 6.0.2.1)
16
- activesupport (= 6.0.2.1)
17
- activesupport (6.0.2.1)
12
+ activemodel (6.1.3)
13
+ activesupport (= 6.1.3)
14
+ activerecord (6.1.3)
15
+ activemodel (= 6.1.3)
16
+ activesupport (= 6.1.3)
17
+ activesupport (6.1.3)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (>= 0.7, < 2)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- zeitwerk (~> 2.2)
23
- concurrent-ruby (1.1.6)
24
- diff-lcs (1.3)
25
- fileutils (0.7.2)
26
- i18n (1.8.2)
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ tzinfo (~> 2.0)
22
+ zeitwerk (~> 2.3)
23
+ concurrent-ruby (1.1.8)
24
+ fileutils (1.5.0)
25
+ i18n (1.8.9)
27
26
  concurrent-ruby (~> 1.0)
28
- minitest (5.14.0)
29
- pg (1.2.2)
30
- rake (13.0.1)
31
- rspec (3.9.0)
32
- rspec-core (~> 3.9.0)
33
- rspec-expectations (~> 3.9.0)
34
- rspec-mocks (~> 3.9.0)
35
- rspec-core (3.9.1)
36
- rspec-support (~> 3.9.1)
37
- rspec-expectations (3.9.0)
38
- diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.9.0)
40
- rspec-mocks (3.9.1)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.9.0)
43
- rspec-support (3.9.2)
44
- thread_safe (0.3.6)
45
- tzinfo (1.2.6)
46
- thread_safe (~> 0.1)
47
- zeitwerk (2.2.2)
27
+ minitest (5.14.4)
28
+ pg (1.2.3)
29
+ tzinfo (2.0.4)
30
+ concurrent-ruby (~> 1.0)
31
+ zeitwerk (2.4.2)
48
32
 
49
33
  PLATFORMS
50
34
  ruby
35
+ x86_64-darwin-19
51
36
 
52
37
  DEPENDENCIES
53
38
  activerecord
54
- bundler (~> 1.17)
55
- fileutils (~> 0.7.2)
56
- pg (>= 0.18, < 2.0)
57
- rake (~> 13.0)
39
+ fileutils
40
+ pg
58
41
  redash_backup!
59
- rspec (~> 3.0)
60
42
 
61
43
  BUNDLED WITH
62
- 1.17.2
44
+ 2.2.9
data/README.md CHANGED
@@ -19,10 +19,31 @@ Or install it yourself as:
19
19
  $ gem install redash_backup
20
20
 
21
21
  ## Usage
22
+ ### With other than zsh
23
+ - YOUR_REDEDASH_DATABASE_URL is like postgres://username:password@host:port/db
22
24
 
25
+ ```sh
26
+ rake redash:backup[YOUR_REDEDASH_DATABASE_URL,EXPORT_DIR_NAME]
27
+ #
28
+ # export...
29
+ #
30
+ # ./queries/dashboard1/hoge.sql
31
+ # ./queries/dashboard1/page.sql
32
+ # ./queries/dashboard2/poko.sql
33
+ # ./queries/dashboard2/pako.sql
34
+ # ./queries/unused/maru.sql
35
+ # ./queries/unused/batu.sql
36
+ #
37
+ # ※ default export path: './queries'
38
+ # Can call without 'EXPORT DIR NAME'
39
+ # ex. rake redash:backup['YOUR REDEDASH DATABASE_URL']
23
40
  ```
24
- require 'redash_backup'
25
- RedashBackup.new('YOUR REDEDASH DATABASE_URL').execute('EXPORT DIR NAME')
41
+
42
+ ### With zsh
43
+
44
+ ```sh
45
+ ※ Surround with single quotes
46
+ rake 'redash:backup[YOUR_REDEDASH_DATABASE_URL,EXPORT_DIR_NAME]'
26
47
  #
27
48
  # export...
28
49
  #
@@ -35,4 +56,4 @@ Or install it yourself as:
35
56
  #
36
57
  # ※ default export path: './queries'
37
58
  #
38
- ```
59
+ ```
data/Rakefile CHANGED
@@ -1,6 +1,15 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "redash_backup"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ namespace :redash do
8
+ task :query_backup, [:db_url, :export_dir] do |task, args|
9
+ RedashBackup.new(args.db_url).execute(args.export_dir)
10
+ end
11
+
12
+ task :db_backup, [:db_url, :expoet_dir] do |task, args|
13
+ RedashBackup.new(args.db_url).db_dump(args.export_dir)
14
+ end
15
+ end
data/lib/redash_backup.rb CHANGED
@@ -7,7 +7,8 @@ class RedashBackup
7
7
  ENV['DATABASE_URL'] = database_url
8
8
  end
9
9
 
10
- def execute(dir = './queries')
10
+ def execute(dir = nil)
11
+ dir ||= './queries'
11
12
  RedashBackup::Base.export!(dir)
12
13
  end
13
14
 
@@ -11,31 +11,31 @@ class RedashBackup::Base
11
11
  def export
12
12
  FileUtils.rm_r(@dir) if Dir.exist? @dir
13
13
  Dir.mkdir(@dir)
14
- boards = Dashboard.active.all.find_each
15
- boards.each { |board| export_by_board!(board) }
14
+ Dashboard.active.all.find_each { |board| export_by_board!(board) }
16
15
  export_unused_queries!
17
16
  end
18
17
 
19
18
  private
20
19
 
21
20
  def export_by_board!(board)
22
- Dir.mkdir(@dir + '/' + board.name)
21
+ board_name = board.name.gsub('/', '_')
22
+ Dir.mkdir(@dir + '/' + board_name)
23
23
  board.widgets.each do |widget|
24
24
  query = widget.visualization&.query
25
25
  next unless query
26
26
 
27
27
  text = <<~TEXT
28
- -- #{board.name}
28
+ -- #{board_name}
29
29
  -- #{query.name}
30
30
  -- #{Time.now.strftime('%Y/%m/%d %H:%M')}
31
31
 
32
32
  #{query.query}
33
33
  TEXT
34
- File.open(@dir + "/#{board.name}/#{query.name.gsub('/', '_')}.sql", 'w') do |file|
34
+ File.open(@dir + "/#{board_name}/#{query.name.gsub('/', '_')}.sql", 'w') do |file|
35
35
  file.puts text
36
36
  end
37
37
  end
38
- puts "Completed export to #{@dir}/#{board.name}/*.sql"
38
+ puts "Completed export to #{@dir}/#{board_name}/*.sql"
39
39
  end
40
40
 
41
41
  # unused: queries not attach to dashboard
@@ -1,3 +1,3 @@
1
1
  class RedashBackup
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Tashiro"]
10
10
  spec.email = ["g4160hc@gmail.com"]
11
11
 
12
- spec.summary = 'Simple Redash\'s query backup tool'
12
+ spec.summary = 'Simple tool for Redash\'s query backup'
13
13
  spec.description = 'cli for back up redash queries'
14
14
  spec.homepage = 'https://github.com/tashirosota/ruby-redash_backup'
15
15
  spec.license = "MIT"
@@ -33,11 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.bindir = "exe"
34
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
35
  spec.require_paths = ["lib"]
36
- spec.add_dependency "activerecord", "~> 6.0.2.1"
37
- spec.add_dependency "pg", "~> 1.2.2"
38
- spec.add_dependency 'fileutils', '~> 0.7.2'
39
-
40
- spec.add_development_dependency "bundler", "~> 1.17"
41
- spec.add_development_dependency "rake", "~> 13.0"
42
- spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_dependency "pg"
37
+ spec.add_dependency "activerecord"
38
+ spec.add_dependency "fileutils"
43
39
  end
metadata CHANGED
@@ -1,99 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redash_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tashiro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activerecord
14
+ name: pg
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.2.1
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.2.1
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pg
28
+ name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.2
33
+ version: '0'
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: 1.2.2
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fileutils
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.2
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.7.2
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.17'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.17'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '13.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '13.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
52
+ - - ">="
95
53
  - !ruby/object:Gem::Version
96
- version: '3.0'
54
+ version: '0'
97
55
  description: cli for back up redash queries
98
56
  email:
99
57
  - g4160hc@gmail.com
@@ -103,7 +61,6 @@ extra_rdoc_files: []
103
61
  files:
104
62
  - ".gitignore"
105
63
  - ".rspec"
106
- - ".travis.yml"
107
64
  - CHANGELOG.md
108
65
  - CODE_OF_CONDUCT.md
109
66
  - Gemfile
@@ -125,7 +82,7 @@ metadata:
125
82
  homepage_uri: https://github.com/tashirosota/ruby-redash_backup
126
83
  source_code_uri: https://github.com/tashirosota/ruby-redash_backup
127
84
  changelog_uri: https://github.com/tashirosota/ruby-redash_backup/blob/master/CHANGELOG.md
128
- post_install_message:
85
+ post_install_message:
129
86
  rdoc_options: []
130
87
  require_paths:
131
88
  - lib
@@ -140,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
97
  - !ruby/object:Gem::Version
141
98
  version: '0'
142
99
  requirements: []
143
- rubygems_version: 3.0.1
144
- signing_key:
100
+ rubygems_version: 3.1.2
101
+ signing_key:
145
102
  specification_version: 4
146
- summary: Simple Redash's query backup tool
103
+ summary: Simple tool for Redash's query backup
147
104
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.0
7
- before_install: gem install bundler -v 1.17.2