Class: Prick::Feature

Inherits:
Branch
  • Object
show all
Defined in:
lib/prick/branch.rb,
lib/prick/build.rb

Overview

Feature maintains a migration in the parent release but it is ignored when including the feature

Instance Attribute Summary collapse

Attributes inherited from Branch

#base_version, #directory, #migration, #name, #schema, #version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Branch

#<=>, #build, #checkout_release, #dump, exist?, #exist?, #feature?, #migrate, #migrate_features, #migration?, #prepare, #prepared?, #prerelease?, #present?, present?, #release?

Constructor Details

#initialize(feature_name, base_version) ⇒ Feature

Returns a new instance of Feature.



325
326
327
328
329
330
331
# File 'lib/prick/build.rb', line 325

def initialize(project, base_release, name)
  base_release.is_a?(Release) || base_release.is_a?(Prerelease) or 
      raise Internal, "Expected a Release object, got #{base_release.class}"
  version = Version.new(base_release.version, feature: name)
  migration = FeatureMigration.new(Migration.path(version))
  super(project, base_release, version, migration)
end

Instance Attribute Details

#feature_nameObject (readonly)

Returns the value of attribute feature_name.



204
205
206
# File 'lib/prick/branch.rb', line 204

def feature_name
  @feature_name
end

Class Method Details

.directory(name) ⇒ Object



248
249
250
251
# File 'lib/prick/branch.rb', line 248

def self.directory(name)
  version = Version.new(name)
  File.join(Release.directory(version.truncate(:feature).to_s), version.feature.to_s)
end

.load(name) ⇒ Object



242
243
244
245
246
# File 'lib/prick/branch.rb', line 242

def self.load(name)
  directory = self.directory(name)
  migration_state = MigrationState.new(directory).read
  self.new(migration_state.version.feature, migration_state.base_version)
end

Instance Method Details

#checkoutObject



333
334
335
336
# File 'lib/prick/build.rb', line 333

def checkout() 
  super
#     FileUtils.ln_sf(feature, "feature")
end

#createObject



338
339
340
341
342
343
344
345
# File 'lib/prick/build.rb', line 338

def create
  super
  migration.create
  migration.prepare
  Git.commit("Created feature #{feature}")
  migration.dump
  self
end

#databaseObject



206
# File 'lib/prick/branch.rb', line 206

def database() base_version.to_s end

#featureObject

Name of feature



318
# File 'lib/prick/build.rb', line 318

def feature() version.feature end

#include(feature_version) ⇒ Object



222
# File 'lib/prick/branch.rb', line 222

def include(feature_version) @migration.insert_feature(feature_version) end

#nodeObject

A feature’s node is the feature directory



321
# File 'lib/prick/build.rb', line 321

def node() release_dir end

#rebase(base_version) ⇒ Object



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/prick/build.rb', line 360

def rebase(new_base_release)
  # Checkout new_base_release
  # Merge feature
  # Establish symlinks
  # Create as branch

#     new_base > base_release or 
#         raise Error, "Can't rebase from #{base_release.version} to #{new_base.version}"
#     new_feature = Feature.new(project, base_release, base.version, base: base)
#     new_feature.ensure(:active)
#     schema.version = version
#     FileUtils.ln_sf("../#{feature.release_dir}", new_feature.release_dir)
#     Git.add(new_feature.release_dir)
#     new_feature
end

#release_dirObject



323
# File 'lib/prick/build.rb', line 323

def release_dir() migration.path end