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)


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

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



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

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



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

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

#target_contentString

Returns:

  • (String)


19
20
21
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 19

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

#target_pathPathname

Returns:

  • (Pathname)


24
25
26
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 24

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

#write_target_filevoid

This method returns an undefined value.



51
52
53
# File 'lib/avm/eac_ruby_base1/sources/gemfile_local.rb', line 51

def write_target_file
  target_path.write(target_content)
end