capistrano-psw 1.0.0.pre8 → 1.0.0.pre9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 334c8a67ca34fd8b888875163998a666002085d9
4
- data.tar.gz: 29cbc92f289bc5cce26289489a25aea7648cb29d
3
+ metadata.gz: 30b41edefc58312d17a0281e25d05782c87a68c4
4
+ data.tar.gz: a1b9ff31f479eb37e7216763a7ca2e08f231a9c4
5
5
  SHA512:
6
- metadata.gz: f6723621a43b99b27ca92d0486f0b309677c47bf42c77c48faa0f118d7440a67e5df9e839e8c41b3159d53b7cbc2e3d87071c3088c686ac46c92d56ec35514c4
7
- data.tar.gz: 848bbbbcbd79b808b0c0bca39b727541fcee89d06b2d7409b214f017fb2989a4b0752d30c55b1bab7669fcb7b01e2d00e03dbea5cd4eb5c1a1fc3a5be78c7783
6
+ metadata.gz: 02c00eed5742fe8c6e4640237a5b500a2565eaea20e72568ef23b5d9a3b57693766836a8f5b242980d90da52c8cf79c8aa0954c3b1d5e24c2ddda8456d32c92f
7
+ data.tar.gz: 15d5e55c4fff3deb6524d10ec4a8d23e7aa71372ce18f5a7eb70f9cf243a2460daf49bd754f08941681f99d9412792b911a3972c47b11a7973d11aaac71a36d7
@@ -0,0 +1,17 @@
1
+ require 'capistrano'
2
+ require 'json'
3
+
4
+ module Capistrano
5
+ module Psw
6
+ class ServerUtils
7
+ def self.get_servers_from_json (filename, stage_name)
8
+ raise ArgumentError, 'missing filename' if filename.nil? || filename.strip == ''
9
+ raise ArgumentError, 'missing stage_name' if stage_name.nil? || stage_name.strip == ''
10
+ stages = JSON.parse File.read filename
11
+ servers = stages[stage_name]
12
+
13
+ servers.map {|server| {name: server['name'], properties: server['properties']}}
14
+ end
15
+ end
16
+ end
17
+ end
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Capistrano
12
12
  module Psw
13
- VERSION = "1.0.0.pre8"
13
+ VERSION = "1.0.0.pre9"
14
14
  end
15
15
  end
@@ -0,0 +1,29 @@
1
+ require "rake"
2
+ require File.expand_path('../spec_helper.rb', __FILE__)
3
+
4
+ require 'capistrano/psw/server_utils'
5
+
6
+ describe "psw-cap-helpers" do
7
+ describe "ServerUtils" do
8
+ describe "get servers from json" do
9
+ it 'raises an argument error if no filename is supplied' do
10
+ expect {
11
+ Capistrano::Psw::ServerUtils.get_servers_from_json('', 'staging')
12
+ }.to raise_error(ArgumentError)
13
+ end
14
+
15
+ it 'raises an argument error if no stage is supplied' do
16
+ expect {
17
+ Capistrano::Psw::ServerUtils.get_servers_from_json('servers.json', '')
18
+ }.to raise_error(ArgumentError)
19
+ end
20
+
21
+ it 'fetches servers for the running stage' do
22
+ servers = Capistrano::Psw::ServerUtils.get_servers_from_json "#{File.expand_path('../servers.json', __FILE__)}", 'staging'
23
+ servers.length.should == 2
24
+ servers.any? {|server| server[:name] == 'stagingserver1.com'}.should be_true
25
+ servers.any? {|server| server[:name] == 'stagingserver2.com'}.should be_true
26
+ end
27
+ end
28
+ end
29
+ end
data/spec/servers.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "production": [
3
+ {
4
+ "name": "ec2-54-204-81-224.compute-1.amazonaws.com",
5
+ "properties": {
6
+ "user": "ubuntu",
7
+ "roles": ["web", "app", "db"],
8
+ "ssh_options": {
9
+ "user": "ubuntu",
10
+ "keys": "~/keys/twistage-default.pem",
11
+ "forward_agent": true,
12
+ "auth_methods": "publickey"
13
+ }
14
+ }
15
+ },
16
+ {
17
+ "name": "prodserver2.com",
18
+ "properties": {
19
+ "user": "ubuntu",
20
+ "roles": ["web", "app", "db"],
21
+ "ssh_options": {
22
+ "user": "ubuntu",
23
+ "keys": "~/keys/twistage-default.pem",
24
+ "forward_agent": true,
25
+ "auth_methods": "publickey"
26
+ }
27
+ }
28
+ }],
29
+ "staging": [
30
+ {
31
+ "name": "stagingserver1.com",
32
+ "properties": {
33
+ "roles": ["web", "app", "db"],
34
+ "ssh_options": {
35
+ "user": "ubuntu",
36
+ "keys": "~/keys/twistage-default.pem",
37
+ "forward_agent": true,
38
+ "auth_methods": "publickey"
39
+ }
40
+ }
41
+ },
42
+ {
43
+ "name": "stagingserver2.com",
44
+ "properties": {
45
+ "roles": ["web", "app", "db"],
46
+ "ssh_options": {
47
+ "user": "ubuntu",
48
+ "keys": "~/keys/twistage-default.pem",
49
+ "forward_agent": true,
50
+ "auth_methods": "publickey"
51
+ }
52
+ }
53
+ }]
54
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-psw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre8
4
+ version: 1.0.0.pre9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lexmark International Technology S.A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ files:
83
83
  - capistrano-psw.gemspec
84
84
  - ci/pipeline-config.json
85
85
  - lib/capistrano/psw.rb
86
+ - lib/capistrano/psw/server_utils.rb
86
87
  - lib/capistrano/psw/task_loader.rb
87
88
  - lib/capistrano/psw/version.rb
88
89
  - resources/lib/capistrano/tasks/psw-clockwork.cap
@@ -93,6 +94,8 @@ files:
93
94
  - spec/psw-peppr_spec.rb
94
95
  - spec/psw-repo_spec.rb
95
96
  - spec/psw-sidekiq_spec.rb
97
+ - spec/psw_cap_helpers_spec.rb
98
+ - spec/servers.json
96
99
  - spec/spec_helper.rb
97
100
  homepage: http://www.perceptivesoftware.com/
98
101
  licenses:
@@ -124,4 +127,6 @@ test_files:
124
127
  - spec/psw-peppr_spec.rb
125
128
  - spec/psw-repo_spec.rb
126
129
  - spec/psw-sidekiq_spec.rb
130
+ - spec/psw_cap_helpers_spec.rb
131
+ - spec/servers.json
127
132
  - spec/spec_helper.rb