Class: Ree::Package

Inherits:
Object show all
Defined in:
lib/ree/core/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_version, name, entry_rpath, schema_rpath, gem_name = nil) ⇒ Package

Returns a new instance of Package.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ree/core/package.rb', line 9

def initialize(schema_version, name, entry_rpath, schema_rpath, gem_name = nil)
  @schema_version = schema_version
  @name = name
  @schema_rpath = schema_rpath
  @entry_rpath = entry_rpath
  @objects_store = {}
  @deps_store = {}
  @env_vars_store = {}
  @entry_loaded = false
  @schema_loaded = false
  @loaded = false
  @tags = []
  @preload = {}
  @preloaded = false
  @gem_name = gem_name
end

Instance Attribute Details

Returns the value of attribute default_links.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def default_links
  @default_links
end

#entry_rpathObject (readonly)

Returns the value of attribute entry_rpath.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def entry_rpath
  @entry_rpath
end

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def gem_name
  @gem_name
end

#moduleObject (readonly)

Returns the value of attribute module.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def module
  @module
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def name
  @name
end

#preloadObject (readonly)

Returns the value of attribute preload.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def preload
  @preload
end

#schema_rpathObject (readonly)

Returns the value of attribute schema_rpath.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def schema_rpath
  @schema_rpath
end

#schema_versionObject (readonly)

Returns the value of attribute schema_version.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def schema_version
  @schema_version
end

#tagsObject (readonly)

Returns the value of attribute tags.



6
7
8
# File 'lib/ree/core/package.rb', line 6

def tags
  @tags
end

Instance Method Details

#depsObject



116
117
118
# File 'lib/ree/core/package.rb', line 116

def deps
  @deps_store.values
end

#dirObject



96
97
98
# File 'lib/ree/core/package.rb', line 96

def dir
  @dir ||= @schema_rpath ? Pathname.new(@schema_rpath).dirname.to_s : nil
end

#entry_loaded?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/ree/core/package.rb', line 88

def entry_loaded?
  @entry_loaded
end

#env_varsObject



139
140
141
# File 'lib/ree/core/package.rb', line 139

def env_vars
  @env_vars_store.values
end

#gem?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/ree/core/package.rb', line 100

def gem?
  !!@gem_name
end

#get_dep(name) ⇒ Object

Parameters:

  • name (Symbol)


128
129
130
# File 'lib/ree/core/package.rb', line 128

def get_dep(name)
  @deps_store[name]
end

#get_env_var(name) ⇒ Object

Parameters:

  • name (String)


151
152
153
# File 'lib/ree/core/package.rb', line 151

def get_env_var(name)
  @env_vars_store[name]
end

#get_object(name) ⇒ Nilor[Ree::Object]

Parameters:

  • name (Symbol)

Returns:



180
181
182
# File 'lib/ree/core/package.rb', line 180

def get_object(name)
  @objects_store[name]
end

#loaded?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/ree/core/package.rb', line 72

def loaded?
  @loaded
end

#objectsObject



184
185
186
# File 'lib/ree/core/package.rb', line 184

def objects
  @objects_store.values.flatten
end

#preloaded?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/ree/core/package.rb', line 35

def preloaded?
  @preloaded
end

#remove_object(name) ⇒ nil

Parameters:

  • name (Symbol)

Returns:

  • (nil)


170
171
172
173
174
175
176
# File 'lib/ree/core/package.rb', line 170

def remove_object(name)
  if @objects_store[name]
    @objects_store.delete(name)
  end

  nil
end

#resetObject



59
60
61
62
63
64
65
66
# File 'lib/ree/core/package.rb', line 59

def reset
  @entry_loaded = false
  @schema_loaded = false
  @loaded = false
  @deps_store = {}
  @env_vars_store = {}
  @preload = {}
end

#schema_loaded?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/ree/core/package.rb', line 92

def schema_loaded?
  @schema_loaded
end


26
27
28
# File 'lib/ree/core/package.rb', line 26

def set_default_links(&block)
  @default_links = block; self
end

#set_dep(dep) ⇒ Object

Parameters:



121
122
123
124
125
# File 'lib/ree/core/package.rb', line 121

def set_dep(dep)
  old = @deps_store[dep.name]
  @deps_store[dep.name] = dep
  old
end

#set_deps(list) ⇒ Object



110
111
112
113
114
# File 'lib/ree/core/package.rb', line 110

def set_deps(list)
  list.each do |item|
    @deps_store[item.name] = item
  end
end

#set_entry_loadedObject



80
81
82
# File 'lib/ree/core/package.rb', line 80

def set_entry_loaded
  @entry_loaded = true
end

#set_entry_rpath(val) ⇒ Object

Parameters:

  • val (String)


45
46
47
# File 'lib/ree/core/package.rb', line 45

def set_entry_rpath(val)
  @entry_rpath = val; self
end

#set_env_var(var) ⇒ Object

Parameters:



144
145
146
147
148
# File 'lib/ree/core/package.rb', line 144

def set_env_var(var)
  old = @env_vars_store[var.name]
  @env_vars_store[var.name] = var
  old
end

#set_env_vars(list) ⇒ Object

Parameters:



133
134
135
136
137
# File 'lib/ree/core/package.rb', line 133

def set_env_vars(list)
  list.each do |item|
    @env_vars_store[item.name] = item
  end
end

#set_loadedObject



76
77
78
# File 'lib/ree/core/package.rb', line 76

def set_loaded
  @loaded = true
end

#set_module(mod) ⇒ Object

Parameters:

  • mod (Module)


105
106
107
# File 'lib/ree/core/package.rb', line 105

def set_module(mod)
  @module = mod; self
end

#set_object(object) ⇒ Nilor[Ree::Object]

Returns Previous object version.

Parameters:

Returns:



157
158
159
160
161
162
163
164
165
166
# File 'lib/ree/core/package.rb', line 157

def set_object(object)
  if object.package_name != @name
    raise Ree::Error.new("package should only include objects from the same package")
  end

  existing = @objects_store[object.name]
  return existing if existing

  @objects_store[object.name] = object
end

#set_preload(val) ⇒ Object



68
69
70
# File 'lib/ree/core/package.rb', line 68

def set_preload(val)
  @preload = val; self
end

#set_preloaded(val) ⇒ Object

Parameters:

  • val (Bool)


31
32
33
# File 'lib/ree/core/package.rb', line 31

def set_preloaded(val)
  @preloaded = val; self
end

#set_schema_loadedObject



84
85
86
# File 'lib/ree/core/package.rb', line 84

def set_schema_loaded
  @schema_loaded = true
end

#set_schema_rpath(val) ⇒ Object

Parameters:

  • val (String)


55
56
57
# File 'lib/ree/core/package.rb', line 55

def set_schema_rpath(val)
  @schema_rpath = val; self
end

#set_schema_version(val) ⇒ Object

Parameters:

  • val (String)


40
41
42
# File 'lib/ree/core/package.rb', line 40

def set_schema_version(val)
  @schema_version = val; self
end

#set_tags(list) ⇒ Object

Parameters:

  • list (ArrayOf[String])


50
51
52
# File 'lib/ree/core/package.rb', line 50

def set_tags(list)
  @tags = (@tags + list).map(&:to_s).uniq; self
end