class Fastlane::Actions::ClocAction

Public Class Methods

authors() click to toggle source
# File fastlane/lib/fastlane/actions/cloc.rb, line 62
def self.authors
  ["intere"]
end
available_options() click to toggle source
# File fastlane/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,
                                 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",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :output_directory,
                                 env_name: "FL_CLOC_OUTPUT_DIRECTORY",
                                 description: "Where to put the generated report file",
                                 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)",
                                 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)?",
                                 type: Boolean,
                                 default_value: true)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/cloc.rb, line 80
def self.category
  :misc
end
description() click to toggle source
# File fastlane/lib/fastlane/actions/cloc.rb, line 24
def self.description
  "Generates a Code Count that can be read by Jenkins (xml format)"
end
details() click to toggle source
# File fastlane/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](https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin) and [https://github.com/AlDanial/cloc](https://github.com/AlDanial/cloc) for more information."
  ].join("\n")
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/cloc.rb, line 70
def self.example_code
  [
    'cloc(
       exclude_dir: "ThirdParty,Resources",
       output_directory: "reports",
       source_directory: "MyCoolApp"
    )'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/cloc.rb, line 66
def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end
run(params) click to toggle source
# File fastlane/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