Class: Kurgan::Inspect
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Kurgan::Inspect
- Includes:
- Thor::Actions
- Defined in:
- lib/kurgan/inspect.rb
Instance Method Summary collapse
- #check_versions ⇒ Object
- #display ⇒ Object
- #get_cfhighlander_template ⇒ Object
- #get_components ⇒ Object
- #get_project_name ⇒ Object
Instance Method Details
#check_versions ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kurgan/inspect.rb', line 29 def check_versions @components.each do |comp| releases = Kurgan::GitHub.get_releases(comp[:template]) if !releases.nil? && releases.any? latest_release = releases.sort_by { |r| r[:tag_name] }.reverse.first comp[:latest_release] = latest_release[:tag_name] else comp[:latest_release] = 'not found' end end end |
#display ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/kurgan/inspect.rb', line 41 def display puts Terminal::Table.new( :title => "Project: #{@project_name}", :headings => ['Component', 'Version', 'Latest Release'], :rows => @components.map {|comp| [comp[:template], comp[:version], comp[:latest_release]] } ) end |
#get_cfhighlander_template ⇒ Object
8 9 10 11 12 13 |
# File 'lib/kurgan/inspect.rb', line 8 def get_cfhighlander_template @cfhighlander_rb = Dir['*.cfhighlander.rb'][0] if @cfhighlander_rb.nil? raise "No cfhighlander.rb file found in #{Dir.pwd}" end end |
#get_components ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/kurgan/inspect.rb', line 19 def get_components cfhighlander_file = File.read(@cfhighlander_rb) raw_components = cfhighlander_file.scan(/template:\s?(.*?)\s/).flatten @components = raw_components.map do |template_str| template = template_str.strip.gsub(/("|'|,)/, '').split(/(@|#)/) { template: template.first, version: (template.size > 1 ? template.last : "not found") } end end |
#get_project_name ⇒ Object
15 16 17 |
# File 'lib/kurgan/inspect.rb', line 15 def get_project_name @project_name = @cfhighlander_rb.split('.').first end |