BibOpsworks 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 17d9198e5b80c83a651f659464d021699f13df71
4
- data.tar.gz: 7d698c23931a5d5c9e4c39c57ccf24f94c38e0db
3
+ metadata.gz: adae563a8593de469e4cbf116f07573b5212498a
4
+ data.tar.gz: 425726bfe06f281f9324621747dd038afe8c9955
5
5
  SHA512:
6
- metadata.gz: d8bfbc99a283bdd50f703fe62fb216051aecc21abb825f5cc36602a36bfbba15bdcf8dec145fb5dfa1ca0f4119d39ac98566e256e03932cef0331580f9caf82e
7
- data.tar.gz: 8386a8b06db7a8179678974e508fd9e086bddb78067bc51579d434541b3c2b4525929dd203cdbc75d407e2d49049a004b7d93d8feb17bb3d588431946b936eef
6
+ metadata.gz: 133a277ee9bf1ae15e2d164da697c1783b9f3eebe21ca87915fddebdd7c9a503b8ebe3c44437bd0743ac4c56187ffe371c08ea6a23371a3a03fb69b37565cf42
7
+ data.tar.gz: 7ac2cff747a03524db8dff63100b5e1451f17ae52f2f2f548b0c4c54623cc9b4bec8e438a79fac6c0a798ea531f0db89ab9f545e5175373d0ac6d8b979da9d20
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- BibOpsworks (0.0.2)
4
+ BibOpsworks (0.0.3)
5
5
  json
6
6
 
7
7
  GEM
data/lib/bib/opsworks.rb CHANGED
@@ -3,21 +3,18 @@ require 'bib/opsworks/newrelic'
3
3
  require 'bib/opsworks/version'
4
4
 
5
5
  class BibOpsworks
6
- def initialize(deploy_data)
7
- @deploy_data = deploy_data
8
- end
9
6
 
10
- def copy_composer(release_path)
11
- composer = Bib::Opsworks::Composer.new()
12
- composer.copy_vendor(release_path, @deploy_data)
7
+ def copy_composer(release_path, deploy_user)
8
+ composer = Bib::Opsworks::Composer.new
9
+ composer.copy_vendor(release_path, deploy_user)
13
10
  end
14
11
 
15
- def newrelic_publish_deployment(app_name, newrelic_api_key)
16
- newrelic = Bib::Opsworks::Newrelic.new()
17
- newrelic.publish_deployment(app_name, @deploy_data, newrelic_api_key)
12
+ def newrelic_publish_deployment(app_name, deploy_data, newrelic_api_key)
13
+ newrelic = Bib::Opsworks::Newrelic.new
14
+ newrelic.publish_deployment(app_name, deploy_data, newrelic_api_key)
18
15
  end
19
16
 
20
17
  def version
21
- return Bib::Opsworks::VERSION
18
+ Bib::Opsworks::VERSION
22
19
  end
23
20
  end
@@ -2,18 +2,18 @@ module Bib
2
2
  module Opsworks
3
3
  class Composer
4
4
 
5
- def copy_vendor(release_path, deploy_data)
5
+ def copy_vendor(release_path, deploy_user)
6
6
  app_current = ::File.expand_path("#{release_path}/../../current")
7
7
  vendor_dir = "#{app_current}/vendor"
8
-
9
- deploy_user = deploy_data['deploy_user']['user']
10
- deploy_group = deploy_data['deploy_user']['group']
8
+
9
+ deploy_username = deploy_user['user']
10
+ deploy_group = deploy_user['group']
11
11
 
12
12
  release_vendor = "#{release_path}/vendor"
13
-
13
+
14
14
  ::FileUtils.cp_r vendor_dir, release_vendor if ::File.exists?(vendor_dir)
15
- ::FileUtils.chown_R deploy_user, deploy_group, release_vendor if ::File.exists?(release_vendor)
15
+ ::FileUtils.chown_R deploy_username, deploy_group, release_vendor if ::File.exists?(release_vendor)
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -4,27 +4,20 @@ module Bib
4
4
  class Newrelic
5
5
 
6
6
  def publish_deployment(app_name, deploy_data, newrelic_api_key)
7
-
8
7
  newrelic_body = prepare_publishing_data(app_name, deploy_data)
9
-
8
+
10
9
  newrelic_url = "https://rpm.newrelic.com/deployments.xml"
11
10
  url = URI.parse(newrelic_url)
12
11
  request = Net::HTTP::Post.new(url.request_uri)
13
12
  request.add_field('X-License-Key', newrelic_api_key)
14
13
  request.body = newrelic_body
15
14
  resp = Net::HTTP.new(url.host, url.port).start do |http|
16
- http.request(request)
17
- end
18
-
19
- case resp
20
- when Net::HTTPOK
21
- return true
22
- else
23
- return false
15
+ http.request(request)
24
16
  end
25
-
17
+
18
+ resp.is_a? Net::HTTPOK
26
19
  end
27
-
20
+
28
21
  def prepare_publishing_data(app_name, deploy_data)
29
22
  scm_revision = deploy_data["scm"]["revision"]
30
23
 
@@ -33,16 +26,13 @@ module Bib
33
26
  else
34
27
  deployment_user = deploy_data["deploying_user"].split('/')[1]
35
28
  end
36
-
29
+
37
30
  newrelic_appid_body = "deployment[app_name]=#{app_name}"
38
31
  newrelic_user_body = "deployment[user]=#{deployment_user}"
39
32
  newrelic_revision_body = "deployment[revision]=#{scm_revision}"
40
-
41
- newrelic_body = "#{newrelic_appid_body}&#{newrelic_user_body}&=#{newrelic_revision_body}"
42
-
43
- return newrelic_body
44
-
33
+
34
+ "#{newrelic_appid_body}&#{newrelic_user_body}&#{newrelic_revision_body}"
45
35
  end
46
36
  end
47
37
  end
48
- end
38
+ end
@@ -1,5 +1,5 @@
1
1
  module Bib
2
2
  module Opsworks
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ class ComposerTest < Minitest::Test
8
8
  @fixtures_path ||= Pathname.new(File.expand_path('../tmp-fixtures/', __FILE__)).tap{|path|
9
9
  FileUtils.mkdir_p path.to_s
10
10
  }
11
-
11
+
12
12
  @release_path = Pathname.new(File.expand_path('releases/123/', @fixtures_path))
13
13
  FileUtils.mkdir_p @release_path
14
14
  FileUtils.mkdir_p Pathname.new(File.expand_path('current/vendor/some-lib', @fixtures_path))
@@ -17,14 +17,14 @@ class ComposerTest < Minitest::Test
17
17
  def teardown
18
18
  FileUtils.rm_rf @fixtures_path
19
19
  end
20
-
20
+
21
21
  def test_composer_copy
22
- composervendor = Bib::Opsworks::Composer.new()
23
-
22
+ composervendor = Bib::Opsworks::Composer.new
23
+
24
24
  #do not use www-data, or the test will fail on systems without that user
25
- deploydata = { 'deploy_user' => { 'user' => Process.uid, 'group' => Process.gid }}
26
-
27
- composervendor.copy_vendor(@release_path, deploydata)
25
+ deploy_user = { 'user' => Process.uid, 'group' => Process.gid }
26
+
27
+ composervendor.copy_vendor(@release_path, deploy_user)
28
28
  assert_equal(true,::File.exists?(File.expand_path('releases/123/vendor/some-lib',@fixtures_path)))
29
29
  end
30
30
  end
@@ -4,24 +4,24 @@ require 'minitest/autorun'
4
4
  require 'bib/opsworks/newrelic'
5
5
 
6
6
  class NewrelicTest < Minitest::Test
7
-
7
+
8
8
  def test_publish_deployment
9
- newrelic = Bib::Opsworks::Newrelic.new()
10
-
9
+ newrelic = Bib::Opsworks::Newrelic.new
10
+
11
11
  deploy_data = { 'deploying_user' => 'arn:aws:iam::123456:user/gemtest', 'scm' => { 'revision' => 'rev1' } }
12
12
  app_name = 'unittest'
13
-
13
+
14
14
  result = newrelic.prepare_publishing_data(app_name, deploy_data)
15
- assert_equal("deployment[app_name]=unittest&deployment[user]=gemtest&=deployment[revision]=rev1", result)
15
+ assert_equal("deployment[app_name]=unittest&deployment[user]=gemtest&deployment[revision]=rev1", result)
16
16
  end
17
-
17
+
18
18
  def test_publish_deployment_nouser
19
- newrelic = Bib::Opsworks::Newrelic.new()
20
-
19
+ newrelic = Bib::Opsworks::Newrelic.new
20
+
21
21
  deploy_data = { 'scm' => { 'revision' => 'rev1' } }
22
22
  app_name = 'unittest'
23
-
23
+
24
24
  result = newrelic.prepare_publishing_data(app_name, deploy_data)
25
- assert_equal("deployment[app_name]=unittest&deployment[user]=opsworks&=deployment[revision]=rev1", result)
25
+ assert_equal("deployment[app_name]=unittest&deployment[user]=opsworks&deployment[revision]=rev1", result)
26
26
  end
27
27
  end
@@ -0,0 +1,11 @@
1
+ gem 'minitest'
2
+
3
+ require 'minitest/autorun'
4
+ require 'bib/opsworks'
5
+
6
+ class OpsworksTest < Minitest::Test
7
+
8
+ def test_version
9
+ assert_equal("0.0.3", BibOpsworks.new.version)
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BibOpsworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-29 00:00:00.000000000 Z
12
+ date: 2013-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -99,9 +99,9 @@ files:
99
99
  - lib/bib/opsworks/composer.rb
100
100
  - lib/bib/opsworks/newrelic.rb
101
101
  - lib/bib/opsworks/version.rb
102
- - tests/bib_test.rb
103
102
  - tests/composer_test.rb
104
103
  - tests/newrelic_test.rb
104
+ - tests/opsworks_test.rb
105
105
  homepage: https://github.com/easybiblabs/bib-opsworks
106
106
  licenses: []
107
107
  metadata: {}
data/tests/bib_test.rb DELETED
@@ -1,12 +0,0 @@
1
- gem 'minitest'
2
-
3
- require 'minitest/autorun'
4
- require 'bib/opsworks'
5
-
6
- class BibTest < Minitest::Test
7
-
8
- def test_version
9
- bib = BibOpsworks.new({})
10
- assert_equal("0.0.2", bib.version())
11
- end
12
- end