Class: Avm::EacRubyBase1::Sources::GemfileLocal

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/eac_ruby_base1/sources/gemfile_local.rb,
lib/avm/eac_ruby_base1/sources/gemfile_local/sibling.rb

Defined Under Namespace

Classes: Sibling

Instance Method Summary collapse

Instance Method Details

#dependency_sub?(sub) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 10

def dependency_sub?(sub)
  sub.is_a?(::Avm::EacRubyBase1::Sources::Base) &&
    sub.gem_name != source.gem_name &&
    source.gemfile_lock_gem_version(sub.gem_name).present?
end

#on_unexisting_gemfile_localObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 26

def on_unexisting_gemfile_local
  return yield unless target_path.exist?

  ::EacRubyUtils::Fs::Temp.on_file do |temp_file|
    ::FileUtils.cp(target_path, temp_file)
    begin
      ::FileUtils.rm_f(target_path)
      yield
    ensure
      ::FileUtils.cp(temp_file, target_path)
    end
  end
end

#run_bundleObject



40
41
42
43
44
45
46
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 40

def run_bundle
  on_unexisting_gemfile_local do
    source.bundle.execute!
  rescue ::RuntimeError
    source.bundle('update').execute!
  end
end

#target_contentString

Returns:

  • (String)


17
18
19
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 17

def target_content
  siblings.map(&:target_content).join
end

#target_pathPathname

Returns:

  • (Pathname)


22
23
24
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 22

def target_path
  source.path.join('Gemfile.local')
end

#write_target_filevoid

This method returns an undefined value.



49
50
51
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 49

def write_target_file
  target_path.write(target_content)
end