Class: Gemshine::Command

Inherits:
Object
  • Object
show all
Includes:
UI, Thor::Actions, Thor::Base, Thor::Shell
Defined in:
lib/gemshine/command.rb

Constant Summary

Constants included from UI

UI::MSG_BUNDLE_ERROR, UI::MSG_BUNDLE_OUTDATED, UI::MSG_BUNDLE_UP_TO_DATE, UI::MSG_GATHER_OUTDATED, UI::MSG_MISSING_GEMFILE, UI::MSG_PATH_STATS, UI::MSG_UP_TO_DATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UI

#detect_outdated_color, #gem_table, #log_bundle_message, #log_missing, #log_path_stats, #log_project, #log_up_to_date, #run_bundle_outdated

Constructor Details

#initialize(root_path = '', options = {}) ⇒ Command

Returns a new instance of Command.



14
15
16
17
18
19
20
# File 'lib/gemshine/command.rb', line 14

def initialize(root_path = '', options = {})
  @root_path = root_path
  @options = options

  self.destination_root = Dir.pwd
  @behavior = :invoke
end

Instance Attribute Details

#bundle_outdated_outputObject

Returns the value of attribute bundle_outdated_output.



12
13
14
# File 'lib/gemshine/command.rb', line 12

def bundle_outdated_output
  @bundle_outdated_output
end

#gemfile_pathObject

Returns the value of attribute gemfile_path.



12
13
14
# File 'lib/gemshine/command.rb', line 12

def gemfile_path
  @gemfile_path
end

#project_dirObject

Returns the value of attribute project_dir.



12
13
14
# File 'lib/gemshine/command.rb', line 12

def project_dir
  @project_dir
end

#project_nameObject

Returns the value of attribute project_name.



12
13
14
# File 'lib/gemshine/command.rb', line 12

def project_name
  @project_name
end

#projectsObject

Returns the value of attribute projects.



12
13
14
# File 'lib/gemshine/command.rb', line 12

def projects
  @projects
end

Instance Method Details

#pathObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gemshine/command.rb', line 22

def path
  ruby_project_directories.each do |project_dir|
    @project_dir = project_dir
    @project_name = File.basename(@project_dir)
    @gemfile_path = File.join(@project_dir, 'Gemfile')

    log_project

    unless File.exists?(@gemfile_path)
      log_missing
      next
    end

    @bundle_outdated_output = run_bundle_outdated

    if @bundle_outdated_output.match(/\b#{MSG_BUNDLE_UP_TO_DATE}\b/)
      log_up_to_date
      next
    end

    unless @bundle_outdated_output.match(/\b#{MSG_BUNDLE_OUTDATED}\b/)
      log_bundle_message @bundle_outdated_output
      next
    end

    gem_table valid_gem_list
  end
end

#versionObject



51
52
53
# File 'lib/gemshine/command.rb', line 51

def version
  puts "Gemshine version #{VERSION}"
end