Class: BranchIOCLI::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/branch_io_cli/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :branch, &b) ⇒ RakeTask

Returns a new instance of RakeTask.



10
11
12
13
14
15
16
# File 'lib/branch_io_cli/rake_task.rb', line 10

def initialize(name = :branch, &b)
  namespace name do
    report_task
    setup_task
    validate_task
  end
end

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



8
9
10
# File 'lib/branch_io_cli/rake_task.rb', line 8

def defaults
  @defaults
end

Instance Method Details

#report_taskObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/branch_io_cli/rake_task.rb', line 18

def report_task
  desc "Generate a brief Branch report"
  task :report, %i{paths options} do |task, args|
    paths = args[:paths]
    paths = [paths] unless paths.respond_to?(:each)

    paths.each do |path|
      Dir.chdir(path) do |p|
        Command::ReportCommand.new(Configuration::ReportConfiguration.wrapper(args[:options])).run!
      end
    end
  end
end

#setup_taskObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/branch_io_cli/rake_task.rb', line 32

def setup_task
  desc "Set a project up with the Branch SDK"
  task :setup, %i{paths options} do |task, args|
    paths = args[:paths]
    paths = [paths] unless paths.respond_to?(:each)

    paths.each do |path|
      Dir.chdir(path) do |p|
        Command::SetupCommand.new(Configuration::SetupConfiguration.wrapper(args[:options])).run!
      end
    end
  end
end

#validate_taskObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/branch_io_cli/rake_task.rb', line 46

def validate_task
  desc "Validate universal links in one or more projects"
  task :validate, %i{paths options} do |task, args|
    paths = args[:paths]
    paths = [paths] unless paths.respond_to?(:each)

    paths.each do |path|
      Dir.chdir(path) do |p|
        Command::ValidateCommand.new(Configuration::ValidateConfiguration.wrapper(args[:options] || {})).run!
      end
    end
  end
end