stackfu 0.1.0 → 0.1.1
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/Rakefile +1 -1
- data/lib/stackfu.rb +15 -2
- data/lib/stackfu/api_hooks.rb +13 -8
- data/lib/stackfu/commands/dump_command.rb +37 -21
- data/lib/stackfu/commands/list_command.rb +10 -5
- data/lib/stackfu/commands/publish_command.rb +5 -2
- data/lib/stackfu/helpers/rendering.rb +15 -2
- data/stackfu.gemspec +2 -2
- metadata +4 -4
data/Rakefile
CHANGED
data/lib/stackfu.rb
CHANGED
@@ -49,8 +49,8 @@ require "#{dir}/commands/deploy_command"
|
|
49
49
|
require "#{dir}/commands/dump_command"
|
50
50
|
|
51
51
|
module StackFu
|
52
|
-
VERSION = '0.
|
53
|
-
API = "http://
|
52
|
+
VERSION = '0.1.1'
|
53
|
+
API = "http://stackfu.com"
|
54
54
|
CONFIG_FILE = "#{ENV['HOME']}/.stackfu"
|
55
55
|
|
56
56
|
include StackFu::OperatingSystems
|
@@ -86,3 +86,16 @@ class String
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
# class ActiveResource::Connection
|
90
|
+
# # Creates new Net::HTTP instance for communication with
|
91
|
+
# # remote service and resources.
|
92
|
+
# def http
|
93
|
+
# http = Net::HTTP.new(@site.host, @site.port)
|
94
|
+
# http.use_ssl = @site.is_a?(URI::HTTPS)
|
95
|
+
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
|
96
|
+
# http.read_timeout = @timeout if @timeout
|
97
|
+
# #Here's the addition that allows you to see the output
|
98
|
+
# http.set_debug_output $stderr
|
99
|
+
# return http
|
100
|
+
# end
|
101
|
+
# end
|
data/lib/stackfu/api_hooks.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
module StackFu
|
2
2
|
module ApiHooks
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class
|
8
|
-
class
|
3
|
+
class Resource < ActiveResource::Base
|
4
|
+
self.format = :json
|
5
|
+
end
|
6
|
+
|
7
|
+
class Server < Resource; end
|
8
|
+
class User < Resource; end
|
9
|
+
class Stack < Resource; end
|
10
|
+
class Plugin < Resource; end
|
11
|
+
class Provider < Resource; end
|
12
|
+
class Deployment < Resource; end
|
9
13
|
|
10
14
|
def initialize_api(config)
|
11
15
|
[Server, User, Stack, Plugin, Provider, Deployment].each do |model_class|
|
12
|
-
model_class.
|
13
|
-
model_class.
|
16
|
+
model_class.user = $config[:token]
|
17
|
+
model_class.password = "X"
|
18
|
+
model_class.site = StackFu::API
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
@@ -3,11 +3,11 @@ module StackFu
|
|
3
3
|
include ApiHooks
|
4
4
|
|
5
5
|
error_messages :missing_subcommand => "You have to tell what you want to dump: a stack or a plugin"
|
6
|
-
subcommand :
|
6
|
+
subcommand :plugin, :required_parameters => [:plugin_name]
|
7
7
|
|
8
|
-
def
|
8
|
+
def plugin(parameters, options)
|
9
9
|
stack_name = parameters[0]
|
10
|
-
stack = spinner {
|
10
|
+
stack = spinner { Plugin.find(stack_name) }
|
11
11
|
|
12
12
|
if stack
|
13
13
|
if directory?(stack_name)
|
@@ -21,33 +21,49 @@ module StackFu
|
|
21
21
|
create_file "#{stack_name}/stack.yml", {
|
22
22
|
"type" => "stack",
|
23
23
|
"name" => stack.name,
|
24
|
-
"description" => stack.description
|
25
|
-
"operating_system" => stack.operating_system.to_s
|
24
|
+
"description" => stack.respond_to?(:description) ? stack.description : ""
|
26
25
|
}.to_yaml
|
27
26
|
|
28
27
|
create_folder "#{stack_name}/config"
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
"
|
33
|
-
|
29
|
+
if stack.respond_to?(:controls)
|
30
|
+
controls = map stack.controls, "controls" do |c|
|
31
|
+
{ "name" => c.name,
|
32
|
+
"label" => c.label,
|
33
|
+
"type" => c._type }
|
34
|
+
end
|
35
|
+
else
|
36
|
+
controls = []
|
34
37
|
end
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
"
|
39
|
-
|
39
|
+
if stack.respond_to?(:requirements)
|
40
|
+
requirements = map stack.requirements, "requirements" do |req|
|
41
|
+
{ "data" => req.data,
|
42
|
+
"error" => req.error,
|
43
|
+
"type" => req._type }
|
44
|
+
end
|
45
|
+
else
|
46
|
+
requirements = []
|
40
47
|
end
|
41
48
|
|
42
|
-
|
43
|
-
|
44
|
-
"
|
49
|
+
if stack.respond_to?(:executions)
|
50
|
+
executions = map stack.executions, "scripts" do |exec|
|
51
|
+
{ "description" => exec.description,
|
52
|
+
"file" => exec.description.downcase.gsub(" ", "_") }
|
53
|
+
end
|
54
|
+
else
|
55
|
+
executions = []
|
45
56
|
end
|
46
57
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
"
|
58
|
+
|
59
|
+
if stack.respond_to?(:validations)
|
60
|
+
validations = map stack.validations, "validations" do |val|
|
61
|
+
{ "data" => val.data,
|
62
|
+
"error" => val.error,
|
63
|
+
"type" => val._type }
|
64
|
+
end
|
65
|
+
else
|
66
|
+
validations = []
|
51
67
|
end
|
52
68
|
|
53
69
|
create_file "#{stack_name}/config/01-controls.yml", controls
|
@@ -57,7 +73,7 @@ module StackFu
|
|
57
73
|
|
58
74
|
create_folder "#{stack_name}/script"
|
59
75
|
stack.executions.each do |script|
|
60
|
-
create_file "#{stack_name}/script/#{script.description.downcase.gsub(" ", "_")}.sh.erb", script.
|
76
|
+
create_file "#{stack_name}/script/#{script.description.downcase.gsub(" ", "_")}.sh.erb", script.script
|
61
77
|
end
|
62
78
|
|
63
79
|
puts "Stack #{stack_name} dumped successfully..."
|
@@ -3,16 +3,17 @@ module StackFu
|
|
3
3
|
include ApiHooks
|
4
4
|
|
5
5
|
def default(parameters, options)
|
6
|
-
user = User.find(:all).first
|
6
|
+
# user = User.find(:all).first
|
7
7
|
items = spinner {
|
8
8
|
[
|
9
|
-
Stack.find(:all, :conditions => { "user.id" => user.id }),
|
10
|
-
Plugin.find(:all
|
9
|
+
# Stack.find(:all, :conditions => { "user.id" => user.id }),
|
10
|
+
Plugin.find(:all)
|
11
11
|
].flatten
|
12
12
|
}
|
13
13
|
|
14
14
|
params = {
|
15
|
-
:class => [Stack, Plugin],
|
15
|
+
# :class => [Stack, Plugin],
|
16
|
+
:class => [Plugin],
|
16
17
|
:collection => items,
|
17
18
|
:display => [:name, :type, :description],
|
18
19
|
:main_column => :name,
|
@@ -20,7 +21,11 @@ module StackFu
|
|
20
21
|
:ansi => options[:plain].nil?
|
21
22
|
}
|
22
23
|
|
23
|
-
puts table(params) { |item|
|
24
|
+
puts table(params) { |item|
|
25
|
+
description = item.respond_to?(:description) ? item.description : ""
|
26
|
+
|
27
|
+
[item.name, "Plugin", description.truncate_words(10)]
|
28
|
+
}
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -52,8 +52,11 @@ module StackFu
|
|
52
52
|
end
|
53
53
|
|
54
54
|
item_class = ApiHooks.const_get("#{what.to_s.classify}")
|
55
|
+
item_class.format = :json
|
55
56
|
|
56
|
-
stacks = item_class.find(:all
|
57
|
+
stacks = item_class.find(:all) || []
|
58
|
+
stacks = stacks.select { |s| s.name == stack_spec["name"] }
|
59
|
+
|
57
60
|
if stacks.any?
|
58
61
|
unless options[:update]
|
59
62
|
if agree("You already have a #{what} named #{stack_spec["name"]}. Do you want to update it?")
|
@@ -68,7 +71,7 @@ module StackFu
|
|
68
71
|
|
69
72
|
stack = stacks.first
|
70
73
|
begin
|
71
|
-
item_class.delete(stack.
|
74
|
+
item_class.delete(stack.name)
|
72
75
|
rescue ActiveResource::ResourceNotFound
|
73
76
|
puts "There was a problem updating your #{what}. Please report this problem at support@stackfu.com or try again in a few minutes."
|
74
77
|
return
|
@@ -107,7 +107,16 @@ module StackFu
|
|
107
107
|
|
108
108
|
display.each_with_index do |column, i|
|
109
109
|
max_value_size = collection.map do |item|
|
110
|
-
|
110
|
+
if block_given?
|
111
|
+
value = yield(item)[i]
|
112
|
+
else
|
113
|
+
if item.respond_to?(column)
|
114
|
+
value = item.send(column)
|
115
|
+
else
|
116
|
+
value = ""
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
111
120
|
value.to_s.size
|
112
121
|
end.max
|
113
122
|
|
@@ -150,7 +159,11 @@ module StackFu
|
|
150
159
|
value = values[idx]
|
151
160
|
idx += 1
|
152
161
|
else
|
153
|
-
|
162
|
+
if item.respond_to?(col[:name])
|
163
|
+
value = item.send(col[:name])
|
164
|
+
else
|
165
|
+
value = ""
|
166
|
+
end
|
154
167
|
end
|
155
168
|
|
156
169
|
just_method = value.is_a?(Numeric) ? :rjust : :ljust
|
data/stackfu.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{stackfu}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Felipe Coury"]
|
9
|
-
s.date = %q{2010-08-
|
9
|
+
s.date = %q{2010-08-29}
|
10
10
|
s.default_executable = %q{stackfu}
|
11
11
|
s.description = %q{StackFu Backend}
|
12
12
|
s.email = %q{felipe@stackfu.com}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackfu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Felipe Coury
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-29 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|