This represents a single package in a Repository.

Methods
Attributes
[RW] description The description of the package.
[R] name The name of this package.
[R] registry The Registry instance that contains this package.
Classes and Modules
Module Copland::Package::Fixated
Public Class methods
new( registry, name )

Create a new package associated with the given registry. The package will have the given name. Note: this will not add the package to the registry!

    # File lib/copland/package.rb, line 54
54:     def initialize( registry, name )
55:       @registry = registry
56:       @name = name
57:       @service_points = Hash.new
58:       @configuration_points = Hash.new
59:       @schemas = Hash.new
60:     end
Public Instance methods
add_configuration_point( configuration_point )

Add the given configuration point to the package.

    # File lib/copland/package.rb, line 68
68:     def add_configuration_point( configuration_point )
69:       @configuration_points[ configuration_point.name ] = configuration_point
70:     end
add_pending_contribution( name, value )

Adds a "pending" contribution to the package. When the package is fixated (see fixate!), the given value will be contributed to the configuration point with the given name. Once the package is fixated, this method will be illegal to invoke.

     # File lib/copland/package.rb, line 166
166:     def add_pending_contribution( name, value )
167:       ( @pending_contributions ||= [] ).push :name => name,
168:                                              :value => value
169:     end
add_schema( schema )

Add the given schema to the package. Note that this requires that the schema have a name. This will also set the schema’s owner attribute to the package.

    # File lib/copland/package.rb, line 75
75:     def add_schema( schema )
76:       schema.owner = self
77:       @schemas[ schema.name ] = schema
78:     end
add_service_point( service_point )

Add the given service point to the package.

    # File lib/copland/package.rb, line 63
63:     def add_service_point( service_point )
64:       @service_points[ service_point.name ] = service_point
65:     end
configuration_point( name )

Returns the configuration point with the given name, or nil if no such configuration point exists.

     # File lib/copland/package.rb, line 147
147:     def configuration_point( name )
148:       @configuration_points[ name ]
149:     end
configuration_point_count()

Returns the number of configuration points in the package.

     # File lib/copland/package.rb, line 197
197:     def configuration_point_count
198:       @configuration_points.size
199:     end
configuration_points()

Returns the names of all configuration points in the package.

     # File lib/copland/package.rb, line 152
152:     def configuration_points
153:       @configuration_points.keys.freeze
154:     end
each_configuration_point( &block )

Iterates over each configuration point in the package.

     # File lib/copland/package.rb, line 180
180:     def each_configuration_point( &block )
181:       @configuration_points.each_value( &block )
182:     end
each_schema( &block )

Iterates over each schema in the package.

     # File lib/copland/package.rb, line 185
185:     def each_schema( &block )
186:       @schemas.each_value( &block )
187:     end
each_service_point( include_private=false ) {|pt if pt.visibility == :public || include_private| ...}

Iterates over each service point in the package.

     # File lib/copland/package.rb, line 172
172:     def each_service_point( include_private=false, &block )
173:       @service_points.each_value do |pt|
174:         yield pt if pt.visibility == :public || include_private
175:       end
176:       self
177:     end
find_schema( name )

This is a convenience method for returning a schema with the given name, giving preference when a package is not specified to the schemas within the current package.

     # File lib/copland/package.rb, line 133
133:     def find_schema( name )
134:       find_service( name ) do |pkg, id|
135:         if pkg.nil?
136:           raise PackageNotFound, name
137:         else
138:           schema = pkg.schema( id )
139:           raise SchemaNotFound, name unless schema
140:           return schema
141:         end
142:       end
143:     end
find_service( name, &block )

This is a convenience method for returning a service with the given name, giving preference when a package is not specified to the service points within the current package.

     # File lib/copland/package.rb, line 126
126:     def find_service( name, &block )
127:       Copland::get_possibly_local_service( registry, self, name, &block )
128:     end
fixate!()

Fixates the package. This will, in turn, fixate each configuration and service point in the package. Also, all pending contributions will be contributed to the configuration points they were intended for.

     # File lib/copland/package.rb, line 209
209:     def fixate!
210:       extend Fixated
211: 
212:       @schemas.each_value { |schema| schema.fixate! }
213:       @service_points.each_value { |point| point.fixate! }
214:       @configuration_points.each_value { |point| point.fixate! }
215: 
216:       if @pending_contributions
217:         @pending_contributions.each do |value|
218:           name = value[ :name ]
219:           contribution = value[ :value ]
220: 
221:           configuration_point = find_service( name ) do |pkg, id|
222:             raise PackageNotFound, name unless pkg
223:             pkg.configuration_point( id )
224:           end
225: 
226:           raise ConfigurationPointNotFound, name unless configuration_point
227: 
228:           contribution.instance_variable_set( :@contributor, self )
229:           configuration_point.contribute contribution
230:         end
231: 
232:         remove_instance_variable :@pending_contributions
233:       end
234:     end
fixated?()

Returns false, although when the package is fixated this will be overridden with a method that will return true.

     # File lib/copland/package.rb, line 238
238:     def fixated?
239:       false
240:     end
schema( name )

Returns the schema with the given name, or nil if no such schema exists.

     # File lib/copland/package.rb, line 158
158:     def schema( name )
159:       @schemas[ name ]
160:     end
schema_count()

Returns the number of schemas in the package.

     # File lib/copland/package.rb, line 202
202:     def schema_count
203:       @schemas.size
204:     end
service( name, include_private=false, &init )

This instantiates the service point with the given name and returns the resulting service. If the service point does not exist, this will raise a ServicePointNotFound exception.

If a block is given, it will be used to initialize the service (but only when the service is created—if the service is a singleton service and it was created previously, the init block will be ignored).

If include_private is true, then only public service points may be instantiated.

     # File lib/copland/package.rb, line 111
111:     def service( name, include_private=false, &init )
112:       point = service_point( name, include_private ) or
113:         raise ServicePointNotFound, name
114:       point.instance( &init )
115:     end
service_exist?( name, include_private=false )

Returns true if the named service exists in this package, and false otherwise.

     # File lib/copland/package.rb, line 119
119:     def service_exist?( name, include_private=false )
120:       return !service_point( name, include_private ).nil?
121:     end
service_point( name, include_private=false )

Returns the service point with the given name. If no such service point exists, this returns nil. If include_private is false, then this will also return nil if the point exists, but is marked private.

    # File lib/copland/package.rb, line 83
83:     def service_point( name, include_private=false )
84:       point = @service_points[ name ]
85:       return nil if point.nil? || point.visibility == :private &&
86:         !include_private
87:       point
88:     end
service_point_count( include_private=false )

Returns the number of service points in the package.

     # File lib/copland/package.rb, line 190
190:     def service_point_count( include_private=false )
191:       @service_points.
192:         reject { |k,v| v.visibility == :private && !include_private }.
193:         size
194:     end
service_points( include_private=false )

This returns the names of all service points in the package. If include_private is true (the default), then only the public service points will be returned.

    # File lib/copland/package.rb, line 93
93:     def service_points( include_private=false )
94:       names = @service_points.keys.dup
95:       if !include_private
96:         names.reject! { |p| @service_points[p].visibility != :public }
97:       end
98:       names
99:     end