webbynode-blueprint 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/blueprint/blueprint.rb +7 -5
- data/lib/blueprint/components.rb +38 -7
- data/lib/blueprint.rb +7 -3
- data/test/blueprint_test.rb +3 -5
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/blueprint/blueprint.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pp'
|
1
2
|
require "blueprint/components"
|
2
3
|
require "blueprint/utils"
|
3
4
|
require "yaml"
|
@@ -22,15 +23,16 @@ class Blueprint
|
|
22
23
|
@def.merge!(opts)
|
23
24
|
|
24
25
|
else
|
25
|
-
@def[:
|
26
|
+
@def[:content] ||= s
|
26
27
|
@def[:script] = "#{s}.sh"
|
27
|
-
@def[:email] = "#{s}.markdown"
|
28
|
+
@def[:email] = "#{s}.markdown" if @def["item_type"] == "readystack"
|
29
|
+
@def[:item_type] ||= "stack"
|
28
30
|
|
29
31
|
end
|
30
32
|
|
31
33
|
(errors ||= []) << "provides requires the blueprint name" if @def.empty?
|
32
|
-
(errors ||= []) << "no blueprint name found
|
33
|
-
(errors ||= []) << "no email template found for #{@def[:content]}" unless @def.has_key?(:email)
|
34
|
+
(errors ||= []) << "no blueprint name found" unless @def.has_key?(:content)
|
35
|
+
# (errors ||= []) << "no email template found for #{@def[:content]}" unless @def.has_key?(:email)
|
34
36
|
(errors ||= []) << "no script found for #{@def[:content]}" unless @def.has_key?(:script)
|
35
37
|
|
36
38
|
raise "Errors: #{errors * ", "}" if errors
|
@@ -40,7 +42,7 @@ class Blueprint
|
|
40
42
|
if req.is_a?(Hash)
|
41
43
|
requirement_def = { :group => req[:group], :contains => req[:with] }
|
42
44
|
else
|
43
|
-
requirement_def = { :group => req, :contains => req }
|
45
|
+
requirement_def = { :group => req, :contains => [req] }
|
44
46
|
end
|
45
47
|
|
46
48
|
(@def[:dependencies] ||= []) << requirement_def
|
data/lib/blueprint/components.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require "blueprint/utils"
|
2
2
|
|
3
3
|
module BlueprintComponents
|
4
|
+
BLUEPRINT_TRANSLATIONS = {
|
5
|
+
:render_as => :control,
|
6
|
+
:type => :item_type
|
7
|
+
}
|
8
|
+
|
4
9
|
class Component
|
5
10
|
class << self
|
6
11
|
attr_accessor :item_type
|
@@ -16,22 +21,35 @@ module BlueprintComponents
|
|
16
21
|
|
17
22
|
def attributes(*args)
|
18
23
|
opts = args.last.is_a?(Hash) ? args.pop : {}
|
19
|
-
@def.merge!(opts)
|
24
|
+
@def.merge!(:attributes => opts)
|
20
25
|
end
|
21
26
|
|
22
27
|
def initialize(*args)
|
23
28
|
opts = args.last.is_a?(Hash) ? args.pop : {}
|
29
|
+
|
30
|
+
if opts
|
31
|
+
opts.clone.keys.each do |k|
|
32
|
+
if BLUEPRINT_TRANSLATIONS.key?(k)
|
33
|
+
opts[BLUEPRINT_TRANSLATIONS[k]] = opts.delete(k)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
24
38
|
@def = { :item_type => self.class.item_type }.merge(opts)
|
25
39
|
if self.class.block
|
26
|
-
@def.merge!(self.class.block.call(args, opts))
|
40
|
+
@def.merge!(self.class.block.call(self, args, opts))
|
27
41
|
end
|
28
42
|
end
|
43
|
+
|
44
|
+
def remove_attribute(attr)
|
45
|
+
@def.delete(attr)
|
46
|
+
end
|
29
47
|
end
|
30
48
|
|
31
49
|
class Value < Component
|
32
50
|
include BlueprintComponents
|
33
51
|
|
34
|
-
creates "value" do |args, opts|
|
52
|
+
creates "value" do |obj, args, opts|
|
35
53
|
{ :content => args.pop }.merge(opts)
|
36
54
|
end
|
37
55
|
end
|
@@ -47,15 +65,28 @@ module BlueprintComponents
|
|
47
65
|
add_child val
|
48
66
|
end
|
49
67
|
|
50
|
-
creates "param" do |args, opts|
|
51
|
-
|
68
|
+
creates "param" do |obj, args, opts|
|
69
|
+
content = args.pop
|
70
|
+
|
71
|
+
if opts.key?(:values)
|
72
|
+
opts.delete(:values)
|
73
|
+
|
74
|
+
values = obj.remove_attribute(:values)
|
75
|
+
unless values.is_a?(Array)
|
76
|
+
raise "values should be an array for Parameter #{content}"
|
77
|
+
end
|
78
|
+
|
79
|
+
values.each { |v| obj.value(v) }
|
80
|
+
end
|
81
|
+
|
82
|
+
{ :content => content }.merge(opts)
|
52
83
|
end
|
53
84
|
end
|
54
85
|
|
55
86
|
class Aggregate < Component
|
56
87
|
include BlueprintComponents
|
57
88
|
|
58
|
-
creates "aggregate" do |args, opts|
|
89
|
+
creates "aggregate" do |obj, args, opts|
|
59
90
|
{ :label => args.pop }.merge(opts)
|
60
91
|
end
|
61
92
|
end
|
@@ -63,7 +94,7 @@ module BlueprintComponents
|
|
63
94
|
class Dependency < Component
|
64
95
|
include BlueprintComponents
|
65
96
|
|
66
|
-
creates "dependency" do |args, opts|
|
97
|
+
creates "dependency" do |obj, args, opts|
|
67
98
|
{ :content => args.pop }.merge(opts)
|
68
99
|
end
|
69
100
|
end
|
data/lib/blueprint.rb
CHANGED
@@ -4,16 +4,20 @@ require 'blueprint/utils'
|
|
4
4
|
|
5
5
|
def blueprint(*args, &block)
|
6
6
|
blueprint_def = args.last.is_a?(Hash) ? args.pop : {}
|
7
|
-
|
7
|
+
|
8
8
|
if blueprint_def.empty?
|
9
9
|
blueprint_def[:label] = args.pop
|
10
10
|
end
|
11
11
|
|
12
|
+
if blueprint_def[:type]
|
13
|
+
blueprint_def[:item_type] = blueprint_def.delete(:type)
|
14
|
+
end
|
15
|
+
|
12
16
|
blueprint = Blueprint.new(blueprint_def)
|
13
|
-
|
17
|
+
|
14
18
|
if block_given?
|
15
19
|
yield blueprint
|
16
20
|
end
|
17
|
-
|
21
|
+
|
18
22
|
blueprint
|
19
23
|
end
|
data/test/blueprint_test.rb
CHANGED
@@ -5,11 +5,8 @@ class BlueprintTest < Test::Unit::TestCase
|
|
5
5
|
blueprint "Rails" do |f|
|
6
6
|
f.provides "rails"
|
7
7
|
|
8
|
-
f.parameter "version", :label => "Rails Version", :render_as => "combobox"
|
9
|
-
|
10
|
-
p.value "2.2.2"
|
11
|
-
p.value "2.1.2"
|
12
|
-
end
|
8
|
+
f.parameter "version", :label => "Rails Version", :render_as => "combobox",
|
9
|
+
:values => ["2.3.2", "2.2.2", "2.1.2"]
|
13
10
|
|
14
11
|
f.parameter "doc_rdoc", :label => "Install rdoc", :render_as => "checkbox"
|
15
12
|
f.parameter "doc_ri", :label => "Install ri", :render_as => "checkbox"
|
@@ -18,6 +15,7 @@ class BlueprintTest < Test::Unit::TestCase
|
|
18
15
|
:label => "Create dummy app?",
|
19
16
|
:render_as => "checkbox",
|
20
17
|
:attributes => {:default => "y"}
|
18
|
+
|
21
19
|
f.parameter "dummyapp-path",
|
22
20
|
:label => "Path for dummy app",
|
23
21
|
:render_as => "text",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webbynode-blueprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Coury
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|