Class: Fastlane::Actions::ClocAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/cloc.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, output, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



66
67
68
# File 'lib/fastlane/actions/cloc.rb', line 66

def self.authors
  ["intere"]
end

.available_optionsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/actions/cloc.rb', line 35

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :binary_path,
                                 env_name: "FL_CLOC_BINARY_PATH",
                                 description: "Where the cloc binary lives on your system (full path including 'cloc')",
                                 optional: true,
                                 is_string: true,
                                 default_value: '/usr/local/bin/cloc'),
    FastlaneCore::ConfigItem.new(key: :exclude_dir,
                                 env_name: "FL_CLOC_EXCLUDE_DIR",
                                 description: "Comma separated list of directories to exclude", # a short description of this parameter
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :output_directory,
                                 env_name: "FL_CLOC_OUTPUT_DIRECTORY",
                                 description: "Where to put the generated report file",
                                 is_string: true,
                                 default_value: "build"),
    FastlaneCore::ConfigItem.new(key: :source_directory,
                                env_name: "FL_CLOC_SOURCE_DIRECTORY",
                                description: "Where to look for the source code (relative to the project root folder)",
                                is_string: true,
                                default_value: ""),
    FastlaneCore::ConfigItem.new(key: :xml,
                                env_name: "FL_CLOC_XML",
                                description: "Should we generate an XML File (if false, it will generate a plain text file)?",
                                is_string: false,
                                default_value: true)
  ]
end

.categoryObject



84
85
86
# File 'lib/fastlane/actions/cloc.rb', line 84

def self.category
  :misc
end

.descriptionObject



24
25
26
# File 'lib/fastlane/actions/cloc.rb', line 24

def self.description
  "Generates a Code Count that can be read by Jenkins (xml format)"
end

.detailsObject



28
29
30
31
32
33
# File 'lib/fastlane/actions/cloc.rb', line 28

def self.details
  [
    "This action will run cloc to generate a SLOC report that the Jenkins SLOCCount plugin can read.",
    "See https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin and https://github.com/AlDanial/cloc for more information."
  ].join("\n")
end

.example_codeObject



74
75
76
77
78
79
80
81
82
# File 'lib/fastlane/actions/cloc.rb', line 74

def self.example_code
  [
    'cloc(
       exclude_dir: "ThirdParty,Resources",
       output_directory: "reports",
       source_directory: "MyCoolApp"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/fastlane/actions/cloc.rb', line 70

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fastlane/actions/cloc.rb', line 4

def self.run(params)
  cloc_binary = params[:binary_path]
  exclude_dirs = params[:exclude_dir].nil? ? '' : "--exclude-dir=#{params[:exclude_dir]}"
  xml_format = params[:xml]
  out_dir = params[:output_directory]
  output_file = xml_format ? "#{out_dir}/cloc.xml" : "#{out_dir}/cloc.txt"
  source_directory = params[:source_directory]

  command = [
    cloc_binary,
    exclude_dirs,
    '--by-file',
    xml_format ? '--xml ' : '',
    "--out=#{output_file}",
    source_directory
  ].join(' ').strip

  Actions.sh command
end