gazer 0.2.44 → 0.2.46

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: 5aed8be2fa20e23f9e4530234e4399cce98836b154a3c56948af3a7d00ff9afa
4
- data.tar.gz: d9feaa5c0f5e28d519a667307e6118641cae9f5f1906acf35cceb5451ca16d7c
3
+ metadata.gz: 1111e80913b3cdb2b0649e59b963a0d656f19b84e6ccb523f20609f70d9dd068
4
+ data.tar.gz: 4733f9a2ac19d708b91e5729e3b7a588344f63a8726dfb776444ac3ec297d9ad
5
5
  SHA512:
6
- metadata.gz: 21900cfacd545b341c4a0a63d2622f63dc8333f408dfec46414490a0385b694d9b03afff886dff3962db67350d249134560d771e1e6e62f05f2a899ebf5bd9b3
7
- data.tar.gz: 6bed0237902824a24cf01062c62e986d77288380f273fe450397aa5ab5b3bf81344aa326feb9821c34ef0b25aa8749c637a5a84cc4a42c25a37050aeaa9bfe0f
6
+ metadata.gz: b296ce9ecb25983851508cda708c8ad2ded39834a63d2d4f1c00ce924311268fb6ce990ee9c4c2fd37d715dbe208472ceb1866539d456a585a09720305d584c2
7
+ data.tar.gz: cb29a1df8bf6e02bc061c99ba33cb1746805b66d46edc777589c2112a5d7db837b953033c53a5547605216063aa3b0119a23f644b2f4e38ce1fc66452ffb48af
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.3
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.5.8
5
+ before_install: gem install bundler -v 1.17.3
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,35 +1,35 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Code of Conduct
2
2
 
3
3
  ## Our Pledge
4
4
 
5
5
  In the interest of fostering an open and welcoming environment, we as
6
6
  contributors and maintainers pledge to making participation in our project and
7
7
  our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
8
+ size, disability, ethnicity, gender identity and expression, level of
9
+ experience, education, socio-economic status, nationality, personal appearance,
10
+ race, religion, or sexual identity and orientation.
11
11
 
12
12
  ## Our Standards
13
13
 
14
14
  Examples of behavior that contributes to creating a positive environment
15
15
  include:
16
16
 
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
22
 
23
23
  Examples of unacceptable behavior by participants include:
24
24
 
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
33
 
34
34
  ## Our Responsibilities
35
35
 
@@ -37,11 +37,11 @@ Project maintainers are responsible for clarifying the standards of acceptable
37
37
  behavior and are expected to take appropriate and fair corrective action in
38
38
  response to any instances of unacceptable behavior.
39
39
 
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
40
+ Project maintainers have the right and responsibility to remove, edit, or reject
41
+ comments, commits, code, wiki edits, issues, and other contributions that are
42
+ not aligned to this Code of Conduct, or to ban temporarily or permanently any
43
+ contributor for other behaviors that they deem inappropriate, threatening,
44
+ offensive, or harmful.
45
45
 
46
46
  ## Scope
47
47
 
@@ -52,23 +52,42 @@ address, posting via an official social media account, or acting as an appointed
52
52
  representative at an online or offline event. Representation of a project may be
53
53
  further defined and clarified by project maintainers.
54
54
 
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at deangelo@looker.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
55
+ This Code of Conduct also applies outside the project spaces when the Project
56
+ Steward has a reasonable belief that an individual's behavior may have a
57
+ negative impact on the project or its community.
58
+
59
+ ## Conflict Resolution
60
+
61
+ We do not believe that all conflict is bad; healthy debate and disagreement
62
+ often yield positive results. However, it is never okay to be disrespectful or
63
+ to engage in behavior that violates the project’s code of conduct.
64
+
65
+ If you see someone violating the code of conduct, you are encouraged to address
66
+ the behavior directly with those involved. Many issues can be resolved quickly
67
+ and easily, and this gives people more control over the outcome of their
68
+ dispute. If you are unable to resolve the matter for any reason, or if the
69
+ behavior is threatening or harassing, report it. We are dedicated to providing
70
+ an environment where participants feel welcome and safe.
71
+
72
+ Reports should be directed to *Mike DeAngelo* drstrangelove@google.com, the
73
+ Project Steward(s) for *gzr*. It is the Project Steward’s duty to
74
+ receive and address reported violations of the code of conduct. They will then
75
+ work with a committee consisting of representatives from the Open Source
76
+ Programs Office and the Google Open Source Strategy team. If for any reason you
77
+ are uncomfortable reaching out to the Project Steward, please email
78
+ opensource@google.com.
79
+
80
+ We will investigate every complaint, but you may not receive a direct response.
81
+ We will use our discretion in determining when and how to follow up on reported
82
+ incidents, which may range from not taking action to permanent expulsion from
83
+ the project and project-sponsored spaces. We will notify the accused of the
84
+ report and provide them an opportunity to discuss it before any action is taken.
85
+ The identity of the reporter will be omitted from the details of the report
86
+ supplied to the accused. In potentially harmful situations, such as ongoing
87
+ harassment or threats to anyone's safety, we may take action without notice.
67
88
 
68
89
  ## Attribution
69
90
 
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
91
+ This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
92
+ available at
93
+ https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
data/CONTRIBUTING.md CHANGED
@@ -1,29 +1,29 @@
1
- ## How to contribute to Gazer
1
+ # How to Contribute
2
2
 
3
- Did you read the [code of conduct](https://github.com/looker-open-source/gzr/blob/master/CODE_OF_CONDUCT.md)?
3
+ We'd love to accept your patches and contributions to this project. There are
4
+ just a few small guidelines you need to follow.
4
5
 
5
- #### **Did you find a bug?**
6
+ ## Contributor License Agreement
6
7
 
7
- * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/looker-open-source/gzr/issues).
8
+ Contributions to this project must be accompanied by a Contributor License
9
+ Agreement (CLA). You (or your employer) retain the copyright to your
10
+ contribution; this simply gives us permission to use and redistribute your
11
+ contributions as part of the project. Head over to
12
+ <https://cla.developers.google.com/> to see your current agreements on file or
13
+ to sign a new one.
8
14
 
9
- * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/looker-open-source/gzr/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
15
+ You generally only need to submit a CLA once, so if you've already submitted one
16
+ (even if it was for a different project), you probably don't need to do it
17
+ again.
10
18
 
11
- #### **Did you write a patch that fixes a bug?**
19
+ ## Code Reviews
12
20
 
13
- * Open a new GitHub pull request with the patch.
21
+ All submissions, including submissions by project members, require review. We
22
+ use GitHub pull requests for this purpose. Consult
23
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
24
+ information on using pull requests.
14
25
 
15
- * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
26
+ ## Community Guidelines
16
27
 
17
- * Depending on the content of the patch, we may need to work out a legal agreement to clarify everyone's rights before the patch is accepted.
18
-
19
- #### **Do you intend to add a new feature or change an existing one?**
20
-
21
- * Again please open an issue in GitHub. Larger projects often segregate bugs from new features and enhancements, but we are still small enough that it is not an issue.
22
-
23
- #### **Do you have questions about the source code?**
24
-
25
- * Ask any question about how to use Gazer by contacting the [primary developer](mailto:deangelo+gzr@looker.com).
26
-
27
- Thanks! :heart: :heart: :heart:
28
-
29
- Gazer Team
28
+ This project follows
29
+ [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.44)
5
- looker-sdk (~> 0.0.7)
4
+ gazer (0.2.46)
5
+ looker-sdk (~> 0.1.1)
6
+ net-http-persistent (~> 4.0.1)
6
7
  netrc (~> 0.11.0)
7
8
  pastel (~> 0.7.2)
8
9
  rubyzip (~> 1.3.0)
@@ -14,18 +15,38 @@ PATH
14
15
  GEM
15
16
  remote: https://rubygems.org/
16
17
  specs:
17
- addressable (2.7.0)
18
+ addressable (2.8.0)
18
19
  public_suffix (>= 2.0.2, < 5.0)
20
+ connection_pool (2.2.5)
19
21
  diff-lcs (1.3)
20
22
  equatable (0.5.0)
21
- faraday (0.17.3)
23
+ faraday (1.8.0)
24
+ faraday-em_http (~> 1.0)
25
+ faraday-em_synchrony (~> 1.0)
26
+ faraday-excon (~> 1.1)
27
+ faraday-httpclient (~> 1.0.1)
28
+ faraday-net_http (~> 1.0)
29
+ faraday-net_http_persistent (~> 1.1)
30
+ faraday-patron (~> 1.0)
31
+ faraday-rack (~> 1.0)
22
32
  multipart-post (>= 1.2, < 3)
33
+ ruby2_keywords (>= 0.0.4)
34
+ faraday-em_http (1.0.0)
35
+ faraday-em_synchrony (1.0.0)
36
+ faraday-excon (1.1.0)
37
+ faraday-httpclient (1.0.1)
38
+ faraday-net_http (1.0.1)
39
+ faraday-net_http_persistent (1.2.0)
40
+ faraday-patron (1.0.0)
41
+ faraday-rack (1.0.0)
23
42
  kramdown (1.16.2)
24
- looker-sdk (0.0.7)
25
- faraday (>= 0.9.0, < 1.0)
43
+ looker-sdk (0.1.1)
44
+ faraday (>= 1.2, < 2.0)
26
45
  sawyer (~> 0.8)
27
46
  multipart-post (2.1.1)
28
47
  necromancer (0.4.0)
48
+ net-http-persistent (4.0.1)
49
+ connection_pool (~> 2.2)
29
50
  netrc (0.11.0)
30
51
  pastel (0.7.2)
31
52
  equatable (~> 0.5.0)
@@ -33,19 +54,20 @@ GEM
33
54
  public_suffix (4.0.6)
34
55
  rake (12.3.3)
35
56
  rouge (3.1.1)
36
- rspec (3.9.0)
37
- rspec-core (~> 3.9.0)
38
- rspec-expectations (~> 3.9.0)
39
- rspec-mocks (~> 3.9.0)
40
- rspec-core (3.9.2)
41
- rspec-support (~> 3.9.3)
42
- rspec-expectations (3.9.2)
57
+ rspec (3.10.0)
58
+ rspec-core (~> 3.10.0)
59
+ rspec-expectations (~> 3.10.0)
60
+ rspec-mocks (~> 3.10.0)
61
+ rspec-core (3.10.1)
62
+ rspec-support (~> 3.10.0)
63
+ rspec-expectations (3.10.1)
43
64
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.9.0)
45
- rspec-mocks (3.9.1)
65
+ rspec-support (~> 3.10.0)
66
+ rspec-mocks (3.10.2)
46
67
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-support (3.9.3)
68
+ rspec-support (~> 3.10.0)
69
+ rspec-support (3.10.2)
70
+ ruby2_keywords (0.0.5)
49
71
  rubyzip (1.3.0)
50
72
  sawyer (0.8.2)
51
73
  addressable (>= 2.3.5)
@@ -56,7 +78,7 @@ GEM
56
78
  unicode_utils (~> 1.4)
57
79
  strings-ansi (0.2.0)
58
80
  thor (0.20.3)
59
- timers (4.3.2)
81
+ timers (4.3.3)
60
82
  tty (0.8.1)
61
83
  bundler (~> 1.16, < 2.0)
62
84
  equatable (~> 0.5.0)
@@ -129,7 +151,7 @@ GEM
129
151
  tty-screen (~> 0.6.4)
130
152
  tty-tree (0.1.0)
131
153
  tty-which (0.3.0)
132
- unicode-display_width (1.7.0)
154
+ unicode-display_width (1.8.0)
133
155
  unicode_utils (1.4.0)
134
156
  wisper (2.0.1)
135
157
 
data/gzr.gemspec CHANGED
@@ -59,7 +59,8 @@ Gem::Specification.new do |spec|
59
59
  spec.add_dependency "thor", "~> 0.20.0"
60
60
  spec.add_dependency 'netrc', "~> 0.11.0"
61
61
  spec.add_dependency 'rubyzip', "~> 1.3.0"
62
- spec.add_dependency 'looker-sdk', "~> 0.0.7"
62
+ spec.add_dependency 'looker-sdk', "~> 0.1.1"
63
+ spec.add_dependency 'net-http-persistent', '~> 4.0.1'
63
64
 
64
65
  spec.add_development_dependency "bundler", "~> 1.17"
65
66
  spec.add_development_dependency "rake", "~> 12.3.3"
data/lib/gzr/cli.rb CHANGED
@@ -41,6 +41,8 @@ module Gzr
41
41
  class_option :http_proxy, type: :string, desc: 'HTTP Proxy for connecting to Looker host'
42
42
  class_option :force, type: :boolean, default: false, desc: 'Overwrite objects on server'
43
43
  class_option :su, type: :string, desc: 'After connecting, change to user_id given'
44
+ class_option :width, type: :numeric, default: nil, desc: 'Width of rendering for tables'
45
+ class_option :persistent, type: :boolean, default: false, desc: 'Use persistent connection to communicate with host'
44
46
 
45
47
 
46
48
  # Error raised by this runner
@@ -62,7 +62,7 @@ module Gzr
62
62
  if @options[:csv] then
63
63
  output.puts render_csv(table)
64
64
  else
65
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
65
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
66
66
  end
67
67
  end if table
68
68
  end
@@ -61,7 +61,7 @@ module Gzr
61
61
  if @options[:csv] then
62
62
  output.puts render_csv(table)
63
63
  else
64
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
64
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
65
65
  end
66
66
  end if table
67
67
  end
@@ -61,7 +61,7 @@ module Gzr
61
61
  if @options[:csv] then
62
62
  output.puts render_csv(table)
63
63
  else
64
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: 1024)
64
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: 1024, width: @options[:width] || TTY::Screen.width)
65
65
  end
66
66
  end if table
67
67
  end
@@ -62,7 +62,7 @@ module Gzr
62
62
  if @options[:csv] then
63
63
  output.puts render_csv(table)
64
64
  else
65
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
65
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
66
66
  end
67
67
  end if table
68
68
  end
@@ -63,7 +63,7 @@ module Gzr
63
63
  if @options[:csv] then
64
64
  output.puts render_csv(table)
65
65
  else
66
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
66
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
67
67
  end
68
68
  end if table
69
69
  end
@@ -63,7 +63,7 @@ module Gzr
63
63
  if @options[:csv] then
64
64
  output.puts render_csv(table)
65
65
  else
66
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
66
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
67
67
  end
68
68
  end if table
69
69
  end
@@ -61,7 +61,7 @@ module Gzr
61
61
  if @options[:csv] then
62
62
  output.puts render_csv(table)
63
63
  else
64
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
64
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
65
65
  end
66
66
  end if table
67
67
  end
@@ -63,7 +63,7 @@ module Gzr
63
63
  if @options[:csv] then
64
64
  output.puts render_csv(table)
65
65
  else
66
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: 1024)
66
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: 1024, width: @options[:width] || TTY::Screen.width)
67
67
  end
68
68
  end if table
69
69
  end
@@ -87,7 +87,7 @@ module Gzr
87
87
  if @options[:csv] then
88
88
  output.puts render_csv(table)
89
89
  else
90
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
90
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width, width: @options[:width] || TTY::Screen.width)
91
91
  end
92
92
  end if table
93
93
  end
@@ -91,7 +91,7 @@ module Gzr
91
91
  if @options[:csv] then
92
92
  output.puts render_csv(table)
93
93
  else
94
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
94
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
95
95
  end
96
96
  end if table
97
97
  end
@@ -65,7 +65,7 @@ module Gzr
65
65
  if @options[:csv] then
66
66
  output.puts render_csv(table)
67
67
  else
68
- output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments)
68
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments, width: @options[:width] || TTY::Screen.width)
69
69
  end
70
70
  end if table
71
71
  end
@@ -64,7 +64,7 @@ module Gzr
64
64
  if @options[:csv] then
65
65
  output.puts render_csv(table)
66
66
  else
67
- output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments)
67
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments, width: @options[:width] || TTY::Screen.width)
68
68
  end
69
69
  end if table
70
70
  end
@@ -65,7 +65,7 @@ module Gzr
65
65
  if @options[:csv] then
66
66
  output.puts render_csv(table)
67
67
  else
68
- output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments)
68
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, multiline: true, alignments: alignments, width: @options[:width] || TTY::Screen.width)
69
69
  end
70
70
  end if table
71
71
  end
@@ -101,7 +101,7 @@ module Gzr
101
101
  if @options[:csv] then
102
102
  output.puts render_csv(table)
103
103
  else
104
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
104
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
105
105
  end
106
106
  end if table
107
107
  end
@@ -65,7 +65,7 @@ module Gzr
65
65
  if @options[:csv] then
66
66
  output.puts render_csv(table)
67
67
  else
68
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: [:right])
68
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: [:right], width: @options[:width] || TTY::Screen.width)
69
69
  end
70
70
  end if table
71
71
  end
@@ -71,7 +71,7 @@ module Gzr
71
71
  if @options[:csv] then
72
72
  output.puts render_csv(table)
73
73
  else
74
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
74
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
75
75
  end
76
76
  end if table
77
77
  end
@@ -55,7 +55,7 @@ module Gzr
55
55
  if @options[:csv] then
56
56
  output.puts render_csv(table)
57
57
  else
58
- output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
58
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
59
59
  end
60
60
  end if table
61
61
  end
@@ -46,13 +46,19 @@ module Gzr
46
46
  output.puts pastel.red data
47
47
  end
48
48
 
49
- def v3_1_available?
50
- @v3_1_available ||= false
49
+ @versions = []
50
+ @current_version = nil
51
+
52
+ def sufficient_version?(given_version, minimum_version)
53
+ return true unless (given_version && minimum_version)
54
+ versions = @versions.map {|v| v.version}.sort
55
+ !versions.drop_while {|v| v < minimum_version}.reverse.drop_while {|v| v > given_version}.empty?
51
56
  end
52
57
 
53
- def build_connection_hash(api_version='3.0')
58
+
59
+ def build_connection_hash(api_version=nil)
54
60
  conn_hash = Hash.new
55
- conn_hash[:api_endpoint] = "http#{@options[:ssl] ? "s" : ""}://#{@options[:host]}:#{@options[:port]}/api/#{api_version}"
61
+ conn_hash[:api_endpoint] = "http#{@options[:ssl] ? "s" : ""}://#{@options[:host]}:#{@options[:port]}/api/#{api_version||@current_version||""}"
56
62
  if @options[:http_proxy]
57
63
  conn_hash[:connection_options] ||= {}
58
64
  conn_hash[:connection_options][:proxy] = {
@@ -95,10 +101,16 @@ module Gzr
95
101
  conn_hash
96
102
  end
97
103
 
98
- def login(api_version)
104
+ def faraday_connection
105
+ @faraday_connection ||= Faraday.new { |conn|
106
+ if @options[:persistent]
107
+ conn.adapter :net_http_persistent
108
+ end
109
+ }
110
+ end
111
+
112
+ def login(min_api_version=nil)
99
113
  @secret = nil
100
- versions = nil
101
- current_version = nil
102
114
  begin
103
115
  conn_hash = build_connection_hash
104
116
 
@@ -119,8 +131,8 @@ module Gzr
119
131
 
120
132
  begin
121
133
  versions_response = agent.call(:get,"/versions")
122
- versions = versions_response.data.supported_versions
123
- current_version = versions_response.data.current_version
134
+ @versions = versions_response.data.supported_versions
135
+ @current_version = versions_response.data.current_version.version
124
136
  rescue Faraday::SSLError => e
125
137
  raise Gzr::CLI::Error, "SSL Certificate could not be verified\nDo you need the --no-verify-ssl option or the --no-ssl option?"
126
138
  rescue Faraday::ConnectionFailed => cf
@@ -128,23 +140,25 @@ module Gzr
128
140
  rescue LookerSDK::NotFound => nf
129
141
  say_warning "endpoint #{root}/versions was not found"
130
142
  end
131
- versions.each do |v|
132
- @v3_1_available = true if v.version == "3.1"
133
- end
134
143
  end
135
144
 
136
- say_warning "API 3.1 available? #{v3_1_available?}" if @options[:debug]
145
+ say_warning "API current_version #{@current_version}" if @options[:debug]
146
+ say_warning "API versions #{@versions.map{|v| v.version}}" if @options[:debug]
137
147
 
138
- raise Gzr::CLI::Error, "Operation requires API v3.1, but user specified a different version" if (api_version == "3.1") && @options[:api_version] && !("3.1" == @options[:api_version])
139
- raise Gzr::CLI::Error, "Operation requires API v3.1, which is not available from this host" if (api_version == "3.1") && !v3_1_available?
148
+ raise Gzr::CLI::Error, "Operation requires API v#{min_api_version}, but user specified version #{@options[:api_version]}" unless sufficient_version?(@options[:api_version],min_api_version)
140
149
 
141
- conn_hash = build_connection_hash(@options[:api_version] || current_version.version)
150
+ api_version = [min_api_version, @current_version].max
151
+ raise Gzr::CLI::Error, "Operation requires API v#{api_version}, which is not available from this host" if api_version && !@versions.any? {|v| v.version == api_version}
152
+ raise Gzr::CLI::Error, "User specified API v#{@options[:api_version]}, which is not available from this host" if @options[:api_version] && !@versions.any? {|v| v.version == @options[:api_version]}
153
+
154
+ conn_hash = build_connection_hash(@options[:api_version] || api_version)
142
155
  @secret = nil
143
156
 
144
157
  say_ok("connecting to #{conn_hash.map { |k,v| "#{k}=>#{(k == :client_secret) ? '*********' : v}" }}") if @options[:debug]
145
158
 
146
159
  begin
147
- @sdk = LookerSDK::Client.new(conn_hash) unless @sdk
160
+ @sdk = LookerSDK::Client.new(conn_hash.merge!(faraday: faraday_connection)) unless @sdk
161
+
148
162
  say_ok "check for connectivity: #{@sdk.alive?}" if @options[:debug]
149
163
  say_ok "verify authentication: #{@sdk.authenticated?}" if @options[:debug]
150
164
  rescue LookerSDK::Unauthorized => e
@@ -200,10 +214,10 @@ module Gzr
200
214
  end
201
215
  end
202
216
 
203
- def with_session(api_version="3.0")
217
+ def with_session(min_api_version="3.0")
204
218
  return nil unless block_given?
205
219
  begin
206
- login(api_version) unless @sdk
220
+ login(min_api_version) unless @sdk
207
221
  yield
208
222
  rescue LookerSDK::Error => e
209
223
  say_error e.errors if e.respond_to?(:errors) && e.errors
data/lib/gzr/version.rb CHANGED
@@ -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.44"
23
+ VERSION = "0.2.46"
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.44
4
+ version: 0.2.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -114,14 +114,28 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.7
117
+ version: 0.1.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.7
124
+ version: 0.1.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: net-http-persistent
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 4.0.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 4.0.1
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement