Module: Lapidist

Defined in:
lib/lapidist.rb,
lib/lapidist/version.rb,
lib/lapidist/cli/command.rb

Defined Under Namespace

Modules: Cli Classes: Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.gem_deps(path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lapidist.rb', line 17

def self.gem_deps(path)
	gems = self.gems(path)
	@gem_deps ||= gems.map { |g|
		begin
			gemspec_path = File.join(path, g, "#{g}.gemspec")
  		deps = File.open(File.join(path, g, "#{g}.gemspec"), 'r:UTF-8').each_line.map { |line|
  		 	line.match(/add_(development_|runtime_)?dependency\s+.([\w_-]+)/)
  		}.compact.map { |m| m[2]}.keep_if { |d| gems.include?(d) }.uniq
		rescue Errno::ENOENT => e
    	puts "[!] gemspec #{gemspec_path} not found for #{g} gem"
    end

		[g, deps]
	}.to_h
end

.gem_tests(path) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/lapidist.rb', line 33

def self.gem_tests(path)
	# https://stackoverflow.com/q/28655221/902217
	@gem_tests ||= self.gem_deps(path).inject(Hash.new([])) { |memo, (key, values)|
  values.each { |value| memo[value] += [key] }
  memo
}
end

.gems(path) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/lapidist.rb', line 7

def self.gems(path)
  if File.exist?(path)
    @gems ||= Pathname.new(path).children.select { |child|
      child.directory? && (child + ".git").directory? && !child.glob("*.gemspec").empty?
    }.map { |e| File.basename(e) }
  else
    raise "#{gitmodules_path} not found make sure that -p/--gems-path correctly specified"
  end
end