lib/eac_launcher/instances/base.rb in eac_launcher-0.2.0 vs lib/eac_launcher/instances/base.rb in eac_launcher-0.2.1
- old
+ new
@@ -1,46 +1,44 @@
require_relative 'base/cache'
module EacLauncher
module Instances
- class Base < ::EacLauncher::Path
- include ::Eac::SimpleCache
- include ::EacRubyUtils::Console::Speaker
- include ::EacLauncher::Instances::Base::Cache
+ module Base
+ class << self
+ def extend_object(object)
+ object.extend ::Eac::SimpleCache
+ object.extend ::EacRubyUtils::Console::Speaker
+ object.extend ::EacLauncher::Instances::Base::Cache
+ super
+ end
- attr_reader :parent
-
- def initialize(path, parent)
- super(path)
- @parent = parent
+ def instanciate(path, context, parent)
+ unless path.is_a?(::EacLauncher::Instances::Base)
+ raise "#{path} is not a project" unless path.project?
+ path.extend(::EacLauncher::Instances::Base)
+ path.context = context
+ path.parent = parent
+ end
+ path
+ end
end
+ attr_accessor :context, :parent
+
def name
- to_root_path
+ logical
end
- def stereotypes_uncached
- EacLauncher::Stereotype.stereotypes.select { |s| s.match?(self) }
- end
-
def stereotype?(stereotype)
stereotypes.include?(stereotype)
end
- def children
- scan(self)
- end
-
def to_parent_path
return self unless @parent
- gsub(/\A#{Regexp.quote(@parent)}/, '')
+ logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
end
- def to_root_path
- gsub(/\A#{root}/, '')
- end
-
def project?
stereotypes.any?
end
def publish_run
@@ -58,18 +56,15 @@
"#{s.publish_class.new(self).check}"
end
end
def project_name
- File.basename(self)
+ ::File.basename(logical)
end
- def current_cache
- stereotypes.each do |s|
- return s.warp_class.new(self) if s.warp_class
- end
- self
+ def included?
+ !::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
end
private
def publish?(stereotype)
@@ -78,36 +73,9 @@
filter.blank? ? true : filter == stereotype.name.demodulize
end
def options_uncached
::EacLauncher::Context.current.settings.instance_settings(self)
- end
-
- def root_uncached
- return self unless @parent
- @parent.root
- end
-
- def scan(path)
- r = []
- scan_subdirectories(path) do |sp|
- c = self.class.new(sp, self)
- if c.stereotypes.any?
- r << c
- else
- r += scan(sp)
- end
- end
- r
- end
-
- def scan_subdirectories(path)
- Dir.entries(path).each do |basename|
- next if %w[. ..].include?(basename)
- sp = path.subpath(basename)
- next unless File.directory?(sp)
- yield(sp)
- end
end
end
end
end