gemrage 0.4.0 → 0.4.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/gemrage.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gemrage}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Huckstep"]
@@ -48,9 +48,9 @@ class Gem::Commands::ScanCommand < Gem::Command
48
48
 
49
49
  def execute
50
50
  if dir = get_one_optional_argument
51
- notify(send_project_to_gemrage(project_scan(File.expand_path(dir))))
51
+ send_project_to_gemrage(project_scan(File.expand_path(dir)))
52
52
  else
53
- notify(send_system_to_gemrage(system_scan))
53
+ send_system_to_gemrage(system_scan)
54
54
  end
55
55
  end
56
56
 
@@ -69,26 +69,30 @@ private
69
69
  end
70
70
 
71
71
  def project_scan(dir)
72
- Dir[File.join(dir, '**', '{Gemfile}')].map do |gemfile|
73
- project_name = File.basename(File.dirname(gemfile))
74
- project_id = Digest::SHA1.hexdigest(File.dirname(gemfile))
72
+ h = {}
73
+ Dir[File.join(dir, '**', '{Gemfile,gemfile}')].each do |gemfile|
74
+ dir = File.dirname(gemfile)
75
+ notify("Trying to process a Gemfile found in #{dir}")
76
+ project_name = File.basename(dir)
77
+ project_id = Digest::SHA1.hexdigest(dir)
75
78
  lockfile = parse_lockfile("#{gemfile}.lock")
76
79
 
77
80
  begin
78
81
  d = Bundler::Definition.build(gemfile, nil, nil)
79
82
  deps = d.current_dependencies
80
- {
83
+ info = {
81
84
  :name => project_name,
82
- :identifier => project_id,
83
85
  :gems => Hash[*deps.map do |dep|
84
86
  [dep.name, lockfile[dep.name] || dep.requirement.to_s]
85
87
  end.flatten]
86
88
  }
89
+ git_url = find_git_url(dir) and info[:origin] = Digest::SHA1.hexdigest(git_url.split.last)
90
+ h[project_id] = info
87
91
  rescue Exception => boom
88
92
  # Maybe it's an old Gemfile
89
- nil
90
93
  end
91
- end.compact
94
+ end
95
+ h
92
96
  end
93
97
 
94
98
  def parse_lockfile(lockfile)
@@ -109,20 +113,20 @@ private
109
113
 
110
114
  def system_scan
111
115
  if windows? && pik?
112
- notify("Scanning with pik")
116
+ notify('Scanning with pik')
113
117
  pik_scan
114
118
  elsif !windows? && rvm? && !options[:force_basic]
115
119
  if :jruby == platform
116
- notify("You are using jRuby and have RVM. Oh boy...",
120
+ notify('You are using jRuby and have RVM. Oh boy...',
117
121
  "We'd like to make use of RVM, but using RVM from jRuby is...interesting.",
118
122
  "We'll just do a basic scan, and you can rescan using a non-jRuby VM if you want RVM support.")
119
123
  basic_scan
120
124
  else
121
- notify("Scanning with RVM...this might take a while")
125
+ notify('Scanning with RVM...this might take a while')
122
126
  rvm_scan
123
127
  end
124
128
  else
125
- notify("Scanning with basic gem support")
129
+ notify('Scanning with basic gem support')
126
130
  basic_scan
127
131
  end
128
132
  end
@@ -212,6 +216,17 @@ private
212
216
  Digest::SHA1.hexdigest(Mac.addr)
213
217
  end
214
218
 
219
+ def find_git_url(wd)
220
+ Dir.chdir(wd) do
221
+ config = '.git/config'
222
+ if File.exists?(config)
223
+ lines = File.readlines(config).map { |line| line.strip }.join("\n").split('[remote "origin"]').last.strip.split("\n").select { |line| line =~ /^url/ }.first
224
+ else
225
+ nil
226
+ end
227
+ end
228
+ end
229
+
215
230
  def parse_gem_list(stdout, plat = platform)
216
231
  h = {}
217
232
  stdout.split("\n").each do |line|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemrage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Huckstep