Module: Lowendinsight::ProjectType

Defined in:
lib/lowendinsight/project_type.rb

Class Method Summary collapse

Class Method Details

.determine_project_type_from_repo(url) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lowendinsight/project_type.rb', line 4

def self.determine_project_type_from_repo(url)
  @url = url
  paths = URI(@url).path.split("/")
  @name = paths[(paths.size)-1]
  g = Git.clone(@url, @name, :path => '/tmp/checkout')

  if package?
    h = {"type" => "package"}
  elsif pom?
    h = {"type" => "pom"}
  elsif gemfile?
    h = {"type" => "gemfile"}
  elsif gemspec?
    h = {"type" => "gemspec"}
  else
    h = {"type" => "unknown"}
  end

  FileUtils.rm_rf("/tmp/checkout/#{@name}")

  return h

end

.gemfile?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/lowendinsight/project_type.rb', line 36

def self.gemfile?
  if File.exist?("/tmp/checkout/#{@name}/Gemfile")
    h = Lowendinsight::GemfileDependencies.get_dependencies_from_file Bundler.read_file("/tmp/checkout/#{@name}/Gemfile")
    if h[0]["message"] == "no dependencies defined in Gemfile, perhaps gemspec"
      return false
    else
      return true
    end
  else
    return false
  end
end

.gemspec?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
# File 'lib/lowendinsight/project_type.rb', line 49

def self.gemspec?
  if File.exist?("/tmp/checkout/#{@name}/Gemfile")
    h = Lowendinsight::GemfileDependencies.get_dependencies_from_file Bundler.read_file("/tmp/checkout/#{@name}/Gemfile")
    if h[0]["message"] == "no dependencies defined in Gemfile, perhaps gemspec"
      return true if File.exist?("/tmp/checkout/#{@name}/#{@name}.gemspec")
    end
  elsif File.exist?("/tmp/checkout/#{@name}/#{@name}.gemspec")
    return true
  end
end

.package?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/lowendinsight/project_type.rb', line 32

def self.package?
  File.exist?("/tmp/checkout/#{@name}/package.json")
end

.pom?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/lowendinsight/project_type.rb', line 28

def self.pom?
  File.exist?("/tmp/checkout/#{@name}/pom.xml")
end