Sha256: 9822af5ba522b90c09fdd86527936d8c81c35bbc3cf4ee70b7201e1f662411a8

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

module Space
  module Models
    class Project
      include Events

      autoload :Bundler, 'space/models/project/bundler'

      attr_reader :name, :repos, :bundler, :config

      def initialize(name)
        @name    = name
        @config  = Config.load(name)
        @repos   = Repos.new(self, config.paths)
        @bundler = Bundler.new(self)
      end

      def local_repos
        bundler.config.keys.map do |key|
          key =~ /^local\.(.+)$/
          $1 if repos.names.include?($1)
        end.compact
      end

      def names
        @names ||= Tmux.windows || repos.names
      end

      def number(name)
        if number = names.index(name)
          number + 1
        else
          names << name
          number(name)
        end
      end

      def refresh
        bundler.refresh
        repos.all.each(&:refresh)
      end

      def subscribe(*args)
        super
        [bundler, repos].each { |object| object.subscribe(self) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
space-0.0.5 lib/space/models/project.rb
space-0.0.4 lib/space/models/project.rb