env_compare 0.1.0 → 0.1.4

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: f6417ed28ff6a91297a3ecc58af784d6819d4f59465984720b57cf9e495f553b
4
- data.tar.gz: a3e325abdeef448d2dac80474a8f51d433ebb2c047f6bea309b9cdde136d0f09
3
+ metadata.gz: 4768bf53d6d45f53db0e5ce3d35deb883580310a4cd947b9d81fa55677b849e9
4
+ data.tar.gz: 1955b4528296632cca9f5c06c101ee1fff4774a2e47f6fa57a7e94ffb0f407c5
5
5
  SHA512:
6
- metadata.gz: d61b7acab0d9661c8e36e2e3e92f1c53cb263184d0c4dfdbbcbd0dcfbcffdc954700384fa77dd0b1a1adc3106a7a4380125e24f352f341b05c9a871e7506d758
7
- data.tar.gz: de8a8214ceadb18c47f3abb2ca18e402286ba99ea2b92439a1f375142cd8225be3fe27dab6685912611d36017bc55887b854b5f979e12a6bcb445c5e8a82f573
6
+ metadata.gz: b6ce901f8ec3fa70931bd1257553bdc5a882c5c43b0ab386507fc643bd91fa35e61c46b81dbbac0e1d8f0b5cdbebd1a1811d395c0bdc807013b9d2c323d143e8
7
+ data.tar.gz: be6d7dfbec6b681018ff383b19f269db6aa85bc62c78d34639b635ab7017dbec4a3561f3f0e5c5e00a2af0715b12d893ad71f68ccff8e55e156236796f792d7b
@@ -13,17 +13,20 @@
13
13
  require:
14
14
  - rubocop-performance
15
15
 
16
+ AllCops:
17
+ NewCops: enable
18
+
16
19
  Layout/LineLength:
17
20
  Max: 120
18
21
 
19
- Style/Documentation:
20
- Enabled: false
21
-
22
- Metrics/MethodLength:
23
- Max: 15
24
-
25
22
  Layout/DotPosition:
26
23
  EnforcedStyle: trailing
27
24
 
28
25
  Layout/MultilineMethodCallIndentation:
29
26
  EnforcedStyle: indented
27
+
28
+ Metrics/MethodLength:
29
+ Max: 15
30
+
31
+ Style/Documentation:
32
+ Enabled: false
@@ -0,0 +1,20 @@
1
+ # CHANGELOG
2
+
3
+ ## main (unreleased)
4
+ - WIP
5
+
6
+ ## 0.1.4 (2020-12-07)
7
+ - Fixed bug with template path reference ([#26](https://github.com/jaydorsey/env_compare/issues/26))
8
+
9
+ ## 0.1.3.pre.beta (2020-09-02)
10
+ - Added `force` and `no-force` options for updating environment variables.
11
+
12
+ ## 0.1.3.pre.alpha (2020-07-29)
13
+ - Added Heroku Oauth.
14
+ - Added ability to update/remove environment variables.
15
+
16
+ ## 0.1.1 (2020-06-12)
17
+ - Improve description example on `diff` option.
18
+
19
+ ## 0.1.0 (2020-06-12)
20
+ - Initial release. Includes a `diff` option & 2 themes.
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in env_compare.gemspec
4
6
  gemspec
5
7
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- env_compare (0.1.0)
4
+ env_compare (0.1.4)
5
5
  launchy
6
+ platform-api
6
7
  thor
7
8
 
8
9
  GEM
@@ -12,19 +13,33 @@ GEM
12
13
  public_suffix (>= 2.0.2, < 5.0)
13
14
  ast (2.4.1)
14
15
  coderay (1.1.3)
15
- diff-lcs (1.3)
16
+ diff-lcs (1.4.4)
17
+ erubis (2.7.0)
18
+ excon (0.76.0)
19
+ heroics (0.1.1)
20
+ erubis (~> 2.0)
21
+ excon
22
+ moneta
23
+ multi_json (>= 1.9.2)
16
24
  launchy (2.5.0)
17
25
  addressable (~> 2.7)
18
26
  method_source (1.0.0)
19
- parallel (1.19.1)
20
- parser (2.7.1.3)
21
- ast (~> 2.4.0)
27
+ moneta (1.0.0)
28
+ multi_json (1.15.0)
29
+ parallel (1.19.2)
30
+ parser (2.7.1.4)
31
+ ast (~> 2.4.1)
32
+ platform-api (3.0.0)
33
+ heroics (~> 0.1.1)
34
+ moneta (~> 1.0.0)
35
+ rate_throttle_client (~> 0.1.0)
22
36
  pry (0.13.1)
23
37
  coderay (~> 1.1)
24
38
  method_source (~> 1.0)
25
- public_suffix (4.0.5)
39
+ public_suffix (4.0.6)
26
40
  rainbow (3.0.0)
27
41
  rake (12.3.3)
42
+ rate_throttle_client (0.1.2)
28
43
  regexp_parser (1.7.1)
29
44
  rexml (3.2.4)
30
45
  rspec (3.9.0)
@@ -40,19 +55,19 @@ GEM
40
55
  diff-lcs (>= 1.2.0, < 2.0)
41
56
  rspec-support (~> 3.9.0)
42
57
  rspec-support (3.9.3)
43
- rubocop (0.85.1)
58
+ rubocop (0.90.0)
44
59
  parallel (~> 1.10)
45
- parser (>= 2.7.0.1)
60
+ parser (>= 2.7.1.1)
46
61
  rainbow (>= 2.2.2, < 4.0)
47
62
  regexp_parser (>= 1.7)
48
63
  rexml
49
- rubocop-ast (>= 0.0.3)
64
+ rubocop-ast (>= 0.3.0, < 1.0)
50
65
  ruby-progressbar (~> 1.7)
51
66
  unicode-display_width (>= 1.4.0, < 2.0)
52
- rubocop-ast (0.0.3)
53
- parser (>= 2.7.0.1)
54
- rubocop-performance (1.6.1)
55
- rubocop (>= 0.71.0)
67
+ rubocop-ast (0.3.0)
68
+ parser (>= 2.7.1.4)
69
+ rubocop-performance (1.8.0)
70
+ rubocop (>= 0.87.0)
56
71
  ruby-progressbar (1.10.1)
57
72
  thor (1.0.1)
58
73
  unicode-display_width (1.7.0)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Jay Dorsey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # EnvCompare
2
+ [![Gem Version](https://img.shields.io/gem/v/env_compare)](https://img.shields.io/gem/v/env_compare)
3
+ ![Gem Downloads](https://img.shields.io/gem/dt/env_compare)
4
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
5
+ [![GitHub License](https://img.shields.io/github/license/jaydorsey/env_compare.svg)](https://github.com/jaydorsey/env_compare/blob/main/LICENSE)
2
6
 
3
7
  Compare Heroku ENV variables across environments in an HTML
4
8
  table.
@@ -11,46 +15,106 @@ production environment variables
11
15
  This gem helps pull down the environment variables and give you
12
16
  a little interface to view & compare them with (via a UI)
13
17
 
14
- No server; it's all done via a CLI. It's really just a wrapper around
15
- some commands around the [heroku cli](https://devcenter.heroku.com/articles/heroku-cli) that does some formatting and
16
- munging of the output so you don't have to copy it all to Excel
17
-
18
- This gem wraps the heroku CLI tool to generates a small temporary
19
- HTML file & opens it using [launchy](https://github.com/copiousfreetime/launchy)
18
+ The heavy lifting is done via the [heroku platform-api gem](https://github.com/heroku/platform-api)
19
+ to retrieve environment variables, format them in an HTML page, and
20
+ generate a small HTML file and open it with [launchy](https://github.com/copiousfreetime/launchy)
20
21
 
21
22
  It automates a few things:
22
23
  - Hides environment variables that match across all environments
23
24
  - Puts them in alpha order
24
25
 
25
26
  It's primarily intended to compare pre-production ENV variables
27
+ across similar/identical environments
26
28
 
27
29
  ## Installation
28
30
 
29
- # Install heroku CLI
30
- brew tap heroku/brew && brew install heroku
31
+ ### Prerequisites
31
32
 
32
- git clone https://github.com/jaydorsey/env_compare.git && cd env_compare
33
- bundle
34
- rake build
35
- gem install pkg/env_compare-0.1.0.gem
33
+ ```bash
34
+ # Install Heroku CLI
35
+ brew tap heroku/brew && brew install heroku
36
+
37
+ # Login with Heroku CLI
38
+ heroku login
39
+
40
+ # Install the heroku oauth plugin to generate an OAuth token
41
+ heroku plugins:install heroku-cli-oauth
42
+
43
+ # Create a token to access your applications
44
+ heroku authorizations:create -d "Platform API token for environment variables"
36
45
 
37
- After installation you should have access to the `ec` executable wrapper
46
+ # Set the Token from above to an environment variable
47
+ export OAUTH_TOKEN=<token>
48
+ ```
38
49
 
39
- > Note: There's no published gem yet. I'm not really sure how useful this is
40
- > but you can install via above or use the development commands below if you
41
- > don't want to build & install the gem locally
50
+ If you want to add the environment variable to your shell permanently, you can
51
+ run a variation of the command below:
52
+
53
+ ```bash
54
+ # Add permanently to `.bash_profile`
55
+ echo 'export OAUTH_TOKEN=<token>' >>~/.bash_profile
56
+ ```
57
+
58
+ ### Install gem
59
+ ```bash
60
+ gem install env_compare
61
+ ```
62
+
63
+ After installation you should have access to the `ec` executable wrapper.
42
64
 
43
65
  ## Usage
66
+ Use `ec` command to start comparing 2 or more heroku application environment variables.
67
+
68
+ When only one application name is specified, output is shown in cli. Otherwise, your default browser is launched.
69
+
70
+ ## Comparing environment variables
71
+
72
+ ### Show **differences** **default*
73
+ ```bash
74
+ ec diff heroku-app-name1 heroku-app-name2 heroku-app-name3
75
+ ```
76
+
77
+ ### Show **all**
78
+ add `--all` option:
79
+ ```bash
80
+ ec diff --all heroku-app-name1 heroku-app-name2 heroku-app-name3
81
+ ```
44
82
 
45
- First, you need to login with heroku cli:
83
+ ### Themes
84
+ - `--theme dark` **default**
85
+ - `--theme light`
46
86
 
47
- heroku login
87
+ For Example:
88
+ ```bash
89
+ ec diff --theme light heroku-app-name1 heroku-app-name2
90
+ ```
48
91
 
49
- Then, you can use the `ec` command
92
+ ## Updating environment variables across multiple apps
50
93
 
51
- Create a file showing differences between 2 or more heroku applications:
94
+ You can use `ec update` to set or clear an environment variable across multiple Heroku
95
+ applications. This includes the options:
52
96
 
53
- ec diff heroku-app-name1 heroku-app-name2 heroku-app-name3
97
+ - `--key=` is required. The name of the Heroku environment variable you want to update.
98
+ - `--value=` is optional. The value of the environment variable you want to update. If not provided, will unset the environment variable.
99
+ - `--force` is a default option. Updates the environment variable, or adds it if not present. ** 0.1.3.pre.beta **
100
+ - `--no-force` is optional. Only update the environment variable if present in the application. ** 0.1.3.pre.beta **
101
+
102
+ ### Examples
103
+
104
+ #### Update an environment variable
105
+
106
+ ```bash
107
+ ec update heroku-app-name1 heroku-app-name2 heroku-app-name3 --key=MY_KEY --value=asdf
108
+ ```
109
+
110
+ #### Clear an environment variable
111
+
112
+ The default key value is nil; omit the `--key` argument if you want to clear an
113
+ environment variable.
114
+
115
+ ```bash
116
+ ec update heroku-app-name1 heroku-app-name2 heroku-app-name3 --key=MY_KEY
117
+ ```
54
118
 
55
119
  ## Development
56
120
 
@@ -60,6 +124,22 @@ To test this on your machine locally, after cloning the repo:
60
124
  bundle
61
125
  bundle exec ec diff heroku-app-name1 heroku-app-name2
62
126
 
127
+ You can also optionally build & install the gem locally to test:
128
+
129
+ rake build
130
+ gem install pkg/env_compare.<version_number>.gem
131
+
132
+ Then, use the `ec` command as normal.
133
+ ### Publishing the gem
134
+
135
+ If you have access to publish the gem on rubygems:
136
+
137
+ rake build
138
+ cd pkg
139
+ gem push env_compare.<version_number>.gem
140
+
63
141
  ## Contributing
64
142
 
65
143
  Bug reports and pull requests are welcome on GitHub at https://github.com/jaydorsey/env_compare.
144
+
145
+ [![Repo Contributors](https://img.shields.io/github/contributors/jaydorsey/env_compare)](https://img.shields.io/github/contributors/jaydorsey/env_compare)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,11 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "env_compare"
4
+ require 'bundler/setup'
5
+ require 'env_compare'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
8
9
 
9
10
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- require "pry"
11
+ require 'pry'
12
+
13
+ def reload!
14
+ puts 'Reloading...'
15
+ exec 'bin/console'
16
+ end
17
+
11
18
  Pry.start
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.metadata['homepage_uri'] = spec.homepage
19
19
  spec.metadata['source_code_uri'] = 'https://github.com/jaydorsey/env_compare'
20
- spec.metadata['changelog_uri'] = 'https://github.com/jaydorsey/env_compare/CHANGELOG.md'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/jaydorsey/env_compare/blob/master/CHANGELOG.md'
21
21
 
22
22
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'launchy'
31
+ spec.add_dependency 'platform-api'
31
32
  spec.add_dependency 'thor'
32
33
 
33
34
  spec.add_development_dependency 'pry'
data/exe/ec CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "env_compare"
4
+ require 'env_compare'
4
5
 
5
- EnvCompare::CLI.start(ARGV)
6
+ EnvCompare::Cli.start(ARGV)
@@ -1,101 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'env_compare/template'
3
4
  require 'env_compare/errors'
4
- require 'env_compare/name_space'
5
5
  require 'env_compare/version'
6
- require 'erb'
7
- require 'launchy'
8
- require 'securerandom'
9
- require 'thor'
10
- require 'pry'
6
+ require 'env_compare/cli'
11
7
 
12
8
  module EnvCompare
13
- class CLI < Thor
14
- attr_accessor :envs
15
-
16
- desc 'version', 'list version'
17
- def version
18
- puts EnvCompare::VERSION
19
- end
20
-
21
- desc 'list ENVIRONMENT', 'List environment variables for a single environment'
22
-
23
- def list(environment)
24
- output = `heroku config -a #{environment}`
25
- puts output
26
- end
27
-
28
- option :theme, type: :string, default: 'dark', desc: 'Theme to use'
29
- option :all, type: :boolean, default: false, desc: 'Display all ENV variables, including matches'
30
- desc 'diff ENV1 ENV2', 'Compare environment variables for 2+ environments'
31
- def diff(*envs)
32
- return list(envs.first) if envs.size == 1
33
-
34
- heroku_results(envs)
35
-
36
- # https://stackoverflow.com/a/5462069/2892779
37
- html =
38
- theme(options[:theme]).
39
- result(
40
- ::EnvCompare::NameSpace.new(data: calculated_output(envs), headers: ['KEY', envs].flatten).get_binding
41
- )
42
-
43
- save_and_open_file(html)
44
- end
45
-
46
- private
47
-
48
- def all_keys
49
- @all_keys ||= Set.new
50
- end
51
-
52
- def calculated_output(envs)
53
- all_keys.sort.map do |key|
54
- results = envs.map { |env| heroku_results[env][key] }
55
- next if results.uniq.size == 1 && !options[:all]
56
-
57
- [key, *results]
58
- end.compact
59
- end
60
-
61
- def heroku_results(envs = nil)
62
- @heroku_results ||=
63
- envs.each_with_object({}) do |env, obj|
64
- obj[env] = {}
65
- lines = `heroku config -a #{env}`.split("\n").drop(1)
66
-
67
- lines.each do |line|
68
- key, _, value = line.partition(':')
69
- obj[env][key.strip] = value.strip
70
-
71
- all_keys << key.strip
72
- end
73
- end
74
- end
75
-
76
- def save_and_open_file(html)
77
- filename = "#{SecureRandom.hex(32)}.html"
78
- output = File.open(filename, 'w')
79
- output.write(html)
80
- output.close
81
-
82
- full_path = File.join(Dir.pwd, output.path)
83
-
84
- Launchy.open(full_path)
85
-
86
- sleep(1)
87
-
88
- File.delete(full_path)
89
- end
90
-
91
- def theme(file)
92
- return ERB.new(File.read(theme_path(file))) if File.exist?(theme_path(file))
93
-
94
- raise MissingThemeError
95
- end
96
-
97
- def theme_path(file)
98
- @theme_path ||= File.join(File.dirname(__dir__), 'themes', "#{file}.erb")
99
- end
100
- end
101
9
  end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+ require 'launchy'
5
+ require 'securerandom'
6
+ require 'platform-api'
7
+ require 'pry'
8
+ require 'thor'
9
+
10
+ module EnvCompare
11
+ class Cli < Thor
12
+ attr_accessor :envs
13
+
14
+ desc 'version', 'list version'
15
+ def version
16
+ puts EnvCompare::VERSION
17
+ end
18
+
19
+ desc 'list ENVIRONMENT', 'List environment variables for a single environment'
20
+
21
+ def list(environment)
22
+ output = `heroku config -a #{environment}`
23
+ puts output
24
+ end
25
+
26
+ option :theme, type: :string, default: 'dark', desc: 'Theme to use'
27
+ option :all, type: :boolean, default: false, desc: 'Display all ENV variables, including matches'
28
+ desc 'diff heroku-app-name-1 heroku-app-name-2', 'Compare environment variables for 2+ environments'
29
+ def diff(*envs)
30
+ return list(envs.first) if envs.size == 1
31
+
32
+ heroku_results(envs)
33
+
34
+ html =
35
+ ::EnvCompare::Template.new(
36
+ data: calculated_output(envs),
37
+ headers: ['KEY', envs].flatten,
38
+ theme_base_path: theme_base_path
39
+ ).render(theme_name(options[:theme]))
40
+
41
+ save_and_open_file(html)
42
+ end
43
+
44
+ option :key, type: :string, desc: 'Key name'
45
+ option :value, type: :string, default: nil, desc: 'Value of key'
46
+ option :force, type: :boolean, default: true, desc: 'Add the ENV, even if it does not exist'
47
+ desc 'update heroku-app-name-1 heroku-app-name-2 --key=MY_KEY --value=test', 'Update environment variable for 1+ environments'
48
+ def update(*apps)
49
+ apps.each do |app|
50
+ if options.force
51
+ config_var_update(app, { options[:key] => options[:value] })
52
+ else
53
+ conditional_config_var_update(app, { options[:key] => options[:value] })
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def all_keys
61
+ @all_keys ||= Set.new
62
+ end
63
+
64
+ def calculated_output(envs)
65
+ all_keys.sort.map do |key|
66
+ results = envs.map { |env| heroku_results[env][key] }
67
+ next if results.uniq.size == 1 && !options[:all]
68
+
69
+ [key, *results]
70
+ end.compact
71
+ end
72
+
73
+ def heroku_results(app_names = nil)
74
+ @heroku_results ||=
75
+ app_names.each_with_object({}) do |app_name, obj|
76
+ obj[app_name] = {}
77
+
78
+ env_vars = config_vars_for_app(app_name)
79
+
80
+ env_vars.each do |key, value|
81
+ obj[app_name][key] = value
82
+
83
+ all_keys << key
84
+ end
85
+ end
86
+ end
87
+
88
+ def save_and_open_file(html)
89
+ filename = "#{SecureRandom.hex(32)}.html"
90
+ output = File.open(filename, 'w')
91
+ output.write(html)
92
+ output.close
93
+
94
+ full_path = File.join(Dir.pwd, output.path)
95
+
96
+ Launchy.open(full_path)
97
+
98
+ sleep(1)
99
+
100
+ File.delete(full_path)
101
+ end
102
+
103
+ def config_vars_for_app(app_name)
104
+ heroku.config_var.info_for_app(app_name)
105
+ end
106
+
107
+ def heroku
108
+ @heroku ||= PlatformAPI.connect_oauth(ENV.fetch('OAUTH_TOKEN'))
109
+ end
110
+
111
+ # Returns a filename.ext when given a filename
112
+ #
113
+ # Also checks to make sure the file exists.
114
+ def theme_name(theme)
115
+ theme_file = "#{theme}.html.erb"
116
+
117
+ path = File.join(theme_base_path, theme_file)
118
+
119
+ return theme_file if File.exist?(path)
120
+
121
+ raise MissingThemeError
122
+ end
123
+
124
+ # Returns a path representing where themes are stored in the library
125
+ #
126
+ # Used for the ERB templates to resolve file locations
127
+ def theme_base_path
128
+ @theme_base_path ||= File.expand_path(File.join(File.dirname(__dir__), '..', 'themes'))
129
+ end
130
+
131
+ def config_var_update(app_name, env_hash)
132
+ heroku.config_var.update(app_name, env_hash)
133
+ end
134
+
135
+ def conditional_config_var_update(app_name, env_hash)
136
+ return if config_vars_for_app(app_name)[options[:key]].nil?
137
+
138
+ config_var_update(app_name, env_hash)
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # https://stackoverflow.com/a/10241263/2892779
4
+ module EnvCompare
5
+ class Template
6
+ def initialize(data:, headers:, theme_base_path:)
7
+ @data = data
8
+ @headers = headers
9
+ @theme_base_path = theme_base_path
10
+ end
11
+
12
+ def render(path)
13
+ content = File.read(File.join(@theme_base_path, path))
14
+ t = ERB.new(content)
15
+ t.result(binding)
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EnvCompare
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -0,0 +1,48 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ :root {
5
+ --black: #000;
6
+ --blue: #409cff;
7
+ --gray-object-only: #636366;
8
+ --orange: #ffb340;
9
+ --purple: #da8fff;
10
+ }
11
+
12
+ body {
13
+ background: var(--black);
14
+ font-family: Arial, Helvetica, sans-serif;
15
+ }
16
+
17
+ table {
18
+ color: var(--purple);
19
+ table-layout: fixed;
20
+ width: 100%;
21
+ }
22
+
23
+ table,
24
+ th,
25
+ td {
26
+ border: 1px solid var(--gray-object-only);
27
+ border-collapse: collapse;
28
+ }
29
+
30
+ th {
31
+ color: var(--orange);
32
+ letter-spacing: 1px;
33
+ }
34
+
35
+ td {
36
+ padding: 10px;
37
+ word-wrap: break-word;
38
+ }
39
+
40
+ td:first-child {
41
+ color: var(--blue);
42
+ }
43
+ </style>
44
+ </head>
45
+ <body>
46
+ <%= render 'table_template.html.erb' %>
47
+ </body>
48
+ </html>
@@ -0,0 +1,47 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ :root {
5
+ --black: #000;
6
+ --blue: #0040dd;
7
+ --gray: #545456;
8
+ --white: #fff;
9
+ }
10
+
11
+ body {
12
+ background: var(--white);
13
+ font-family: Arial, Helvetica, sans-serif;
14
+ }
15
+
16
+ table {
17
+ color: var(--black);
18
+ table-layout: fixed;
19
+ width: 100%;
20
+ }
21
+
22
+ table,
23
+ th,
24
+ td {
25
+ border: 1px solid var(--gray);
26
+ border-collapse: collapse;
27
+ }
28
+
29
+ th {
30
+ color: var(--black);
31
+ letter-spacing: 1px;
32
+ }
33
+
34
+ td {
35
+ padding: 10px;
36
+ word-wrap: break-word;
37
+ }
38
+
39
+ td:first-child {
40
+ color: var(--blue);
41
+ }
42
+ </style>
43
+ </head>
44
+ <body>
45
+ <%= render 'table_template.html.erb' %>
46
+ </body>
47
+ </html>
@@ -0,0 +1,26 @@
1
+ <table>
2
+ <thead>
3
+ <tr>
4
+ <% @headers.each_with_index do |header, idx| %>
5
+ <th>
6
+ <%= header %>&nbsp;
7
+ (<%= @data.map { |col| col[idx] }.compact.size %>)
8
+ </th>
9
+ <% end %>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @data.each do |row| %>
15
+ <tr>
16
+ <% row.each do |cell| %>
17
+ <td>
18
+ <% unless cell.nil? %>
19
+ <code><%= cell %></code>
20
+ <% end %>
21
+ </td>
22
+ <% end %>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Dorsey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: launchy
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: platform-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: thor
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -106,8 +120,10 @@ files:
106
120
  - ".rspec"
107
121
  - ".rubocop.yml"
108
122
  - ".travis.yml"
123
+ - CHANGELOG.md
109
124
  - Gemfile
110
125
  - Gemfile.lock
126
+ - LICENSE
111
127
  - README.md
112
128
  - Rakefile
113
129
  - bin/console
@@ -115,18 +131,20 @@ files:
115
131
  - env_compare.gemspec
116
132
  - exe/ec
117
133
  - lib/env_compare.rb
134
+ - lib/env_compare/cli.rb
118
135
  - lib/env_compare/errors.rb
119
- - lib/env_compare/name_space.rb
136
+ - lib/env_compare/template.rb
120
137
  - lib/env_compare/version.rb
121
- - themes/dark.erb
122
- - themes/light.erb
138
+ - themes/dark.html.erb
139
+ - themes/light.html.erb
140
+ - themes/table_template.html.erb
123
141
  homepage: https://jaydorsey.com/
124
142
  licenses: []
125
143
  metadata:
126
144
  allowed_push_host: https://rubygems.org
127
145
  homepage_uri: https://jaydorsey.com/
128
146
  source_code_uri: https://github.com/jaydorsey/env_compare
129
- changelog_uri: https://github.com/jaydorsey/env_compare/CHANGELOG.md
147
+ changelog_uri: https://github.com/jaydorsey/env_compare/blob/master/CHANGELOG.md
130
148
  post_install_message:
131
149
  rdoc_options: []
132
150
  require_paths:
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EnvCompare
4
- class NameSpace
5
- def initialize(hash)
6
- hash.each do |key, value|
7
- singleton_class.send(:define_method, key) { value }
8
- end
9
- end
10
-
11
- def get_binding
12
- binding
13
- end
14
- end
15
- end
@@ -1,57 +0,0 @@
1
- <html>
2
- <head>
3
- <style>
4
- body {
5
- background: #000;
6
- font-family: Arial, Helvetica, sans-serif;
7
- }
8
- table {
9
- color: #da8fff;
10
- table-layout: fixed;
11
- width: 100%;
12
- }
13
-
14
- table, th, td {
15
- border: 1px solid #636366;
16
- border-collapse: collapse;
17
- }
18
-
19
- th {
20
- color: #ffb340;
21
- letter-spacing: 1px;
22
- }
23
-
24
- td {
25
- padding: 10px;
26
- word-wrap: break-word;
27
- }
28
-
29
- td:first-child {
30
- color: #409cff;
31
- }
32
- </style>
33
- </head>
34
- <body>
35
- <table>
36
- <tr>
37
- <% headers.each_with_index do |header, idx| %>
38
- <th>
39
- <%= header %>&nbsp;
40
- (<%= data.map { |col| col[idx] }.compact.size - 1 %> keys)
41
- </th>
42
- <% end %>
43
- </tr>
44
- <% data.each do |row| %>
45
- <tr>
46
- <% row.each do |cell| %>
47
- <td>
48
- <% unless cell.nil? %>
49
- <code><%= cell %></code>
50
- <% end %>
51
- </td>
52
- <% end %>
53
- </tr>
54
- <% end %>
55
- </table>
56
- </body>
57
- </html>
@@ -1,57 +0,0 @@
1
- <html>
2
- <head>
3
- <style>
4
- body {
5
- background: #fff;
6
- font-family: Arial, Helvetica, sans-serif;
7
- }
8
- table {
9
- color: #000;
10
- table-layout: fixed;
11
- width: 100%;
12
- }
13
-
14
- table, th, td {
15
- border: 1px solid #636366;
16
- border-collapse: collapse;
17
- }
18
-
19
- th {
20
- color: #000;
21
- letter-spacing: 1px;
22
- }
23
-
24
- td {
25
- padding: 10px;
26
- word-wrap: break-word;
27
- }
28
-
29
- td:first-child {
30
- color: #409cff;
31
- }
32
- </style>
33
- </head>
34
- <body>
35
- <table>
36
- <tr>
37
- <% headers.each_with_index do |header, idx| %>
38
- <th>
39
- <%= header %>&nbsp;
40
- (<%= data.map { |col| col[idx] }.compact.size - 1 %> keys)
41
- </th>
42
- <% end %>
43
- </tr>
44
- <% data.each do |row| %>
45
- <tr>
46
- <% row.each do |cell| %>
47
- <td>
48
- <% unless cell.nil? %>
49
- <code><%= cell %></code>
50
- <% end %>
51
- </td>
52
- <% end %>
53
- </tr>
54
- <% end %>
55
- </table>
56
- </body>
57
- </html>