capistrano-platform-resources 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,4 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Capistrano::Configuration::Resources::PlatformResources::VERSION
17
17
 
18
18
  gem.add_dependency("capistrano")
19
- gem.add_development_dependency("net-scp", "~> 1.0.4")
20
- gem.add_development_dependency("net-ssh", "~> 2.2.2")
21
- gem.add_development_dependency("vagrant", "~> 1.0.6")
22
19
  end
@@ -21,30 +21,68 @@ module Capistrano
21
21
  EOS
22
22
  end
23
23
 
24
- _cset(:platform_identifier) { platform.identifier(fetch(:platform_identifier_options, {})) }
25
- def identifier(options={})
26
- options = options.dup
27
- family = ( options.delete(:family) || fetch(:platform_family) )
28
- case family
24
+ _cset(:platform_lsb_packages) {
25
+ case platform_family
29
26
  when :debian
30
- capture((<<-EOS).gsub(/\s+/, " "), options).strip.to_sym
31
- if test -f /etc/lsb-release && grep -i -q DISTRIB_ID=Ubuntu /etc/lsb-release; then
32
- echo ubuntu;
33
- else
34
- echo debian;
35
- fi;
36
- EOS
27
+ %w(lsb-release lsb-core)
37
28
  when :redhat
38
- capture((<<-EOS).gsub(/\s+/, " "), options).strip.to_sym
39
- if test -f /etc/centos-release; then
40
- echo centos;
41
- else
42
- echo redhat;
43
- fi;
44
- EOS
29
+ %w(redhat-lsb)
45
30
  else
46
- :unknown
31
+ []
47
32
  end
33
+ }
34
+
35
+ def lsb_setup(options={})
36
+ if fetch(:platform_setup, false)
37
+ false
38
+ else
39
+ lsb_setup!(options)
40
+ set(:platform_setup, true)
41
+ true
42
+ end
43
+ end
44
+
45
+ def lsb_setup!(options={})
46
+ platform.packages.install(platform_lsb_packages, options)
47
+ end
48
+
49
+ _cset(:platform_identifier) { platform.identifier(fetch(:platform_identifier_options, {})) }
50
+ def identifier(options={})
51
+ options = options.dup
52
+ options.delete(:family) # for backward compatibility
53
+ lsb_identifier(options)
54
+ end
55
+
56
+ def lsb_identifier(options={})
57
+ lsb_setup(options)
58
+ identifier = capture("lsb_release --id --short || true", options).strip.downcase
59
+ not(codename.empty?) ? identifier.to_sym : :unknown
60
+ end
61
+
62
+ _cset(:platform_release) { platform.release(fetch(:platform_release_options, {})) }
63
+ def release(options={})
64
+ options = options.dup
65
+ options.delete(:family) # for backward compatibility
66
+ lsb_release(options)
67
+ end
68
+
69
+ def lsb_release(options={})
70
+ lsb_setup(options)
71
+ release = capture("lsb_release --release --short || true", options).strip.downcase
72
+ not(release.empty?) ? release.to_sym : :unknown
73
+ end
74
+
75
+ _cset(:platform_codename) { platform.codename(fetch(:platform_codename_options, {})) }
76
+ def codename(options={})
77
+ options = options.dup
78
+ options.delete(:family) # for backward compatibility
79
+ lsb_codename(options)
80
+ end
81
+
82
+ def lsb_codename(options={})
83
+ lsb_setup(options)
84
+ codename = capture("lsb_release --codename --short || true", options).strip.downcase
85
+ not(codename.empty?) ? codename.to_sym : :unknown
48
86
  end
49
87
 
50
88
  _cset(:platform_architecture) { platform.architecture(fetch(:platform_architecture_options, {})) }
@@ -76,7 +114,15 @@ module Capistrano
76
114
  end
77
115
 
78
116
  def install(packages=[], options={})
79
- try_update(options)
117
+ if installed?(packages, options)
118
+ false
119
+ else
120
+ install!(packages, options)
121
+ end
122
+ end
123
+
124
+ def install!(packages=[], options={})
125
+ update(options)
80
126
  options = options.dup
81
127
  packages = [ packages ].flatten
82
128
  family = ( options.delete(:family) || fetch(:platform_family) )
@@ -91,6 +137,14 @@ module Capistrano
91
137
  end
92
138
 
93
139
  def uninstall(packages=[], options={})
140
+ if installed?(packages, options)
141
+ uninstall!(packages, options)
142
+ else
143
+ false
144
+ end
145
+ end
146
+
147
+ def uninstall!(packages=[], options={})
94
148
  options = options.dup
95
149
  packages = [ packages ].flatten
96
150
  family = ( options.delete(:family) || fetch(:platform_family) )
@@ -104,14 +158,18 @@ module Capistrano
104
158
  end
105
159
  end
106
160
 
107
- def try_update(options={})
108
- unless fetch(:platform_packages_updated, false)
109
- update(options)
161
+ def update(options={})
162
+ if fetch(:platform_packages_updated, false)
163
+ false
164
+ else
165
+ update!(options)
110
166
  set(:platform_packages_updated, true)
167
+ true
111
168
  end
112
169
  end
170
+ alias try_update update # for backward compatibility before 0.1.2
113
171
 
114
- def update(options={})
172
+ def update!(options={})
115
173
  options = options.dup
116
174
  family = ( options.delete(:family) || fetch(:platform_family) )
117
175
  case family
@@ -123,7 +181,17 @@ module Capistrano
123
181
  end
124
182
 
125
183
  def upgrade(options={})
126
- try_update(options)
184
+ if fetch(:platform_packages_upgraded, false)
185
+ false
186
+ else
187
+ upgrade!(options)
188
+ set(:platform_packages_upgraded, true)
189
+ true
190
+ end
191
+ end
192
+
193
+ def upgrade!(options={})
194
+ update(options)
127
195
  options = options.dup
128
196
  family = ( options.delete(:family) || fetch(:platform_family) )
129
197
  case family
@@ -2,7 +2,7 @@ module Capistrano
2
2
  class Configuration
3
3
  module Resources
4
4
  module PlatformResources
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  /.bundle
2
- /.vagrant
2
+ /.vagrant*
3
3
  /known_hosts
4
4
  /tmp
5
5
  /vendor
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh -e
2
2
 
3
- bundle exec vagrant up
3
+ vagrant up
4
4
  bundle exec cap test_all
5
- bundle exec vagrant halt
5
+ vagrant halt
6
6
 
7
7
  # vim:set ft=sh :
@@ -8,7 +8,11 @@ set :scm, :none
8
8
  set :use_sudo, false
9
9
  set :user, "vagrant"
10
10
  set :password, "vagrant"
11
- set :ssh_options, {:user_known_hosts_file => "/dev/null"}
11
+ set :ssh_options, {
12
+ :auth_methods => %w(publickey password),
13
+ :keys => File.join(ENV["HOME"], ".vagrant.d", "insecure_private_key"),
14
+ :user_known_hosts_file => "/dev/null"
15
+ }
12
16
 
13
17
  role :web, "192.168.33.10"
14
18
  role :app, "192.168.33.10"
@@ -1,5 +1,5 @@
1
1
  /.bundle
2
- /.vagrant
2
+ /.vagrant*
3
3
  /known_hosts
4
4
  /tmp
5
5
  /vendor
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh -e
2
2
 
3
- bundle exec vagrant up
3
+ vagrant up
4
4
  bundle exec cap test_all
5
- bundle exec vagrant halt
5
+ vagrant halt
6
6
 
7
7
  # vim:set ft=sh :
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-platform-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -27,54 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: net-scp
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.0.4
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.0.4
46
- - !ruby/object:Gem::Dependency
47
- name: net-ssh
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 2.2.2
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 2.2.2
62
- - !ruby/object:Gem::Dependency
63
- name: vagrant
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.0.6
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.0.6
78
30
  description: A sort of utilities which helps you to manage platform resources.
79
31
  email:
80
32
  - yamashita@geishatokyo.com