Class: NetLinx::Rake::ERB::Lines
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- NetLinx::Rake::ERB::Lines
- Defined in:
- lib/netlinx/rake/erb/lines.rb
Overview
Show lines of code for .axi files.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name = :lines) {|_self| ... } ⇒ Lines
constructor
A new instance of Lines.
Constructor Details
#initialize(name = :lines) {|_self| ... } ⇒ Lines
Returns a new instance of Lines.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/netlinx/rake/erb/lines.rb', line 14 def initialize name = :lines @name = name yield self if block_given? desc "Show lines of code for .axi files." task(name) do require 'netlinx/workspace' workspace_path = Dir['*.apw'].first workspace = NetLinx::Workspace.new file: workspace_path file_paths = workspace.projects.first.systems.first.files .map(&:path) .select { |path| File.extname(path) == '.axs' or File.extname(path) == '.axi' } puts "\n\nLines of code..." puts "----------------" lines_by_path = file_paths.map { |path| {path: path, lines: File.read(path).lines.count} } lines_by_path.each do |line_by_path| puts "#{line_by_path[:lines]}\t#{line_by_path[:path]}" end puts "-----\t--------------------" total = 0 lines_by_path.map { |l| l[:lines] }.each { |lines| total += lines } puts "#{total}\tTotal" end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/netlinx/rake/erb/lines.rb', line 12 def name @name end |