Class: KnifeChangelog::Changelog::Berksfile

Inherits:
KnifeChangelog::Changelog show all
Defined in:
lib/knife/changelog/berksfile.rb

Constant Summary

Constants inherited from KnifeChangelog::Changelog

GERRIT_REGEXP

Instance Method Summary collapse

Methods inherited from KnifeChangelog::Changelog

#clean, #cookbook_highest_version, #detect_cur_revision, #execute, #format_changelog, #generate_from_changelog_file, #generate_from_git_history, #get_from_supermarket_sources, #handle_git, #handle_new_cookbook, #handle_source, #handle_submodule, #https_url, #linkify, #run, #short

Constructor Details

#initialize(berksfile, config) ⇒ Berksfile

Returns a new instance of Berksfile.



8
9
10
11
12
13
14
# File 'lib/knife/changelog/berksfile.rb', line 8

def initialize(berksfile, config)
  require 'berkshelf'
  @locked_versions = berksfile.lockfile.locks
  @sources = berksfile.sources
  @berksfile = berksfile
  super(config)
end

Instance Method Details

#all_cookbooksObject



16
17
18
# File 'lib/knife/changelog/berksfile.rb', line 16

def all_cookbooks
  @locked_versions.keys
end

#git?(name) ⇒ Boolean

return true if cookbook is downloaded from git

Returns:

  • (Boolean)


32
33
34
# File 'lib/knife/changelog/berksfile.rb', line 32

def git?(name)
  ck_dep(name).location.is_a?(Berkshelf::GitLocation)
end

#git_location(name) ⇒ Object

return a Changelog::Location for this cookbook



42
43
44
45
# File 'lib/knife/changelog/berksfile.rb', line 42

def git_location(name)
  raise "#{name} has not a git location" unless git?(name)
  Location.from_berk_git_location(ck_dep(name).location)
end

#guess_version_for(name) ⇒ Object



53
54
55
# File 'lib/knife/changelog/berksfile.rb', line 53

def guess_version_for(name)
  @locked_versions[name].locked_version.to_s
end

#local?(name) ⇒ Boolean

return true if cookbook is downloaded from local path

Returns:

  • (Boolean)


37
38
39
# File 'lib/knife/changelog/berksfile.rb', line 37

def local?(name)
  ck_dep(name).location.is_a?(Berkshelf::PathLocation)
end

#new_cookbook?(name) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/knife/changelog/berksfile.rb', line 20

def new_cookbook?(name)
  ck_dep(name).nil?
end

#supermarket?(name) ⇒ Boolean

return true if cookbook is downloaded from supermarket

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/knife/changelog/berksfile.rb', line 25

def supermarket?(name)
  # here is berkshelf "expressive" way to say cookbook
  # comes from supermarket
  ck_dep(name).location.is_a?(NilClass)
end

#supermarkets_for(_name) ⇒ Object

return a list of supermarket uri for a given cookbook example: [ ‘supermarket.chef.io’ ]



49
50
51
# File 'lib/knife/changelog/berksfile.rb', line 49

def supermarkets_for(_name)
  @sources.map(&:uri)
end

#update(cookbooks) ⇒ Object



57
58
59
# File 'lib/knife/changelog/berksfile.rb', line 57

def update(cookbooks)
  @berksfile.update(*cookbooks)
end