Class: LogicalConstruct::Plan::StandaloneBundle

Inherits:
Mattock::TaskLib
  • Object
show all
Includes:
Mattock::CommandLineDSL
Defined in:
lib/logical-construct/plan/standalone-bundle.rb

Instance Method Summary collapse

Instance Method Details

#default_configuration(core) ⇒ Object



14
15
16
17
# File 'lib/logical-construct/plan/standalone-bundle.rb', line 14

def default_configuration(core)
  super
  target_dir.absolute_path = core.absolute_path
end

#defineObject



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
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/logical-construct/plan/standalone-bundle.rb', line 24

def define
  directory gems.absolute_path

  #TODO: Experiment with
  #
  #bundle install
  #bundle package --all
  #....
  #bundle install --local
  in_namespace do
    #bundler unconditionally re-produces bundle/setup.rb, which means
    #that plans that use this tasklib will always be re-packed, even when
    #the contents haven't changed significantly.
    #
    #It's possible that a "hash difference" file task could be written
    #for setup.rb? Kind of a hack. Or else tell bundler that it's config
    #dir goes in a temp directory, and then we move things, or local
    #rsync --checksum or something.
    Mattock::BundleCommandTask.define_task(:standalone => gems.absolute_path) do |bundle_build|
      bundle_build.command = (
        cmd("cd", target_dir.absolute_path) &
        cmd("bundle", "install"){|bundler|
        bundler.options << "--gemfile=" + gemfile.absolute_path
        bundler.options << "--path=" + gems.absolute_path
        bundler.options << "--standalone"
        bundler.options << "--binstubs=bin"
      })
    end

    task :pristine => gems.absolute_path do
      gem_scope = [Gem.ruby_engine, Gem::ConfigMap[:ruby_version]].join("/")

      cmd_env = {
        "RUBYOPT" => "",
        "GEM_HOME" => gems.pathname.join(gem_scope).to_s #XXX update this to use gem_scope from flight-deck
      }

      cmd("gem pristine") do |gem|
        gem.options << "--all"
        gem.options << "--extensions"
        gem.command_environment.merge! cmd_env
      end.must_succeed!
    end

    task :load_setup do
      require gems.pathname.join("bundler/setup")
    end
  end

  task 'install:perform' => self[:pristine]
  task 'compile:perform' => self[:standalone]
  task 'compile:preflight' => gemfile.absolute_path
  task :preflight => self[:load_setup]
end

#resolve_configurationObject



19
20
21
22
# File 'lib/logical-construct/plan/standalone-bundle.rb', line 19

def resolve_configuration
  resolve_paths
  super
end