Class: KrackerController
- Inherits:
-
KrackerApplicationController
- Object
- ApplicationController
- KrackerApplicationController
- KrackerController
- Defined in:
- app/controllers/kracker_controller.rb
Instance Method Summary collapse
- #about ⇒ Object
- #artifacts ⇒ Object
- #artifacts_delete ⇒ Object
- #artifacts_expand ⇒ Object
- #bless ⇒ Object
- #clear ⇒ Object
- #delete_current ⇒ Object
- #index ⇒ Object
- #make_master ⇒ Object
- #new ⇒ Object
- #path_config ⇒ Object
- #show ⇒ Object
Methods inherited from KrackerApplicationController
Instance Method Details
#about ⇒ Object
77 78 79 80 81 |
# File 'app/controllers/kracker_controller.rb', line 77 def about about_file = File.('../../../README.md', __FILE__) raw = File.read(about_file) @about = Kramdown::Document.new(raw).to_html end |
#artifacts ⇒ Object
52 53 54 55 |
# File 'app/controllers/kracker_controller.rb', line 52 def artifacts artifacts_location = File.(File.join('~', 'Downloads', '*_artifacts.zip')) @artifacts = Dir.glob(artifacts_location).map { |f| File.basename(f) } end |
#artifacts_delete ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/kracker_controller.rb', line 57 def artifacts_delete artifacts = params[:file].gsub('^', '.') FileUtils.rm_rf File.(File.join('~', 'Downloads', artifacts)) redirect_to '/kracker/artifacts' end |
#artifacts_expand ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/kracker_controller.rb', line 63 def artifacts = params[:file].gsub('^', '.') artifacts = File.(File.join('~', 'Downloads', artifacts)) Zip::ZipFile.open(artifacts) do |zip_file| zip_file.each do |entry| file_destination = generate_unzip_destination(entry.name) File.open(file_destination, 'wb') { |file| file.write(zip_file.read(entry)) } if file_destination end end redirect_to kracker_path end |
#bless ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/controllers/kracker_controller.rb', line 89 def bless blessings = [] params.each_pair { |k, v| blessings << v if k.start_with?('option_') } blessings.each do |blessing| base_test_name = blessing src_yaml = Kracker.current_filename(base_test_name) dst_yaml = Kracker.master_filename(base_test_name) FileUtils.cp src_yaml, dst_yaml if File.exist?(src_yaml) if params['delete_on_bless'] == 'true' files_to_remove = [Kracker.diff_filename(base_test_name)] files_to_remove << File.join(Kracker.diff_file_location, blessing + '__current_not_master__diff.yaml') files_to_remove << File.join(Kracker.diff_file_location, blessing + '__master_not_current__diff.yaml') files_to_remove << File.join(Kracker.diff_file_location, blessing + '__changed_master__diff.yaml') files_to_remove.each { |f| FileUtils.rm_rf f } end end redirect_to kracker_path end |
#clear ⇒ Object
83 84 85 86 87 |
# File 'app/controllers/kracker_controller.rb', line 83 def clear Dir[File.join(Kracker.diff_file_location, '*.yaml'), File.join(Kracker.diff_file_location, '*.html')].each { |f| FileUtils.rm_rf(f) } Dir[File.join(Kracker.current_file_location, '*.yaml')].each { |f| FileUtils.rm_rf(f) } redirect_to kracker_path end |
#delete_current ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/controllers/kracker_controller.rb', line 44 def delete_current test_root = params[:file] src = Kracker.current_filename(test_root) FileUtils.rm_rf src redirect_to '/kracker/new' end |
#index ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/controllers/kracker_controller.rb', line 6 def index @files = if Kracker.diff_file_location Dir[File.join(Kracker.diff_file_location, "*_diff.html")].map{|f| File.basename(f)} else [] end end |
#make_master ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/kracker_controller.rb', line 35 def make_master test_root = params[:file] src = Kracker.current_filename(test_root) dst = Kracker.master_filename(test_root) FileUtils.cp src, dst redirect_to '/kracker/new' end |
#new ⇒ Object
28 29 30 31 32 33 |
# File 'app/controllers/kracker_controller.rb', line 28 def new @files_current = Dir[File.join(Kracker.current_file_location, '*.yaml')].map { |f| File.basename(f).gsub('.yaml', '') } @files_master = Dir[File.join(Kracker.master_file_location, '*.yaml')].map { |f| File.basename(f).gsub('.yaml', '') } @extra_files = @files_current.select { |f| !@files_master.include?("#{f}_master")}.sort end |
#path_config ⇒ Object
25 26 |
# File 'app/controllers/kracker_controller.rb', line 25 def path_config end |
#show ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/kracker_controller.rb', line 14 def show @test_root = params[:diff_file].gsub('_diff', '').gsub('.html', '') @file_diff = "#{@test_root}_diff.html" @file_set_not_master = "#{@test_root}__current_not_master__diff.yaml" @file_set_not_current = "#{@test_root}__master_not_current__diff.yaml" @file_set_changed = "#{@test_root}__changed_master__diff.yaml" @file_diff = "#{@test_root}_diff.html" end |