Class: Bones::VersionedRelease

Inherits:
Release show all
Defined in:
lib/bones/versioned_release.rb

Overview

Class used to encapsulate the logic needed to maintain mockup versions

Constant Summary collapse

DIR_PREFIX =

Pre-fix used for versioned directories

'v'

Instance Attribute Summary

Attributes inherited from Release

#original_destination, #release_destination

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Release

#copy_public_directories, #destination

Constructor Details

#initialize(original_destination, release_destination = nil) ⇒ VersionedRelease

Returns a new instance of VersionedRelease.



8
9
10
11
# File 'lib/bones/versioned_release.rb', line 8

def initialize(original_destination, release_destination = nil)
  super
  @release_destination = get_versioned_destination
end

Class Method Details

.directories(base = nil) ⇒ Object

Returns the versioned directories within the ‘public’ folder $> Bones::Versioned.directories $> => [“/v1”, “/v2”, … “/vN”]



16
17
18
19
20
21
22
23
24
25
# File 'lib/bones/versioned_release.rb', line 16

def self.directories(base=nil)
  base ||= Bones.root / 'public'
  FileUtils.mkdir_p(base) unless File.directory?(base)
  Dir.chdir(base) do
    Dir.glob("#{DIR_PREFIX}**").inject([]) do |dirs, dir|
      dirs << '/' + File.basename(dir) if dir =~ /^#{DIR_PREFIX}\d+$/
      dirs
    end.compact
  end
end

Instance Method Details

#versionObject

Public accessor of version



28
29
30
# File 'lib/bones/versioned_release.rb', line 28

def version
  next_version
end

#versioned_directory_nameObject

Returns directory name of versioned path For example, ‘v1’



34
35
36
# File 'lib/bones/versioned_release.rb', line 34

def versioned_directory_name
  DIR_PREFIX + next_version
end