webistrano_cli 0.0.1 → 0.0.2
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.
- data/Gemfile.lock +1 -1
- data/bin/webistrano_cli +9 -3
- data/lib/webistrano_cli.rb +9 -18
- data/lib/webistrano_cli/config.rb +54 -0
- data/lib/webistrano_cli/version.rb +1 -1
- metadata +15 -14
data/Gemfile.lock
CHANGED
data/bin/webistrano_cli
CHANGED
@@ -9,7 +9,9 @@ require 'slop'
|
|
9
9
|
require 'webistrano_cli'
|
10
10
|
|
11
11
|
# parse assumes ARGV, otherwise you can pass it your own Array
|
12
|
-
opts = Slop.
|
12
|
+
opts = Slop.new :help => true do
|
13
|
+
banner 'Usage: webistrano_cli -p project_name'
|
14
|
+
description 'command allow to deploy projects from webistrano'
|
13
15
|
on :p, :project, 'Project name', true
|
14
16
|
on :s, :stage, 'Stage', true
|
15
17
|
on :t, :task, 'Task', true
|
@@ -17,5 +19,9 @@ opts = Slop.parse :help => true do
|
|
17
19
|
puts 'Version 0.0.1'
|
18
20
|
end
|
19
21
|
end
|
20
|
-
|
21
|
-
opts.
|
22
|
+
begin
|
23
|
+
opts.parse
|
24
|
+
opts.p? ? WebistranoCli.deploy(opts.to_hash) : (puts(opts.help) unless opts.v?)
|
25
|
+
rescue Slop::Error => ex
|
26
|
+
puts ex.message
|
27
|
+
end
|
data/lib/webistrano_cli.rb
CHANGED
@@ -1,29 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'highline/import'
|
3
3
|
require 'webistrano_cli/version'
|
4
|
+
require 'webistrano_cli/config'
|
4
5
|
require 'webistrano_cli/task'
|
5
6
|
|
6
7
|
module WebistranoCli
|
7
8
|
class << self
|
8
9
|
def deploy opts = {}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
next if config[field]
|
18
|
-
config[field] = ask("webistrano #{field}: ") do |q|
|
19
|
-
q.whitespace = :strip_and_collapse
|
20
|
-
q.validate = lambda { |p| p.length > 0 }
|
21
|
-
q.responses[:not_valid] = "can't be blank!"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
[Project, Stage, Deployment].each { |model| model.configure(config) }
|
26
|
-
Task.new(project, stage, task).run
|
10
|
+
config = Config.new
|
11
|
+
config_hash = Config.new.get
|
12
|
+
[Project, Stage, Deployment].each { |model| model.configure(config_hash) }
|
13
|
+
Task.new(
|
14
|
+
opts[:project],
|
15
|
+
config.stage(opts[:stage]),
|
16
|
+
config.task(opts[:task])
|
17
|
+
).run
|
27
18
|
end
|
28
19
|
end
|
29
20
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'yaml'
|
3
|
+
module WebistranoCli
|
4
|
+
class Config
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@file_path = File.expand_path('~/.webistrano_cli.yml')
|
8
|
+
if File.exists?(@file_path)
|
9
|
+
@config = YAML.load_file(@file_path) rescue nil
|
10
|
+
else
|
11
|
+
@config = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get
|
16
|
+
config = {}
|
17
|
+
|
18
|
+
[:site, :user,:password].each do |field|
|
19
|
+
config[field] = ENV["WCLI_#{field.to_s.upcase}"] || (@config['webistrano_cli'][field.to_s] rescue nil)
|
20
|
+
next if config[field]
|
21
|
+
config[field] = ask("webistrano #{field}: ") do |q|
|
22
|
+
q.whitespace = :strip_and_collapse
|
23
|
+
q.validate = lambda { |p| p.length > 0 }
|
24
|
+
q.responses[:not_valid] = "can't be blank!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
File.open(@file_path, 'w') do |f|
|
29
|
+
obj = {
|
30
|
+
'webistrano_cli' => {
|
31
|
+
'site' => config[:site],
|
32
|
+
'user' => config[:user],
|
33
|
+
'password' => config[:password],
|
34
|
+
'defaults' => {
|
35
|
+
'stage' => 'staging',
|
36
|
+
'task' => 'deploy:migrations'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
YAML.dump obj, f
|
41
|
+
end unless File.exists?(@file_path)
|
42
|
+
config
|
43
|
+
end
|
44
|
+
|
45
|
+
def stage opt
|
46
|
+
opt || (@config['webistrano_cli']['defaults']['stage'] rescue nil) || 'staging'
|
47
|
+
end
|
48
|
+
|
49
|
+
def task opt
|
50
|
+
opt || (@config['webistrano_cli']['defaults']['task'] rescue nil) || 'deploy:migrations'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webistrano_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-03 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &2157636100 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2157636100
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: slop
|
28
|
-
requirement: &
|
28
|
+
requirement: &2157635080 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2157635080
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: highline
|
39
|
-
requirement: &
|
39
|
+
requirement: &2157634160 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2157634160
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: mechanize
|
50
|
-
requirement: &
|
50
|
+
requirement: &2157633560 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2157633560
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: activeresource
|
61
|
-
requirement: &
|
61
|
+
requirement: &2157633020 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - <
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: 3.1.0
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2157633020
|
70
70
|
description: Allow to deploy projects from webistrano via console
|
71
71
|
email:
|
72
72
|
- dariusz.gertych@gmail.com
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- bin/webistrano_cli
|
85
85
|
- lib/webistrano_cli.rb
|
86
|
+
- lib/webistrano_cli/config.rb
|
86
87
|
- lib/webistrano_cli/deployment.rb
|
87
88
|
- lib/webistrano_cli/project.rb
|
88
89
|
- lib/webistrano_cli/stage.rb
|
@@ -104,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
105
|
version: '0'
|
105
106
|
segments:
|
106
107
|
- 0
|
107
|
-
hash: -
|
108
|
+
hash: -1627625348420381559
|
108
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
110
|
none: false
|
110
111
|
requirements:
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: '0'
|
114
115
|
segments:
|
115
116
|
- 0
|
116
|
-
hash: -
|
117
|
+
hash: -1627625348420381559
|
117
118
|
requirements: []
|
118
119
|
rubyforge_project: webistrano_cli
|
119
120
|
rubygems_version: 1.6.2
|