Class: Rys::Bundler::Commands::Build

Inherits:
Base
  • Object
show all
Defined in:
lib/rys/bundler/commands/build.rb

Direct Known Subclasses

BuildDeployment, BuildLocal

Constant Summary collapse

COMMENT_PREFIX =
'# RYS_BUILDER #'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#command, #get_redmine_plugin!, #pastel, #prompt, #ui

Constructor Details

#initialize(options) ⇒ Build

Returns a new instance of Build.



66
67
68
# File 'lib/rys/bundler/commands/build.rb', line 66

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/rys/bundler/commands/build.rb', line 11

def options
  @options
end

Class Method Details

.run(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rys/bundler/commands/build.rb', line 13

def self.run(args)
  options = OpenStruct.new
  options.deployment = false
  options.submodules = false
  options.redmine_plugin = nil

  OptionParser.new do |opts|
    opts.banner = 'Usage: bundle rys build [options]'

    opts.on('-d', '--deployment', 'Prepare gems for deployment') do |value|
      options.deployment = value
    end

    # Quite a dangerous switch so do not add a short switch!!!
    opts.on('--revert', 'Revert build (dangerous operation)') do |value|
      options.revert = value
    end

    opts.on('-s', '--submodules', 'Add gems as submodules (experimental)') do |value|
      options.submodules = value
      abort('Not yet implemented')
    end

    opts.on('-r', '--redmine-plugin PATH', 'Redmine plugin for rys gems') do |value|
      options.redmine_plugin = Pathname.new(value)
    end

    opts.on_tail('-h', '--help', 'Show this message') do
      puts opts
      exit
    end

    opts.on_tail('-v', '--version', 'Show version') do
      puts ::Rys::Bundler::VERSION
      exit
    end
  end.parse(args)

  if options.deployment
    klass = BuildDeployment
  else
    klass = BuildLocal
  end

  instance = klass.new(options)

  if options.revert
    instance.run_revert
  else
    instance.run
  end
end

Instance Method Details

#runObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/rys/bundler/commands/build.rb', line 70

def run
  prepare_target
  prepare_to_copy
  copy_dependencies
  comment_copied
  save_report

  ui.info ''
  ui.info 'You may want run bundle install again (just for sure)'
end

#run_revertObject



81
82
83
84
85
86
87
# File 'lib/rys/bundler/commands/build.rb', line 81

def run_revert
  prepare_target
  prepare_to_delete
  delete_dependencies
  uncomment_deleted
  delete_report
end