Class: Ree::BuildPackageDsl

Inherits:
Object show all
Includes:
Args
Defined in:
lib/ree/dsl/build_package_dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Args

#check_arg, #check_arg_any, #check_arg_array_of, #check_bool, #not_nil

Constructor Details

#initialize(packages_facade, mod) ⇒ BuildPackageDsl

Returns a new instance of BuildPackageDsl.

Parameters:



11
12
13
14
# File 'lib/ree/dsl/build_package_dsl.rb', line 11

def initialize(packages_facade, mod)
  @packages_facade = packages_facade
  @package = register_package(mod)
end

Instance Attribute Details

#packageObject (readonly)

Returns the value of attribute package.



6
7
8
# File 'lib/ree/dsl/build_package_dsl.rb', line 6

def package
  @package
end

Instance Method Details

Parameters:

  • block (Proc)

Raises:



60
61
62
63
64
# File 'lib/ree/dsl/build_package_dsl.rb', line 60

def default_links(&block)
  raise Ree::Error.new("block missing") if !block_given?

  @package.set_default_links(&block)
end

#depends_on(depends_on) ⇒ Object

Parameters:

  • depends_on (Symbol)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ree/dsl/build_package_dsl.rb', line 29

def depends_on(depends_on)
  check_arg(depends_on, :depends_on, Symbol)

  if depends_on == @package.name
    raise_error("A package cannot depend on itself")
  end

  if @package.get_dep(depends_on)
    raise_error("Dependent package :#{depends_on} already added for package :#{@package.name}")
  end

  package_dep = @package.set_dep(
    Ree::PackageDep.new(depends_on)
  )

  dep_package = begin
    @packages_facade.get_package(depends_on)
  rescue Ree::Error
    raise_error("Dependent package :#{depends_on} was not found in #{Ree::PACKAGES_SCHEMA_FILE}. Run `ree gen.packages_json` to update schema or fix package name")
  end

  package_dep
end

#env_var(var_name, doc: nil) ⇒ Object

Parameters:

  • var_name (String)
  • doc (Nilor[String]) (defaults to: nil)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ree/dsl/build_package_dsl.rb', line 68

def env_var(var_name, doc: nil)
  check_arg(var_name, :env_var, String)
  check_arg(doc, :doc, String) if doc

  if @package.get_env_var(var_name)
    raise_error("Duplicate env var '#{var_name}'")
  end

  @package.set_env_var(
    Ree::PackageEnvVar.new(
      var_name, doc
    )
  )
end

#load_dependent_packagesObject



53
54
55
56
57
# File 'lib/ree/dsl/build_package_dsl.rb', line 53

def load_dependent_packages
  @package.deps.each do |dep|
    @packages_facade.load_package_entry(dep.name)
  end
end

#preload(opts) ⇒ Object

Parameters:

  • opts (HashOf[Symbol, ArrayOf[Symbol]])


84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ree/dsl/build_package_dsl.rb', line 84

def preload(opts)
  check_arg(opts, :opts, Hash)

  opts.each do |env, list|
    check_arg(list, :object_list, Array)

    list.each do |object_name|
      check_arg(object_name, :object_name, Symbol)
    end
  end

  @package.set_preload(opts)
end

#tags(list) ⇒ Object

Parameters:

  • lists (ArrayOf[String])


17
18
19
20
21
22
23
24
25
26
# File 'lib/ree/dsl/build_package_dsl.rb', line 17

def tags(list)
  list.each do |tag|
    check_arg(tag, :tag, String)
  end

  list += [@package.name.to_s]
  list.uniq

  @package.set_tags(list)
end