class Project

Attributes

root[RW]

Public Class Methods

new(root) click to toggle source
# File lib/soundcheck/project.rb, line 10
def initialize(root)
  self.root = root
end

Public Instance Methods

execute(command) click to toggle source
# File lib/soundcheck/project.rb, line 63
def execute(command)
  logger.debug "Executing #{command}"
  Dir.chdir(root) do
    output = `#{command}`
    [output, $?]
  end
end
file_contents(filename) click to toggle source
# File lib/soundcheck/project.rb, line 30
def file_contents(filename)
  File.read(File.expand_path(File.join(root, filename)))
end
frameworks() click to toggle source
# File lib/soundcheck/project.rb, line 53
def frameworks
  detected_frameworks = language.frameworks.map do |framework_class|
    framework_class.new(self)
  end
  logger.debug "Detected your frameworks: #{detected_frameworks}"

  raise UnknownFramework if detected_frameworks.empty?
  return detected_frameworks
end
has_dir?(dirname) click to toggle source
# File lib/soundcheck/project.rb, line 14
def has_dir?(dirname)
  Dir.chdir(root) do
    Dir.exist?(dirname)
  end
end
has_file?(filename) click to toggle source
# File lib/soundcheck/project.rb, line 20
def has_file?(filename)
  Dir.chdir(root) do
    not Dir.glob(filename).empty?
  end
end
has_files?(*paths) click to toggle source
# File lib/soundcheck/project.rb, line 26
def has_files?(*paths)
  paths.any? { |path| has_file?(path) }
end
language() click to toggle source
# File lib/soundcheck/project.rb, line 34
def language
  case
  when has_file?("Gemfile")
    logger.debug "You have a Gemfile, so I think this is Ruby."
    return Languages::Ruby.new(self) 
  when has_file?("Rakefile")
    logger.debug "You have a Rakefile, so I think this is Ruby."
    return Languages::Ruby.new(self) 
  when has_file?("*.gemspec")
    logger.debug "You have a gemspec, so I think this is Ruby."
    return Languages::Ruby.new(self) 
  when has_file?("package.json")
    logger.debug "You have a package.json, so I think this is NodeJS."
    return Languages::NodeJS.new(self) 
  else
    raise UnknownLanguage
  end
end