Class: RubyPackager::Tasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/ruby_packager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_name, prefix) ⇒ Tasks

Returns a new instance of Tasks.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_packager.rb', line 5

def initialize(application_name, prefix)
  @application_name = application_name
  @prefix = prefix
  @package_name = "#{@prefix}-#{application_name}"
  @version = '1.0'
  @dependencies = []
  @autoreq = true
  @install_path = "opt/#{@prefix}/apps/#{application_name}"
  @links = {}
  @bundle_standalone = false
  @bundle_with_binstubs = false
  @bundle_without = ["development", "test"]
  @vendorize = true
  install(FileList["Gemfile*"])
  if block_given?
    yield self
    define_tasks
  end
end

Instance Attribute Details

#after_install_scriptObject

Returns the value of attribute after_install_script.



37
38
39
# File 'lib/ruby_packager.rb', line 37

def after_install_script
  @after_install_script
end

#application_nameObject (readonly)

Returns the value of attribute application_name.



25
26
27
# File 'lib/ruby_packager.rb', line 25

def application_name
  @application_name
end

#architectureObject

Returns the value of attribute architecture.



38
39
40
# File 'lib/ruby_packager.rb', line 38

def architecture
  @architecture
end

#autoreqObject

Returns the value of attribute autoreq.



33
34
35
# File 'lib/ruby_packager.rb', line 33

def autoreq
  @autoreq
end

#before_install_scriptObject

Returns the value of attribute before_install_script.



36
37
38
# File 'lib/ruby_packager.rb', line 36

def before_install_script
  @before_install_script
end

#bundle_standaloneObject

Returns the value of attribute bundle_standalone.



39
40
41
# File 'lib/ruby_packager.rb', line 39

def bundle_standalone
  @bundle_standalone
end

#bundle_with_binstubsObject

Returns the value of attribute bundle_with_binstubs.



40
41
42
# File 'lib/ruby_packager.rb', line 40

def bundle_with_binstubs
  @bundle_with_binstubs
end

#bundle_withoutObject

Returns the value of attribute bundle_without.



41
42
43
# File 'lib/ruby_packager.rb', line 41

def bundle_without
  @bundle_without
end

#dependenciesObject

Returns the value of attribute dependencies.



32
33
34
# File 'lib/ruby_packager.rb', line 32

def dependencies
  @dependencies
end

#descriptionObject

Returns the value of attribute description.



42
43
44
# File 'lib/ruby_packager.rb', line 42

def description
  @description
end

#epochObject

Returns the value of attribute epoch.



31
32
33
# File 'lib/ruby_packager.rb', line 31

def epoch
  @epoch
end

#install_pathObject

Returns the value of attribute install_path.



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

def install_path
  @install_path
end

#iterationObject

Returns the value of attribute iteration.



30
31
32
# File 'lib/ruby_packager.rb', line 30

def iteration
  @iteration
end

Returns the value of attribute links.



35
36
37
# File 'lib/ruby_packager.rb', line 35

def links
  @links
end

#package_nameObject

Returns the value of attribute package_name.



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

def package_name
  @package_name
end

#rpm_groupObject

Returns the value of attribute rpm_group.



46
47
48
# File 'lib/ruby_packager.rb', line 46

def rpm_group
  @rpm_group
end

#rpm_osObject

Returns the value of attribute rpm_os.



43
44
45
# File 'lib/ruby_packager.rb', line 43

def rpm_os
  @rpm_os
end

#rpm_userObject

Returns the value of attribute rpm_user.



45
46
47
# File 'lib/ruby_packager.rb', line 45

def rpm_user
  @rpm_user
end

#staged_filesObject (readonly)

Returns the value of attribute staged_files.



26
27
28
# File 'lib/ruby_packager.rb', line 26

def staged_files
  @staged_files
end

#vendorizeObject

Returns the value of attribute vendorize.



44
45
46
# File 'lib/ruby_packager.rb', line 44

def vendorize
  @vendorize
end

#versionObject

Returns the value of attribute version.



29
30
31
# File 'lib/ruby_packager.rb', line 29

def version
  @version
end

Instance Method Details



95
96
97
98
99
100
# File 'lib/ruby_packager.rb', line 95

def default_links
  {
    "log" => "/var/log/#{@prefix}/#{application_name}",
    "tmp" => "/var/tmp/#{application_name}"
  }
end

#define_tasksObject



71
72
73
74
75
76
77
78
79
# File 'lib/ruby_packager.rb', line 71

def define_tasks
  define_show_config_task
  define_show_staging_list_task
  define_bundle_file_task
  define_stage_task
  define_rpm_task
  define_install_rpm_task
  define_clean_task
end

#filenameObject



81
82
83
84
85
# File 'lib/ruby_packager.rb', line 81

def filename
  full_version = "#{version}"
  full_version += "-#{iteration}" if iteration
  "pkg/#{package_name}-#{full_version}.x86_64.rpm"
end

#generate(filename, &block) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/ruby_packager.rb', line 87

def generate(filename, &block)
  target_file = staged_app(filename)
  file(target_file) do
    block.call(target_file)
  end
  @staged_files << target_file
end

#install(file_list, options = {}) ⇒ Object



48
49
50
51
52
# File 'lib/ruby_packager.rb', line 48

def install(file_list, options = {})
  @staged_files ||= []
  prefix = options[:prefix] ? staged_file_path(options[:prefix]) : staged_app
  @staged_files += map(file_list => prefix)
end


67
68
69
# File 'lib/ruby_packager.rb', line 67

def install_link(src, target)
  @links[src] = target
end


54
55
56
57
# File 'lib/ruby_packager.rb', line 54

def install_rails_app_links
  install_rails_app_log_link
  install_rails_app_tmp_link
end


59
60
61
# File 'lib/ruby_packager.rb', line 59

def install_rails_app_log_link
  install_link("log", "/var/log/#{@prefix}/#{application_name}")
end


63
64
65
# File 'lib/ruby_packager.rb', line 63

def install_rails_app_tmp_link
  install_link("tmp", "/var/tmp/#{application_name}")
end