gazer 0.2.14 → 0.2.15

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: eeaa05d460f0e4a1d8f78f6627a54f679e6c4a80
4
- data.tar.gz: 154addb6106b2cb5fa81048478e35a2798e97488
3
+ metadata.gz: 4f1519e5c9690bd1028b3f899c281502a5d7746c
4
+ data.tar.gz: 673d9a3e988c95521fedf378ee276834d4d8345d
5
5
  SHA512:
6
- metadata.gz: da4ae7a8d0636c30ee76ab4a5caee34b6843f4e7a77390f394307d7823d1962e994ec3915944d22e2480df1faf3111a1014324d2d60706cccaff78c66b30dc24
7
- data.tar.gz: 5b2f42b86876a1a37f9186284d652d5d13667948b70f7c5e75024b9a782c1cbe146c305264292f81ad587e63c67cafaba098fc6ccfba95aad7d6258f68ac6b04
6
+ metadata.gz: d4fd5dc05483d6cfd4e38bfb5cfa2b12b808db121ae8dc83855caeb29c40f58fbf232b94c7d26ed413864acde333224d540f33fb5100e3cba9ae56157c42a55f
7
+ data.tar.gz: fc06b562eecf5daf51072c253dba790459dab3aecf9531969a4993fdfc2ba688894d87ce4684f40f00abbe75a2eaf1ad9e92ff150a3cd5d4fd8e0d933bf2defb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.14)
4
+ gazer (0.2.15)
5
5
  looker-sdk (~> 0.0.6)
6
6
  netrc (~> 0.11.0)
7
7
  pastel (~> 0.7.2)
@@ -90,24 +90,32 @@ module Gzr
90
90
  end
91
91
 
92
92
  def sync_dashboard(source,target_space_id)
93
- slug_used = search_dashboards_by_slug(source[:slug]).fetch(0,nil) if source[:slug]
94
- title_used = search_dashboards_by_title(source[:title], target_space_id).fetch(0,nil)
93
+ # try to find dashboard by slug in target space
95
94
  existing_dashboard = search_dashboards_by_slug(source[:slug], target_space_id).fetch(0,nil) if source[:slug]
96
- if existing_dashboard then
97
- title_used = false if title_used && title_used.id == existing_dashboard.id
98
- else
99
- existing_dashboard = title_used
100
- title_used = false
101
- end
102
- slug_used = false if existing_dashboard && slug_used && slug_used.id == existing_dashboard.id
95
+ # check for dash of same title in target space
96
+ title_used = search_dashboards_by_title(source[:title], target_space_id).fetch(0,nil)
97
+
98
+ # If there is no match by slug in target space or no slug given, then we match by title
99
+ existing_dashboard ||= title_used
100
+
101
+ # same_title is now a flag indicating that there is already a dash in the same space with
102
+ # that title, and it is the one we are updating.
103
+ same_title = (title_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
104
+
105
+ # check if the slug is used by any dashboard
106
+ slug_used = search_dashboards_by_slug(source[:slug]).fetch(0,nil) if source[:slug]
107
+
108
+ # same_slug is now a flag indicating that there is already a dash with
109
+ # that slug, but it is the one we are updating.
110
+ same_slug = (slug_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
103
111
 
104
- if slug_used then
112
+ if slug_used && !same_slug then
105
113
  say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}"
106
114
  say_warning "dashboard will be imported with new slug"
107
115
  end
108
116
 
109
117
  if existing_dashboard then
110
- if title_used then
118
+ if title_used && !same_title then
111
119
  raise Gzr::CLI::Error, "Dashboard #{source[:title]} already exists in space #{target_space_id}\nDelete it before trying to upate another dashboard to have that title."
112
120
  end
113
121
  if @options[:force] then
@@ -115,10 +123,10 @@ module Gzr
115
123
  new_dash = source.select do |k,v|
116
124
  (keys_to_keep('update_dashboard') - [:space_id,:user_id,:slug]).include? k
117
125
  end
118
- new_dash[:slug] = source[:slug] unless slug_used
126
+ new_dash[:slug] = source[:slug] unless slug_used && !same_slug
119
127
  return update_dashboard(existing_dashboard.id,new_dash)
120
128
  else
121
- raise Gzr::CLI::Error, "Dashboard #{source[:title]} already exists in space #{target_space_id}\nUse --force if you want to overwrite it"
129
+ raise Gzr::CLI::Error, "Dashboard #{existing_dashboard[:title]} with slug #{existing_dashboard[:slug]} already exists in space #{target_space_id}\nUse --force if you want to overwrite it"
122
130
  end
123
131
  else
124
132
  new_dash = source.select do |k,v|
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = "0.2.14"
23
+ VERSION = "0.2.15"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader