Class: Oops::Tasks

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/oops/tasks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Tasks

Returns a new instance of Tasks.

Yields:

  • (_self)

Yield Parameters:

  • _self (Oops::Tasks)

    the object that the method was called on



19
20
21
22
23
24
25
# File 'lib/oops/tasks.rb', line 19

def initialize(&block)
  self.class.default_args.each do |key, value|
    public_send("#{key}=", value)
  end
  yield(self)
  create_task!
end

Instance Attribute Details

#additional_pathsObject

Returns the value of attribute additional_paths.



7
8
9
# File 'lib/oops/tasks.rb', line 7

def additional_paths
  @additional_paths
end

#excludesObject

Returns the value of attribute excludes.



7
8
9
# File 'lib/oops/tasks.rb', line 7

def excludes
  @excludes
end

#formatObject

Returns the value of attribute format.



7
8
9
# File 'lib/oops/tasks.rb', line 7

def format
  @format
end

#includesObject

Returns the value of attribute includes.



7
8
9
# File 'lib/oops/tasks.rb', line 7

def includes
  @includes
end

#prerequisitesObject

Returns the value of attribute prerequisites.



7
8
9
# File 'lib/oops/tasks.rb', line 7

def prerequisites
  @prerequisites
end

Class Method Details

.default_argsObject



9
10
11
12
13
14
15
16
17
# File 'lib/oops/tasks.rb', line 9

def self.default_args
  {
    prerequisites: ['assets:clean', 'assets:precompile'],
    additional_paths: [],
    includes: ['public/assets'],
    excludes: ['.gitignore'],
    format: 'zip'
  }
end

Instance Method Details

#add_file(file_path, path) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/oops/tasks.rb', line 27

def add_file file_path, path
  if format == 'zip'
    sh *%W{zip -r -g build/#{file_path} #{path}}
  elsif format == 'tar'
    sh *%W{tar -r -f build/#{file_path} #{path}}
  end
end

#remove_file(file_path, path) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/oops/tasks.rb', line 35

def remove_file file_path, path
  if format == 'zip'
    sh *%W{zip build/#{file_path} -d #{path}}
  elsif format == 'tar'
    sh *%W{tar --delete -f build/#{file_path} #{path}}
  end
end