cloudenv-hq 0.1.2 → 0.2.7

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: 1df854be28a19a2589839b753472a35cc641b85d772369436f89d4c38fdb6c53
4
- data.tar.gz: 1c9e54ad28255ce9f2f98c95c977a7e69f3dca01e0b709832af32a1f8da5d196
3
+ metadata.gz: 379dc14ea6b12c76e8d18b87c82183709128af1d11979430e44af003d84c051f
4
+ data.tar.gz: dd24b18dba69fb4a6f0b1a968d44ca7c26de5bc9184e1581abbd46eac8b4e1da
5
5
  SHA512:
6
- metadata.gz: 2f531a464c734a711b09afcd95e2dc690a13401e440ab61a5a3e9df6390472ccc13c28b07796178591762149f4630f989abee9c121ce6bb5302f9182dc8e2581
7
- data.tar.gz: 55c23efc41866780fda0627e01babbcfda678878172be7e24a3c3249d505d33979f7ed345a036e52e58a5faafba2c64c1f91181928f448407478dfb1018c876a
6
+ metadata.gz: 24a4a36ea23bd60b8ab8d4f9c37a749320009fb9c2f29146eaad81fedb204ee3820e31d98b00733e0572a2f9b240545e064d97a8fbdb6d85946a2a0d01090195
7
+ data.tar.gz: 18330df2a8b71b59c8f001c7802f6610b584a4af4caf5a767e4f1195d68c9766cda0b64ac599c19c5e54d6232fe7bc5380629fcdbbe45f29f3c6c7be001bbbf7
data/cloudenv-hq.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = "cloudenv-hq"
3
- s.version = "0.1.2"
4
- s.license = "MIT"
5
- s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV["TRAVIS"]
6
- s.date = "2020-10-10"
7
- s.summary = "Keep your ENV vars synced between your team members"
8
- s.email = "support@cloudenv.com"
9
- s.homepage = "https://github.com/cloudenvhq/cloudenv-ruby"
10
- s.description = "Keep your ENV vars synced between your team members."
11
- s.authors = ["Lucas Carlson"]
12
- s.files = ["install.rb", "lib", "lib/cloudenv-hq.rb", "LICENSE", "Rakefile", "README.markdown", "cloudenv-hq.gemspec", "test", "test/base", "test/base/base_test.rb", "test/data", "test/test_helper.rb"]
13
- s.rubyforge_project = "cloudenv-hq"
14
- s.add_dependency "dotenv"
15
- s.add_development_dependency "rake"
16
- s.add_development_dependency "rdoc"
17
- s.add_development_dependency "test-unit"
2
+ s.name = 'cloudenv-hq'
3
+ s.version = '0.2.7'
4
+ s.license = 'MIT'
5
+ s.date = '2020-10-10'
6
+ s.summary = 'Keep your ENV vars synced between your team members'
7
+ s.email = 'support@cloudenv.com'
8
+ s.homepage = 'https://github.com/cloudenvhq/cloudenv-ruby'
9
+ s.description = 'Keep your ENV vars synced between your team members.'
10
+ s.authors = ['Lucas Carlson']
11
+ s.files = ['install.rb', 'lib', 'lib/cloudenv-hq.rb', 'LICENSE', 'Rakefile', 'README.markdown', 'cloudenv-hq.gemspec',
12
+ 'test', 'test/base', 'test/base/base_test.rb', 'test/data', 'test/test_helper.rb']
13
+ s.rubyforge_project = 'cloudenv-hq'
14
+ s.add_dependency 'dotenv'
15
+ s.add_development_dependency 'rake'
16
+ s.add_development_dependency 'rdoc'
17
+ s.add_development_dependency 'test-unit'
18
18
  end
data/lib/cloudenv-hq.rb CHANGED
@@ -1,29 +1,47 @@
1
- require "pathname"
2
- require "dotenv"
3
- require "tempfile"
1
+ require 'pathname'
2
+ require 'dotenv'
3
+ require 'tempfile'
4
+ require 'yaml'
4
5
 
5
6
  class CloudenvHQ
6
- VERSION = "0.1.2".freeze
7
+ VERSION = '0.2.7'.freeze
7
8
 
8
- API_HOST = "https://app.cloudenv.com".freeze
9
- READ_PATH = "/api/v1/envs".freeze
9
+ API_HOST = 'https://app.cloudenv.com'.freeze
10
+ READ_PATH = '/api/v1/envs'.freeze
10
11
 
11
- def initialize(options={})
12
- @environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"]
13
- @bearer = `cat #{options[:bearer] || "~/.cloudenvrc"}`.strip
14
- @secret_key_filename = ".cloudenv-secret-key"
15
- @secret_key = Pathname.new(@secret_key_filename)
12
+ def initialize(options = {})
13
+ @environment = ENV['RAILS_ENV'] || ENV['RACK_ENV']
16
14
 
17
- until File.exists?(@secret_key) || @secret_key.expand_path == Pathname.new("/.cloudenv-secret-key")
18
- @secret_key = @secret_key.parent.parent + @secret_key_filename
15
+ if ENV['CLOUDENV_BEARER_TOKEN'] || options[:bearer]
16
+ @bearer = ENV['CLOUDENV_BEARER_TOKEN'] || options[:bearer]
17
+ else
18
+ @bearer_filename = File.expand_path(ENV['CLOUDENV_BEARER_FILE'] || '~/.cloudenvrc')
19
+ @bearer = IO.read(@bearer_filename).to_s.strip if File.exist?(@bearer_filename)
19
20
  end
20
21
 
21
- if File.exists?(@secret_key)
22
- @app, @secret_key = IO.read(@secret_key).split
22
+ if ENV['CLOUDENV_APP_SLUG'] && ENV['CLOUDENV_APP_SECRET_KEY']
23
+ @app = ENV['CLOUDENV_APP_SLUG']
24
+ @secret_key = ENV['CLOUDENV_APP_SECRET_KEY']
25
+ else
26
+ @secret_key_filename = File.expand_path(ENV['CLOUDENV_APP_SECRET_KEY_FILE'] || '.cloudenv-secret-key')
27
+ @secret_key = Pathname.new(@secret_key_filename)
28
+
29
+ until File.exist?(@secret_key) || @secret_key.expand_path == Pathname.new('/.cloudenv-secret-key')
30
+ @secret_key = @secret_key.parent.parent + @secret_key_filename
31
+ end
32
+
33
+ if File.exist?(@secret_key)
34
+ data = YAML.safe_load(IO.read(@secret_key))
35
+
36
+ @app = data['slug']
37
+ @secret_key = data['secret-key']
38
+ end
39
+ end
23
40
 
41
+ if @bearer && @app && @secret_key
24
42
  if @environment
25
43
  data = `curl -s -H "Authorization: Bearer #{@bearer}" "https://app.cloudenv.com/api/v1/envs?name=#{@app}&environment=#{@environment}&version=#{VERSION}&lang=ruby" | openssl enc -a -aes-256-cbc -md sha512 -d -pass pass:"#{@secret_key}" 2> /dev/null`
26
- file = Tempfile.new("cloudenv")
44
+ file = Tempfile.new('cloudenv')
27
45
  file.write(data)
28
46
  file.close
29
47
  Dotenv.load(file.path)
@@ -31,15 +49,15 @@ class CloudenvHQ
31
49
  end
32
50
 
33
51
  data = `curl -s -H "Authorization: Bearer #{@bearer}" "https://app.cloudenv.com/api/v1/envs?name=#{@app}&environment=default&version=#{VERSION}&lang=ruby" | openssl enc -a -aes-256-cbc -md sha512 -d -pass pass:"#{@secret_key}" 2> /dev/null`
34
- file = Tempfile.new("cloudenv")
52
+ file = Tempfile.new('cloudenv')
35
53
  file.write(data)
36
54
  file.close
37
55
  Dotenv.load(file.path)
38
56
  file.unlink
39
57
  else
40
- warn "WARNING: cloudenv could not find a .cloudenv-secret-key in the directory path"
58
+ warn 'WARNING: cloudenv could not find a .cloudenv-secret-key in the directory path or values for both ENV["CLOUDENV_APP_SLUG"] and ENV["CLOUDENV_APP_SECRET_KEY"]'
41
59
  end
42
60
  end
43
61
  end
44
62
 
45
- CloudenvHQ.new(bearer: ENV["CLOUDENV_BEARER_PATH"])
63
+ CloudenvHQ.new(bearer: ENV['CLOUDENV_BEARER_PATH'])
@@ -1,82 +1,5 @@
1
- require "test_helper"
1
+ require 'test_helper'
2
2
  class BaseTest < Test::Unit::TestCase
3
3
  def setup
4
- @rss09 = SimpleRSS.parse open(File.dirname(__FILE__) + "/../data/rss09.rdf")
5
- @rss20 = SimpleRSS.parse open(File.dirname(__FILE__) + "/../data/rss20.xml")
6
- @rss20_utf8 = SimpleRSS.parse open(File.dirname(__FILE__) + "/../data/rss20_utf8.xml")
7
- @media_rss = SimpleRSS.parse open(File.dirname(__FILE__) + "/../data/media_rss.xml")
8
- @atom = SimpleRSS.parse open(File.dirname(__FILE__) + "/../data/atom.xml")
9
4
  end
10
-
11
- def test_channel
12
- assert_equal @rss09, @rss09.channel
13
- assert_equal @rss20, @rss20.channel
14
- assert_equal @atom, @atom.feed
15
- end
16
-
17
- def test_items
18
- assert_kind_of Array, @rss09.items
19
- assert_kind_of Array, @rss20.items
20
- assert_kind_of Array, @atom.entries
21
- end
22
-
23
- def test_rss09
24
- assert_equal 10, @rss09.items.size
25
- assert_equal "Slashdot", @rss09.title
26
- assert_equal "http://slashdot.org/", @rss09.channel.link
27
- assert_equal "http://books.slashdot.org/article.pl?sid=05/08/29/1319236&amp;from=rss", @rss09.items.first.link
28
- assert_equal "http://books.slashdot.org/article.pl?sid=05/08/29/1319236&amp;from=rss", @rss09.items.first[:link]
29
- assert_equal Time.parse("Wed Aug 24 13:33:34 UTC 2005"), @rss20.items.first.pubDate
30
- assert_equal Time.parse("Fri Sep 09 02:52:31 PDT 2005"), @rss09.channel.dc_date
31
- end
32
-
33
- def test_media_rss
34
- assert_equal 20, @media_rss.items.size
35
- assert_equal "Uploads from herval", @media_rss.title
36
- assert_equal "http://www.flickr.com/photos/herval/", @media_rss.channel.link
37
- assert_equal "http://www.flickr.com/photos/herval/4671960608/", @media_rss.items.first.link
38
- assert_equal "http://www.flickr.com/photos/herval/4671960608/", @media_rss.items.first[:link]
39
- assert_equal "http://farm5.static.flickr.com/4040/4671960608_10cb945d5c_o.jpg", @media_rss.items.first.media_content_url
40
- assert_equal "image/jpeg", @media_rss.items.first.media_content_type
41
- assert_equal "3168", @media_rss.items.first.media_content_height
42
- assert_equal "4752", @media_rss.items.first.media_content_width
43
- assert_equal "Woof?", @media_rss.items.first.media_title
44
- assert_equal "http://farm5.static.flickr.com/4040/4671960608_954d2297bc_s.jpg", @media_rss.items.first.media_thumbnail_url
45
- assert_equal "75", @media_rss.items.first.media_thumbnail_height
46
- assert_equal "75", @media_rss.items.first.media_thumbnail_width
47
- assert_equal "herval", @media_rss.items.first.media_credit
48
- assert_equal "photographer", @media_rss.items.first.media_credit_role
49
- assert_equal "pets frodo", @media_rss.items.first.media_category
50
- assert_equal "urn:flickr:tags", @media_rss.items.first.media_category_scheme
51
- end
52
-
53
- def test_rss20
54
- assert_equal 10, @rss20.items.size
55
- assert_equal "Technoblog", @rss20.title
56
- assert_equal "http://tech.rufy.com", @rss20.channel.link
57
- assert_equal "http://feeds.feedburner.com/rufytech?m=68", @rss20.items.first.link
58
- assert_equal "http://feeds.feedburner.com/rufytech?m=68", @rss20.items.first[:link]
59
- assert_equal "This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site.", @rss20.channel.feedburner_browserFriendly
60
- end
61
-
62
- def test_atom
63
- assert_equal 1, @atom.entries.size
64
- assert_equal "dive into mark", @atom.title
65
- assert_equal "http://example.org/", @atom.feed.link
66
- assert_equal "http://example.org/2005/04/02/atom", @atom.entries.first.link
67
- assert_equal "http://example.org/2005/04/02/atom", @atom.entries.first[:link]
68
- end
69
-
70
- def test_bad_feed
71
- assert_raise(SimpleRSSError) { SimpleRSS.parse(open(File.dirname(__FILE__) + "/../data/not-rss.xml")) }
72
- end
73
-
74
- def test_rss_utf8
75
- assert_equal 2, @rss20_utf8.items.size
76
- assert_equal "SC5 Blog", @rss20_utf8.title
77
- assert_equal Encoding::UTF_8, @rss20_utf8.title.encoding
78
- item = @rss20_utf8.items.first
79
- assert_equal "Mitä asiakkaamme ajattelevat meistä?", item.title
80
- assert_equal Encoding::UTF_8, item.title.encoding
81
- end
82
5
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudenv-hq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-10-10 00:00:00.000000000 Z
@@ -84,7 +84,7 @@ homepage: https://github.com/cloudenvhq/cloudenv-ruby
84
84
  licenses:
85
85
  - MIT
86
86
  metadata: {}
87
- post_install_message:
87
+ post_install_message:
88
88
  rdoc_options: []
89
89
  require_paths:
90
90
  - lib
@@ -99,8 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.0.3
103
- signing_key:
102
+ rubygems_version: 3.2.3
103
+ signing_key:
104
104
  specification_version: 4
105
105
  summary: Keep your ENV vars synced between your team members
106
106
  test_files: []