Class: Bundler::Changelogs::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/changelogs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_lockfile_parsedObject

Returns the value of attribute current_lockfile_parsed.



11
12
13
# File 'lib/bundler/changelogs.rb', line 11

def current_lockfile_parsed
  @current_lockfile_parsed
end

#previous_lockfile_parsedObject

Returns the value of attribute previous_lockfile_parsed.



12
13
14
# File 'lib/bundler/changelogs.rb', line 12

def previous_lockfile_parsed
  @previous_lockfile_parsed
end

Instance Method Details

#exec(_name, args) ⇒ Object



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
# File 'lib/bundler/changelogs.rb', line 20

def exec(_name, args)
  if args.any?
    Bundler.require(:default, *args.map!(&:to_sym))
  else
    Bundler.require
  end

  current_lockfile = '.changelogs_gems.locked'
  previous_lockfile_content = `git show #{Bundler.settings[:changlog_commit] || "HEAD"}:#{current_lockfile}`

  self.current_lockfile_parsed = Bundler::LockfileParser.new(Bundler.read_file(current_lockfile))
  self.previous_lockfile_parsed = Bundler::LockfileParser.new(previous_lockfile_content)

  ARGV.clear
  gems = get_gems_with_changelogs
  binding.pry
  if gems.empty?
    Bundler.ui.error("Up to date. Nothing to show. Or: you already commmited the bundle changes to git? You can specify a range of git commits like this: TODO")
    return
  end

  io = StringIO.new
  write_changelog_output!(gems,io)
  io.rewind

  changelog_output_path = Bundler.settings[:changelog_output_path] 
  if changelog_output_path 
    path = Pathname.new(changelog_output_path)
    path.open("w+"){|f| f.puts io.read }

    #TODO: how to get CWD, crossplatform? Then, remove this verbosity.
    #TODO: other than error...
    Bundler.ui.info("Changelogs written to: #{path}")
  else
    Bundler.ui.info(io.read)
  end

end