Class: ChefServerSlice::CookbookSegment
- Inherits:
-
Application
- Object
- Merb::Controller
- Application
- ChefServerSlice::CookbookSegment
show all
- Includes:
- Chef::Mixin::Checksum
- Defined in:
- app/controllers/cookbook_segment.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
#index ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/controllers/cookbook_segment.rb', line 31
def index
if params[:id]
show
else
display load_cookbook_segment(params[:cookbook_id], params[:type])
end
end
|
#show ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/cookbook_segment.rb', line 39
def show
only_provides :json
files = load_cookbook_segment(params[:cookbook_id], params[:type])
raise NotFound, "Cannot find a suitable #{params[:type].to_s.singularize} file!" unless files.has_key?(params[:id])
to_send = 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
|