webbynode-blueprint 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -6,8 +6,12 @@ class Blueprint
6
6
  include Utils
7
7
  include BlueprintComponents
8
8
 
9
- def initialize(blueprint_def)
10
- @def = blueprint_def
9
+ def initialize(s)
10
+ if s.is_a?(Hash)
11
+ @def = s
12
+ else
13
+ @def[:label] = s
14
+ end
11
15
  end
12
16
 
13
17
  def provides(*args)
@@ -18,12 +22,14 @@ class Blueprint
18
22
  @def.merge!(opts)
19
23
 
20
24
  else
25
+ @def[:name] ||= s
21
26
  @def[:script] = "#{s}.sh"
22
27
  @def[:email] = "#{s}.markdown"
23
28
 
24
29
  end
25
30
 
26
- (errors ||= []) << "provides requires an argument" unless @def.has_key?(:email)
31
+ (errors ||= []) << "provides requires the blueprint name" if @def.empty?
32
+ (errors ||= []) << "no blueprint name found for #{@def[:content]}" unless @def.has_key?(:name)
27
33
  (errors ||= []) << "no email template found for #{@def[:content]}" unless @def.has_key?(:email)
28
34
  (errors ||= []) << "no script found for #{@def[:content]}" unless @def.has_key?(:script)
29
35
 
data/lib/blueprint.rb CHANGED
@@ -4,6 +4,11 @@ require 'blueprint/utils'
4
4
 
5
5
  def blueprint(*args, &block)
6
6
  blueprint_def = args.last.is_a?(Hash) ? args.pop : {}
7
+
8
+ if blueprint_def.empty?
9
+ blueprint_def[:label] = args.pop
10
+ end
11
+
7
12
  blueprint = Blueprint.new(blueprint_def)
8
13
 
9
14
  if block_given?
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class BlueprintTest < Test::Unit::TestCase
4
4
  def rails_blueprint
5
- blueprint(:type => "stack", :name => "rails") do |f|
5
+ blueprint "Rails" do |f|
6
6
  f.provides "rails"
7
7
 
8
8
  f.parameter "version", :label => "Rails Version", :render_as => "combobox" do |p|
@@ -42,7 +42,7 @@ class BlueprintTest < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def rails_readystack_blueprint
45
- blueprint(:type => "readystack", :name => "rs.rails") do |f|
45
+ blueprint(:label => "Rails", :type => "readystack") do |f|
46
46
  # this blueprint delivers "rs.rails"
47
47
  f.provides "rs.rails"
48
48
 
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Coury