fastlane-plugin-number_of_swift_lines 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea038275e18b211309437fa068137bfb85a8c1e0
4
- data.tar.gz: 05662f5ac41c0c9844e6acc9dd91ad26ad8b81de
3
+ metadata.gz: '080c728e50a90f2ee634cc5314706462f9c08035'
4
+ data.tar.gz: 0f8b91ece89e7e50780d97c95953c57fe09546f6
5
5
  SHA512:
6
- metadata.gz: 67721a8131b9e44ee5d15fea384c85fe38ecd07a234d5d4cf94e232e4e8c642717ec9155a329f23e74601f862e33bf5ab7c97be308491bf4b8bb211ce8f107c9
7
- data.tar.gz: 8c7deda440a631c56181a7a126c89efca40f5d3c5af8327206e9c5db85f3f07675b6500ebe264d4fa69f7d057a9b15880ad4cfab20bea36c26f086ae4fa9fe91
6
+ metadata.gz: c468309674d66286b657263b2622f2ba1f98b8212eabe39ce55eb194d95545826a4aaf6eb4e0064552451194893b12132f128477eb6ef60148889016eaf565a6
7
+ data.tar.gz: d0e75e7b95268cb7919c93d3bb6938de7e743d402bf80a2125f56b943186a07e28d5a70836a72b88a085498c1096716f2dbc81404701f4c978fa0d5c2d7b0162
data/README.md CHANGED
@@ -12,7 +12,7 @@ fastlane add_plugin number_of_swift_lines
12
12
 
13
13
  ## About number_of_swift_lines
14
14
 
15
- Outputs the total number of swift lines
15
+ Outputs the total number of lines of swift code, number of swift files, and a list of the most largest swift files.
16
16
 
17
17
  **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
18
 
@@ -1,46 +1,96 @@
1
1
  module Fastlane
2
2
  module Actions
3
+ module SharedValues
4
+ NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES = :NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES
5
+ NUMBER_OF_SWIFT_FILES = :NUMBER_OF_SWIFT_FILES
6
+ NUMBER_OF_SWIFT_LINES = :NUMBER_OF_SWIFT_LINES
7
+ end
8
+
3
9
  class NumberOfSwiftLinesAction < Action
4
10
  def self.run(params)
5
11
  require 'artii'
6
- if not File.exists?('/usr/local/bin/cloc')
7
- UI.error("\nWarning! cloc is not installed in /usr/local/bin/cloc\nrun: brew install cloc")
12
+
13
+ number_of_largest_files = params[:largest_files_cap]
14
+ show_ascii = params[:enable_ascii_art]
15
+ exclude_regex = params[:files_exclude_regex]
16
+
17
+ current_dir = Dir.pwd
18
+ swift_files = `find #{current_dir} -name \"*.swift\" | egrep -v \"#{exclude_regex}\"`
19
+ if swift_files.empty?
20
+ UI.error("No swift files found :(")
8
21
  exit 1
9
22
  end
10
23
 
11
- result = Action.sh("/usr/local/bin/cloc . --include-lang=\"Swift\" --not-match-d='.*Tests' --ignore-whitespace --quiet | grep \"Swift\" | awk '{print $5\"-\"$2}'")
12
- array = result.split("-")
13
- a = Artii::Base.new :font => 'univers'
14
- UI.message("\n" + a.asciify(array[0] + " loc"))
15
- UI.message("\n" + a.asciify(array[1] + " swift files"))
16
- return result
24
+ number_of_files = `echo '#{swift_files}' | wc -l | awk '{print $1}'`
25
+ number_of_lines = `echo '#{swift_files}' | xargs wc -l | tail -1 | awk '{print $1}'`
26
+ largest_files = `echo '#{swift_files}' | xargs wc -l | sort -n | tail -'#{number_of_largest_files.to_s}' | head -'#{(number_of_largest_files-1).to_s}'`
27
+ number_of_lines_largest_file = `echo '#{swift_files}' | xargs wc -l | sort -n | tail -2 | head -1 | awk '{print $1}'`
28
+
29
+ ascii_message = ""
30
+ if show_ascii == true then
31
+ a = Artii::Base.new :font => 'univers'
32
+ ascii_message = a.asciify(number_of_lines_largest_file)
33
+ ascii_message += a.asciify(number_of_files)
34
+ ascii_message += a.asciify(number_of_lines)
35
+ end
36
+
37
+ UI.message("\n\n" + "The " + number_of_largest_files.to_s + " largest files in ascending order:\n\n" + largest_files \
38
+ + "\n\nNumber of lines in the largest swift file:\t" + number_of_lines_largest_file \
39
+ + "Total number of swift files:\t\t\t" + number_of_files \
40
+ + "Total number of swift lines of code:\t\t" + number_of_lines + "\n"\
41
+ + ascii_message)
42
+
43
+ Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES] = number_of_lines_largest_file
44
+ Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_FILES] = number_of_files
45
+ Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_LINES] = number_of_lines
46
+
17
47
  end
18
48
 
19
49
  def self.description
20
- "Outputs the total number of swift lines"
50
+ "Outputs the total number of lines of swift code, number of swift files, and a list of the largest swift files."
21
51
  end
22
52
 
23
53
  def self.authors
24
- ["Dennis Charmington"]
54
+ ["@BinaryDennis"]
25
55
  end
26
56
 
27
57
  def self.return_value
28
58
  # If your method provides a return value, you can describe here what it does
59
+ [
60
+ ['NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES', 'The number of lines in the largets swift file'],
61
+ ['NUMBER_OF_SWIFT_FILES', 'The total number of swift files'],
62
+ ['NUMBER_OF_SWIFT_LINES', 'The total number of swift lines in all swift files']
63
+ ]
29
64
  end
30
65
 
31
66
  def self.details
32
67
  # Optional:
33
- "Using ASCII art to output the total number of code lines written in Swift, excluding all the lines used in unit & UI tests"
68
+ "Using ASCII art to output the total number of code lines written in Swift, excluding all the lines used in unit & UI tests. But also outputs the total number of swift files and a list of the largest swift files."
34
69
  end
35
70
 
36
71
  def self.available_options
37
72
  [
38
- # FastlaneCore::ConfigItem.new(key: :your_option,
39
- # env_name: "NUMBER_OF_SWIFT_LINES_YOUR_OPTION",
40
- # description: "A description of your option",
41
- # optional: false,
42
- # type: String)
43
- ]
73
+ FastlaneCore::ConfigItem.new(key: :largest_files_cap,
74
+ env_name: "LARGEST_FILES_CAP",
75
+ description: "Determines how many files to list, when showing the largets files",
76
+ optional: true,
77
+ default_value: 10,
78
+ type: Integer),
79
+
80
+ FastlaneCore::ConfigItem.new(key: :enable_ascii_art,
81
+ env_name: "ENABLE_ASCII_ART",
82
+ description: "If enabled, shows the total number of swift lines in ASCII art",
83
+ optional: true,
84
+ default_value: true,
85
+ type: [TrueClass, FalseClass]),
86
+
87
+ FastlaneCore::ConfigItem.new(key: :files_exclude_regex,
88
+ env_name: "FILES_EXCLUDE_REGEX",
89
+ description: "Regex string used with grep to exclude files from the list of all swift files",
90
+ optional: true,
91
+ default_value: "(/Tests|/Pods|/Frameworks|/Carthage)",
92
+ type: String)
93
+ ]
44
94
  end
45
95
 
46
96
  def self.is_supported?(platform)
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module NumberOfSwiftLines
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-number_of_swift_lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Charmington
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: artii
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.6.8
171
+ rubygems_version: 2.5.2
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Outputs the total number of swift lines