Class: ComponentizeAny::Witty

Inherits:
Object
  • Object
show all
Defined in:
lib/componentize_any/dsl.rb

Defined Under Namespace

Classes: Interface, Member, Package

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWitty

Returns a new instance of Witty.



79
80
81
82
83
# File 'lib/componentize_any/dsl.rb', line 79

def initialize
  @packages = {}
  @exports = []
  @imports = []
end

Class Attribute Details

.global_witObject

Returns the value of attribute global_wit.



3
4
5
# File 'lib/componentize_any/dsl.rb', line 3

def global_wit
  @global_wit
end

Instance Attribute Details

#exportsObject (readonly)

Returns the value of attribute exports.



54
55
56
# File 'lib/componentize_any/dsl.rb', line 54

def exports
  @exports
end

#importsObject (readonly)

Returns the value of attribute imports.



55
56
57
# File 'lib/componentize_any/dsl.rb', line 55

def imports
  @imports
end

#packagesObject (readonly)

Returns the value of attribute packages.



53
54
55
# File 'lib/componentize_any/dsl.rb', line 53

def packages
  @packages
end

Instance Method Details

#export(name) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/componentize_any/dsl.rb', line 61

def export(name)
  export = nil
  re = /^(\w+):(\w+)\/(\w+)@(\d+\.\d+\.\d+)$/    
  re.match(name)&.tap do |re|
    export = ExportName.new re[1], re[2], re[3], re[4]
  end
  if export.nil?
    raise "invalid export name: #{name}"
  end
  @exports << export
end

#package(name, &blk) ⇒ Object



73
74
75
76
77
# File 'lib/componentize_any/dsl.rb', line 73

def package(name, &blk)
  pkg = Package.new
  @packages[name] = pkg
  pkg.instance_eval(&blk)
end

#world(&blk) ⇒ Object



57
58
59
# File 'lib/componentize_any/dsl.rb', line 57

def world(&blk)
  instance_eval(&blk)
end