ya_queen 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: 188def4d83c25a97161f7d6b4660ca7ebd7634ed
4
- data.tar.gz: f185ed0ccf28d12b4446d6afb9343143ede5e0b7
3
+ metadata.gz: da0f3c18c135fa7c37a23c757a1d91ea35811dc5
4
+ data.tar.gz: 413c03e7f41c53f4d26355aefaa44c22da587cbb
5
5
  SHA512:
6
- metadata.gz: 70d2e931e3e0eae926314cee099955fbcc742f5524ec88c017e3cd2cbf400dc4987c98a42a0bdad53b6fb8b12d1d0a479baaa79d4d5778de29ff8fc84e360d82
7
- data.tar.gz: edb6430f18333aeac1879f2b5d96837ded83a0ca7eff8cecbb7b7364ecc3052f349cd43c2307018dad549d24a1e515917df46958d261f7f8bd1e3374a7014272
6
+ metadata.gz: 3a18eff162e5f202a424d324497c483c2c6a58da7830ce69bee7c45ab34df7ce2170ba1e5e13a83fda9fc01a74633ed7fbe828db29b9584bebc75a8171138c43
7
+ data.tar.gz: d40333158e6f91ca99af27981356ff9c01a7c2cdb14702784797a8746dbea3b103ac38bd86607493beebb712f5555f24e7f42c8d2082e8405e4a27905617f924
data/lib/ya_queen/base.rb CHANGED
@@ -30,27 +30,42 @@ module YaQueen
30
30
  def define_tasks
31
31
  return if servers.nil? or servers.empty?
32
32
 
33
- t = self
34
- task(:"@#{name}"){ t.define_role_task }
33
+ define_role_task
35
34
 
36
35
  servers.each do |host, options|
37
36
  after :"@#{name}", :"@#{name}/#{host}"
38
- task( :"@#{name}/#{host}"){ t.define_each_task(host, options) }
37
+ define_each_task(host, options)
39
38
  after :"@#{name}/#{host}", :"@#{name}/common"
40
39
  end
41
- task(:"@#{name}/common") do
42
- t.define_common_task
43
- t.set_deploy_target("@#{name}")
44
- end
40
+ define_common_task
45
41
  end
46
42
 
47
43
  def role_task(&block) ; @role_task = block; end
48
44
  def common_task(&block); @common_task = block; end
49
45
  def each_task(&block) ; @each_task = block; end
50
46
 
51
- def define_role_task ; @role_task.call if @role_task; end
52
- def define_common_task; @common_task.call if @common_task; end
53
- def define_each_task(host, options); @each_task.call(host, options) if @each_task; end
47
+ def implement_role_task ; @role_task.call if @role_task; end
48
+ def implement_common_task; @common_task.call if @common_task; end
49
+ def implement_each_task(host, options); @each_task.call(host, options) if @each_task; end
50
+
51
+ def define_role_task
52
+ t = self
53
+ task(:"@#{name}"){ t.implement_role_task }
54
+ end
55
+
56
+ def define_common_task
57
+ t = self
58
+ task(:"@#{name}/common") do
59
+ t.implement_common_task
60
+ t.set_deploy_target("@#{name}")
61
+ end
62
+ end
63
+
64
+ def define_each_task(host, options)
65
+ t = self
66
+ task( :"@#{name}/#{host}"){ t.implement_each_task(host, options) }
67
+ end
68
+
54
69
 
55
70
  ## デプロイ先サーバ・ディレクトリ選択時に異なる種類のデプロイ対象を選択できないようにする
56
71
  ## (cap vagrant @apisrv-a01 @gotool01 deploy:update などをできないようにする)
@@ -1,3 +1,3 @@
1
1
  module YaQueen
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/test01.yml ADDED
@@ -0,0 +1,21 @@
1
+ default: &default
2
+ user: 'op1'
3
+ repository: "git@github.com:groovenauts/ya_queen.git"
4
+
5
+ api_server:
6
+ <<: *default
7
+ deploy_to: '/srv/ya_queen/api_server'
8
+ servers:
9
+ api_server01:
10
+ no: 1
11
+ api_server02:
12
+ no: 2
13
+
14
+ backend:
15
+ <<: *default
16
+ deploy_to: '/srv/ya_queen/backend'
17
+ servers:
18
+ backend01:
19
+ no: 1
20
+ backend02:
21
+ no: 2
@@ -1,11 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
+ require 'yaml'
4
+
3
5
  describe YaQueen do
4
6
  it 'should have a version number' do
5
7
  YaQueen::VERSION.should_not be_nil
6
8
  end
7
9
 
8
- it 'should do something useful' do
9
- false.should be_true
10
+ it 'should build tasks' do
11
+ context = mock(:context)
12
+ expect(context).to receive(:task).with(:"@api_server")
13
+
14
+ %w[api_server01 api_server02].each do |host|
15
+ expect(context).to receive(:after).with(:"@api_server", :"@api_server/#{host}")
16
+ expect(context).to receive(:task).with(:"@api_server/#{host}")
17
+ expect(context).to receive(:after).with(:"@api_server/#{host}", :"@api_server/common")
18
+ end
19
+
20
+ expect(context).to receive(:task).with(:"@api_server/common")
21
+
22
+ YaQueen.configure(context, File.expand_path("../test01.yml", __FILE__)) do |c|
23
+ c.define_server_tasks(:api_server)
24
+ end
10
25
  end
11
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ya_queen
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
  - akima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - lib/ya_queen/config.rb
72
72
  - lib/ya_queen/version.rb
73
73
  - spec/spec_helper.rb
74
+ - spec/test01.yml
74
75
  - spec/ya_queen_spec.rb
75
76
  - ya_queen.gemspec
76
77
  homepage: https://github.com/groovenauts/ya_queen
@@ -99,5 +100,6 @@ specification_version: 4
99
100
  summary: ya_queen supports to define complicated capistrano tasks and roles
100
101
  test_files:
101
102
  - spec/spec_helper.rb
103
+ - spec/test01.yml
102
104
  - spec/ya_queen_spec.rb
103
105
  has_rdoc: