Module: Ajax::Helpers::TaskHelper

Defined in:
lib/ajax/helpers/task_helper.rb

Constant Summary collapse

INSTALL_FILES =
%w[
  app/views/layouts/ajax/application.html.erb
  app/controllers/ajax_controller.rb
  app/views/ajax/framework.html.erb
  config/initializers/ajax.rb
  public/images/ajax-loading.gif
  public/javascripts/ajax.js
  public/javascripts/jquery.address-1.3.js
  public/javascripts/jquery.address-1.3.min.js
  public/javascripts/jquery.json-2.2.min.js
]
UPDATE_JAVASCRIPT_FILES =
%w[
public/javascripts/ajax.js]

Instance Method Summary collapse

Instance Method Details

#copy_and_overwrite(file, from_dir = nil, to_dir = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/ajax/helpers/task_helper.rb', line 34

def copy_and_overwrite(file, from_dir=nil, to_dir=nil)
  to_dir ||= Rails.root.to_s
  from_dir ||= Ajax.root.to_s
  from_file, to_file = File.join(from_dir, file), File.join(to_dir, file)
  FileUtils.mkdir_p(File.dirname(to_file)) unless File.directory?(File.dirname(to_file))
  FileUtils.cp(from_file, to_file)
  return true
rescue Exception => e
  e
end

#copy_unless_exists(file, from_dir = nil, to_dir = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ajax/helpers/task_helper.rb', line 19

def copy_unless_exists(file, from_dir=nil, to_dir=nil)
  to_dir ||= Rails.root.to_s
  from_dir ||= Ajax.root.to_s
  from_file, to_file = File.join(from_dir, file), File.join(to_dir, file)
  if File.exist?(to_file)
    return false
  else
    FileUtils.mkdir_p(File.dirname(to_file)) unless File.directory?(File.dirname(to_file))
    FileUtils.cp(from_file, to_file)
    return true
  end
rescue Exception => e
  e
end

#show_result(file) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ajax/helpers/task_helper.rb', line 45

def show_result(file)
  result = yield file
  return unless verbose

  case result
  when Exception
    puts "skipped: #{file} #{result.message}"
  when true
    puts "created: #{file}"
  else
    puts "skipped: #{file}"
  end
end