Class: Pantograph::Actions::ClocAction
- Inherits:
-
Pantograph::Action
- Object
- Pantograph::Action
- Pantograph::Actions::ClocAction
- Defined in:
- pantograph/lib/pantograph/actions/cloc.rb
Constant Summary
Constants inherited from Pantograph::Action
Pantograph::Action::AVAILABLE_CATEGORIES, Pantograph::Action::RETURN_TYPES
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Methods inherited from Pantograph::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
78 79 80 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 78 def self. ['johnknapprs'] end |
.available_options ⇒ Object
30 31 32 33 34 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 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 30 def self. [ PantographCore::ConfigItem.new( key: :binary_path, env_name: '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' ), PantographCore::ConfigItem.new( key: :exclude_dir, env_name: 'CLOC_EXCLUDE_DIR', description: 'Comma separated list of directories to exclude', optional: true, is_string: true ), PantographCore::ConfigItem.new( key: :source_directory, env_name: 'CLOC_SOURCE_DIRECTORY', description: 'Starting point for Cloc analysis', is_string: true, default_value: '.' ), PantographCore::ConfigItem.new( key: :output_directory, env_name: 'CLOC_OUTPUT_DIRECTORY', description: 'Where to put the generated report file', is_string: true, default_value: 'pantograph/reports' ), PantographCore::ConfigItem.new( key: :output_type, env_name: 'CLOC_OUTPUT_TYPE', description: 'Output file type: xml, yaml, cvs, json', is_string: true, default_value: 'yaml' ), PantographCore::ConfigItem.new( key: :list_each_file, env_name: 'CLOC_LIST_EACH_FILE', description: 'List each individual file in cloc report', is_string: false, default_value: true ) ] end |
.category ⇒ Object
99 100 101 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 99 def self.category :misc end |
.description ⇒ Object
19 20 21 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 19 def self.description 'Generates a Code Count that can be read by Jenkins (xml format)' end |
.details ⇒ Object
23 24 25 26 27 28 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 23 def self.details [ 'This action will run cloc to generate a code count report', 'See [https://github.com/AlDanial/cloc](https://github.com/AlDanial/cloc) for more information.' ].join("\n") end |
.example_code ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 86 def self.example_code [ ' # Generate JSON report of project code count cloc( exclude_dir: "build", source_directory: ".", output_directory: "pantograph/reports", output_type: "json" ) ' ] end |
.is_supported?(platform) ⇒ Boolean
82 83 84 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 82 def self.is_supported?(platform) [:mac].include?(platform) end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'pantograph/lib/pantograph/actions/cloc.rb', line 4 def self.run(params) output_type = params[:output_type] cloc_cmd = [] cloc_cmd << params[:binary_path] cloc_cmd << params[:source_directory] cloc_cmd << "--exclude-dir=#{params[:exclude_dir]}" if params[:exclude_dir] cloc_cmd << '--by-file' if params[:list_each_file] cloc_cmd << "--#{output_type}" cloc_cmd << "--report-file=#{params[:output_directory]}/cloc.#{output_type}" cloc_cmd = cloc_cmd.join(' ').strip Actions.sh(cloc_cmd) end |