cloudenv-hq 0.2.0 → 0.2.9

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: 2b5dd3d415383867dfcd30c58d3e67da659f42ef5f2d5148a4d126b12afb046b
4
- data.tar.gz: 57507d4f73d276419d3cacc39e9a5541f778a9a938d4a23aeabeb826ea82fb65
3
+ metadata.gz: 85e69bae05f3818ef2435b9cf9d2ad17d78b163da1dde7a8e020c66083da3f8a
4
+ data.tar.gz: bed96292b71e05bbc63c0c168ee6da4bf0925b1c96c01263a6d230fc98d262e9
5
5
  SHA512:
6
- metadata.gz: abdd25d1c92d5a6d77f25612b1c9c392fd402c56f11ab67133e8947e6e7decf07714dd2121f3fe79083765b1fe367d00e90ab3b2d0b896f07a1ee632a1301b6d
7
- data.tar.gz: b055d7ead49fed1fe41d8818351b2d2933c0f3621cd4dc673638a81abe8354ca89520a5abed276eaae3ca855c22300bc610c9168b51c0699e4603758f72f76c5
6
+ metadata.gz: e4e5b8d90fb65bf6beeb3a211ff92b011d70104301660a1e1ed03bc0e6d6772f65e9e246b9e4e113dcec7ab9c36362c2c5e057f0effa6c0b1a49ff72c54410eb
7
+ data.tar.gz: 1c1c24e4f5d37f83a5a328b2e55f9a88987ca262258cdccb561de5baf8c08f156da2de8847ddf22f895044040a85c29db51bb84ef94b47c38817de4f9eb5187a
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.2.0"
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.9'
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,49 +1,64 @@
1
- require "pathname"
2
- require "dotenv"
3
- require "tempfile"
4
- require "yaml"
1
+ require 'pathname'
2
+ require 'dotenv'
3
+ require 'tempfile'
4
+ require 'yaml'
5
5
 
6
6
  class CloudenvHQ
7
- VERSION = "0.2.0".freeze
7
+ VERSION = '0.2.9'.freeze
8
8
 
9
- API_HOST = "https://app.cloudenv.com".freeze
10
- READ_PATH = "/api/v1/envs".freeze
9
+ API_HOST = 'https://app.cloudenv.com'.freeze
10
+ READ_PATH = '/api/v1/envs'.freeze
11
11
 
12
- def initialize(options={})
13
- @environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"]
14
- @bearer = ENV["CLOUDENV_BEARER_TOKEN"] || `cat #{options[:bearer] || "~/.cloudenvrc"}`.strip
15
- @secret_key_filename = ".cloudenv-secret-key"
16
- @secret_key = Pathname.new(@secret_key_filename)
12
+ def initialize(options = {})
13
+ @environment = ENV['RAILS_ENV'] || ENV['RACK_ENV']
17
14
 
18
- until File.exists?(@secret_key) || @secret_key.expand_path == Pathname.new("/.cloudenv-secret-key")
19
- @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_PATH'] || '~/.cloudenvrc')
19
+ @bearer = IO.read(@bearer_filename).to_s.strip if File.exist?(@bearer_filename)
20
20
  end
21
21
 
22
- if File.exists?(@secret_key)
23
- data = YAML.load(IO.read(@secret_key))
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_PATH'] || '.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.split('/').last
31
+ end
32
+
33
+ if File.exist?(@secret_key)
34
+ data = YAML.safe_load(IO.read(@secret_key))
24
35
 
25
- @app = data["slug"]
26
- @secret_key = data["secret-key"]
36
+ @app = data['slug']
37
+ @secret_key = data['secret-key']
38
+ end
39
+ end
27
40
 
41
+ if @bearer && @app && @secret_key
28
42
  if @environment
29
- 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`
30
- file = Tempfile.new("cloudenv")
31
- file.write(data)
43
+ data = `curl -s -H "Authorization: Bearer #{@bearer}" "#{API_HOST}#{READ_PATH}?name=#{@app}&environment=#{@environment}&version=#{VERSION}&lang=ruby" | openssl enc -a -aes-256-cbc -md sha512 -d -pass pass:"#{@secret_key}" 2> /dev/null`
44
+ file = Tempfile.new('cloudenv')
45
+ file.write(data.encode('UTF-8', invalid: :replace, replace: ''))
32
46
  file.close
33
47
  Dotenv.load(file.path)
34
48
  file.unlink
35
49
  end
36
50
 
37
- 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`
38
- file = Tempfile.new("cloudenv")
39
- file.write(data)
51
+ data = `curl -s -H "Authorization: Bearer #{@bearer}" "#{API_HOST}#{READ_PATH}?name=#{@app}&environment=default&version=#{VERSION}&lang=ruby" | openssl enc -a -aes-256-cbc -md sha512 -d -pass pass:"#{@secret_key}" 2> /dev/null`
52
+ file = Tempfile.new('cloudenv')
53
+ file.write(data.encode('UTF-8', invalid: :replace, replace: ''))
40
54
  file.close
41
55
  Dotenv.load(file.path)
42
56
  file.unlink
57
+
43
58
  else
44
- warn "WARNING: cloudenv could not find a .cloudenv-secret-key in the directory path"
59
+ 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"]'
45
60
  end
46
61
  end
47
62
  end
48
63
 
49
- CloudenvHQ.new(bearer: ENV["CLOUDENV_BEARER_PATH"])
64
+ 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.2.0
4
+ version: 0.2.9
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: []