class BubbleWrap::Requirement

Attributes

paths[RW]
file[RW]
file_dependencies[W]
root[RW]

Public Class Methods

clear!() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 75
def clear!
  paths.select! { |k,v| v.relative == 'motion/shortcut.rb' }
end
file(relative) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 65
def file(relative)
  paths.fetch(relative)
end
files(app_files=nil) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 69
def files(app_files=nil)
  files = paths.values.map(&:to_s)
  files += app_files if app_files
  files.uniq
end
files_dependencies() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 79
def files_dependencies
  deps = {}
  paths.each_value do |file|
    deps.merge! file.dependencies
  end
  deps
end
frameworks(app_frameworks=nil) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 87
def frameworks(app_frameworks=nil)
  frameworks = ['Foundation', 'CoreGraphics'] +
    paths.values.map(&:frameworks)
  frameworks += app_frameworks if app_frameworks
  frameworks.flatten.compact.sort.uniq
end
new(file,root) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 11
def initialize(file,root)
  self.file = file
  self.root = root
end
scan(caller_location, file_spec, &block) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 54
def scan(caller_location, file_spec, &block)
  root = convert_caller_to_root_path caller_location
  self.paths ||= {}
  Dir.glob(File.expand_path(file_spec, root)).each do |file|
    p = new(file,root)
    self.paths[p.relative] = p
    p.depends_on('motion/shortcut.rb') unless p.relative == 'motion/shortcut.rb'
  end
  self.class_eval(&block) if block
end

Public Instance Methods

dependencies() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 33
def dependencies
  return {} if file_dependencies.empty?
  { file => file_dependencies.map(&:to_s) }
end
depends_on(file_or_paths) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 20
def depends_on(file_or_paths)
  paths = file_or_paths.respond_to?(:each) ? file_or_paths : [ file_or_paths ]
  self.file_dependencies += paths.map do |f|
    f = self.class.file(f) unless f.is_a? Requirement
    f unless f.file == file
  end.compact
  self.file_dependencies.uniq!(&:to_s)
end
file_dependencies() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 42
def file_dependencies
  @file_dependencies ||= []
end
frameworks() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 46
def frameworks
  @frameworks ||= []
end
relative() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 16
def relative
  convert_to_relative(file, root)
end
to_s() click to toggle source
# File lib/bubble-wrap/requirement.rb, line 38
def to_s
  file
end
uses_framework(framework_name) click to toggle source
# File lib/bubble-wrap/requirement.rb, line 29
def uses_framework(framework_name)
  self.frameworks << framework_name
end