Class: Rfix::Rake::Gemfile

Inherits:
Dry::Struct
  • Object
show all
Includes:
Dry::Core::Constants, FileUtils
Defined in:
lib/rfix/rake/gemfile.rb

Direct Known Subclasses

AST

Defined Under Namespace

Modules: Types Classes: AST

Constant Summary collapse

FORMAT =
"Gemfile.rubocop-%s%s"
VERSIONS =
[
  "0.82",
  "0.83",
  "0.84",
  "0.92",
  "0.93",
  "1.0.0",
  "1.7.0",
  "1.5.0",
  "1.5.1",
  "1.5.2",
  "1.6.1",
  "1.8.1",
  "1.8.0",
  "1.9.0",
  "1.10.0",
  "1.11.0",
  "1.12.0",
  "1.12.1",
  "1.13.0"
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args, **kwargs, &block) ⇒ Object



59
60
61
# File 'lib/rfix/rake/gemfile.rb', line 59

def self.call(*args, **kwargs, &block)
  (self | AST).call(*args, **kwargs, &block)
end

.files(root_path) ⇒ Object



63
64
65
66
67
# File 'lib/rfix/rake/gemfile.rb', line 63

def self.files(root_path)
  VERSIONS.map do |version|
    Gemfile.call(root_path: root_path, version: version)
  end
end

Instance Method Details

#bundle_lockObject



82
83
84
85
86
# File 'lib/rfix/rake/gemfile.rb', line 82

def bundle_lock
  sh(*lock_args)
rescue RuntimeError
  sh(*lock_args[0..-2])
end

#callObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rfix/rake/gemfile.rb', line 69

def call
  puts "Working with #{version}"

  gemfile.write(content)

  if lockfile.exist?
    lockfile.delete
  end

  bundle_lock
  puts "Finished with #{version}"
end

#lock_argsObject



88
89
90
# File 'lib/rfix/rake/gemfile.rb', line 88

def lock_args
  ["bundle", "lock", "--gemfile", gemfile.to_path, "--local"]
end

#to_sObject



92
93
94
# File 'lib/rfix/rake/gemfile.rb', line 92

def to_s
  gemfile.to_s
end