cloudenv-hq 0.1.3 → 0.2.8

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: 61908e7704a50ec6b47dbd0338a6e1543011a5608397b8f249eed13ef7f2f53b
4
- data.tar.gz: 9943a3960721ccf85fc6c26a000e224d82c16069cf099fa04cd9ab91377c4bb8
3
+ metadata.gz: 987cb4343dc95e07ffda2c04ecd4a1f752238bd31bfeeeb41fa440c150a99404
4
+ data.tar.gz: ba78b1131e83eb7d514a0086486ef7552b945133721a39663d7b2da15a1c11fb
5
5
  SHA512:
6
- metadata.gz: c0c26bc92380a56a37af75131c90f52066e270662ea6d32c255d7ebf098e92dff913cd99ce3416ad4f4951352f4eada91f1a5f6d09e87f54a38324b9f9bf2f65
7
- data.tar.gz: 5f52495103a3f2f3dffc2e802ef3b7fee43dd116536c2b64c59cfa2b5d8bfa5353cf488d90cb536eb14d125a571d6ff6c9280ca589ebd0929836cb694633f84d
6
+ metadata.gz: 58c005f8881fc66f0cf63dc3843baf65784705356be282f09ab703b87b7fc7ec4bb8af77394b4661bbe91b4c915be4a6b14e91b039d6e0712e92226b7cfe1681
7
+ data.tar.gz: c144dc13bea071d56f76af8f824855f43ad8519c77442a1b8750050f7087f6357c1c5da4ed19eaa6b7ca3ddfb844df1f8db1d5d7042ac16bdae4adbf0b108b4d
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.3"
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.8'
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,45 +1,65 @@
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.3".freeze
7
+ VERSION = '0.2.8'.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 = ENV["CLOUDENV_BEARER_TOKEN"] || `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_PATH'] || '~/.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_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))
23
35
 
36
+ @app = data['slug']
37
+ @secret_key = data['secret-key']
38
+ end
39
+ end
40
+
41
+ if @bearer && @app && @secret_key
24
42
  if @environment
25
- 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")
27
- 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: ''))
28
46
  file.close
29
47
  Dotenv.load(file.path)
30
48
  file.unlink
31
49
  end
32
50
 
33
- 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")
35
- 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: ''))
36
54
  file.close
55
+ puts 1
37
56
  Dotenv.load(file.path)
38
57
  file.unlink
58
+
39
59
  else
40
- warn "WARNING: cloudenv could not find a .cloudenv-secret-key in the directory path"
60
+ 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
61
  end
42
62
  end
43
63
  end
44
64
 
45
- CloudenvHQ.new(bearer: ENV["CLOUDENV_BEARER_PATH"])
65
+ 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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudenv-hq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson