Class: ChefServerSlice::CookbookLibraries

Inherits:
Application
  • Object
show all
Includes:
Chef::Mixin::Checksum
Defined in:
app/controllers/cookbook_libraries.rb

Instance Method Summary collapse

Methods inherited from Application

#absolute_slice_url, #access_denied, #authorized_node, #escape_node_id, #expand_cookbook_deps, #fix_up_node_id, #get_available_recipes, #load_all_files, #load_cookbook_segment, #login_required, #redirect_back_or_default, #segment_files, #specific_cookbooks, #store_location

Instance Method Details

#indexObject



34
35
36
37
38
39
40
41
# File 'app/controllers/cookbook_libraries.rb', line 34

def index
  if params[:id]
    show
  else
    load_cookbook_libs()
    display @lib_files
  end
end

#load_cookbook_libsObject



30
31
32
# File 'app/controllers/cookbook_libraries.rb', line 30

def load_cookbook_libs()
  @lib_files = load_cookbook_segment(params[:cookbook_id], :libraries)
end

#showObject

Raises:

  • (NotFound)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/cookbook_libraries.rb', line 43

def show
  only_provides :json
  load_cookbook_libs
  raise NotFound, "Cannot find a suitable library file!" unless @lib_files.has_key?(params[:id])
  
  to_send = @lib_files[params[:id]][:file]
  current_checksum = checksum(to_send)
  Chef::Log.debug("Old sum: #{params[:checksum]}, New sum: #{current_checksum}") 
  if current_checksum == params[:checksum]
    display "File #{to_send} has not changed", :status => 304
  else
    send_file(to_send)
  end
end