Class: OffGithub::GemInvestigator
- Inherits:
-
Object
- Object
- OffGithub::GemInvestigator
- Defined in:
- lib/off_github.rb
Instance Method Summary collapse
- #found_matches ⇒ Object
- #github_suspects ⇒ Object
-
#initialize(local = GemList.new, other = GemList.new(GEMCUTTER_URL), github = GemList.new(GITHUB_URL)) ⇒ GemInvestigator
constructor
A new instance of GemInvestigator.
- #relations ⇒ Object
- #stats ⇒ Object (also: #to_s)
- #will_be_migrated ⇒ Object
- #will_be_migrated_with_versions ⇒ Object
- #will_not_be_migrated ⇒ Object
Constructor Details
#initialize(local = GemList.new, other = GemList.new(GEMCUTTER_URL), github = GemList.new(GITHUB_URL)) ⇒ GemInvestigator
Returns a new instance of GemInvestigator.
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/off_github.rb', line 68 def initialize( local = GemList.new, other = GemList.new(GEMCUTTER_URL), github = GemList.new(GITHUB_URL)) @github = github.list @github_gems = github.gems @github_url = github.source @other = other.list @other_gems = other.gems @other_url = other.source @local = local.list @local_gems = local.gems end |
Instance Method Details
#found_matches ⇒ Object
85 86 87 |
# File 'lib/off_github.rb', line 85 def found_matches @found_matches ||= github_suspects.map{|name| find_match(name)} end |
#github_suspects ⇒ Object
81 82 83 |
# File 'lib/off_github.rb', line 81 def github_suspects @github_suspects ||= @local.select{|name| looks_like_github_gem?(name)} end |
#relations ⇒ Object
89 90 91 |
# File 'lib/off_github.rb', line 89 def relations @relations ||= Hash[*github_suspects.map.zip(found_matches).flatten] end |
#stats ⇒ Object Also known as: to_s
129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/off_github.rb', line 129 def stats <<-STATS #{Hirb::Helpers::AutoTable.render will_be_migrated_with_versions, :headers => [GITHUB_URL, GEMCUTTER_URL, "action"]} reinstall: Will reinstall from gemcutter. uninstall: Non-github gem already installed. Will remove github gem. skip: Gemcutter version is older. Will not do anything. Couldn't find these gems on Gemcutter: #{will_not_be_migrated.join("\n")} STATS end |
#will_be_migrated ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/off_github.rb', line 93 def will_be_migrated return @will_be_migrated if @will_be_migrated targets = relations.select{|k, v| v} @will_be_migrated = targets.map do |names| gh_name, gc_name = names local_gh_versions = @local_gems[gh_name] local_gc_versions = @local_gems[gc_name] gh_versions = @github_gems[gh_name] gc_versions = @other_gems[gc_name] action = if @local.include?(gc_name) && !newer_version?(local_gh_versions.first, gc_versions.first) "uninstall" elsif !newer_version?(gc_versions.first, local_gh_versions.first) "skip" else "reinstall" end [gh_name, gc_name, action] end.sort{|a,b| a[2] <=> b[2]} end |
#will_be_migrated_with_versions ⇒ Object
116 117 118 119 120 121 122 123 |
# File 'lib/off_github.rb', line 116 def will_be_migrated_with_versions @will_be_migrated_with_versions ||= will_be_migrated.map do |rows| gh_name, gc_name, action = rows [gh_name + " (#{@local_gems[gh_name].join(', ')})", gc_name + " (#{@other_gems[gc_name].join(', ')})", action] end end |
#will_not_be_migrated ⇒ Object
125 126 127 |
# File 'lib/off_github.rb', line 125 def will_not_be_migrated @will_not_be_migrated ||= Hash[*relations.select{|k, v| !v}.flatten].keys end |