Sha256: 31dbd7dc1edc0cc1a2a8e899e91944ec97144dde98acbf8684aeb21f86e15b3c

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

class Textmate::Source::Macromates < Textmate::Source::Base

  name 'Macromates'

  def bundles(search = '')
    repositories.map do |repository|
      repository_bundles(repository, search)
    end.flatten.uniq.sort
  end

  def install(bundle)
    repository = repositories.detect do |repository|
      repository_bundles(repository, bundle, :exact)
    end
    install_bundle_from_svn("#{repository}/#{bundle}.tmbundle", bundle)
  end

private ######################################################################

  def repositories
    repositories  = []
    repositories << 'http://svn.textmate.org/trunk/Bundles/'
    repositories << 'http://svn.textmate.org/trunk/Review/Bundles/'
  end

  def repository_bundles(repository, search = '', match = :partial)
    search_term = Regexp.new(".*#{search}.*", 'i')

    %x{ svn list #{repository} }.map do |bundle|
      bundle.split('.').first
    end.select do |bundle|
      match == :partial ? bundle =~ search_term : bundle == search
    end
  end

  def install_bundle_from_svn(svn_path, bundle)
    around_install(bundle) do
      %x{ svn co "#{svn_path}" "#{local_path_for(bundle)}" }
      puts "#{bundle} installed"
    end
  end

end

Textmate::Remote.register_source Textmate::Source::Macromates

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddollar-textmate-1.0.0 lib/textmate/source/macromates.rb
ddollar-textmate-1.0.1 lib/textmate/source/macromates.rb
ddollar-textmate-1.0.2 lib/textmate/source/macromates.rb
ddollar-textmate-1.0.3 lib/textmate/source/macromates.rb
ddollar-textmate-1.1.0 lib/textmate/source/macromates.rb
ddollar-textmate-1.2.0 lib/textmate/source/macromates.rb
ddollar-textmate-1.2.1 lib/textmate/source/macromates.rb