Parent

Included Modules

Class/Module Index [+]

Quicksearch

Repositories

Public Class Methods

each(&block) click to toggle source
# File lib/commands/plugin.rb, line 397
def self.each(&block)
  self.instance.each(&block)
end
instance() click to toggle source
# File lib/commands/plugin.rb, line 393
def self.instance
  @instance ||= Repositories.new
end
new(cache_file = File.join(find_home, ".rails-plugin-sources")) click to toggle source
# File lib/commands/plugin.rb, line 316
def initialize(cache_file = File.join(find_home, ".rails-plugin-sources"))
  @cache_file = File.expand_path(cache_file)
  load!
end

Public Instance Methods

add(uri) click to toggle source
# File lib/commands/plugin.rb, line 325
def add(uri)
  unless find{|repo| repo.uri == uri }
    @repositories.push(Repository.new(uri)).last
  end
end
all() click to toggle source
# File lib/commands/plugin.rb, line 339
def all
  @repositories
end
defaults() click to toggle source
# File lib/commands/plugin.rb, line 369
def defaults
      http://dev.rubyonrails.com/svn/rails/plugins/
end
each(&block) click to toggle source
# File lib/commands/plugin.rb, line 321
def each(&block)
  @repositories.each(&block)
end
exist?(uri) click to toggle source
# File lib/commands/plugin.rb, line 335
def exist?(uri)
  @repositories.detect{|repo| repo.uri == uri }
end
find_home() click to toggle source
# File lib/commands/plugin.rb, line 375
def find_home
  ['HOME', 'USERPROFILE'].each do |homekey|
    return ENV[homekey] if ENV[homekey]
  end
  if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
    return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
  end
  begin
    File.expand_path("~")
  rescue StandardError => ex
    if File::ALT_SEPARATOR
      "C:/"
    else
      "/"
    end
  end
end
find_plugin(name) click to toggle source
# File lib/commands/plugin.rb, line 343
def find_plugin(name)
  @repositories.each do |repo|
    repo.each do |plugin|
      return plugin if plugin.name == name
    end
  end
  return nil
end
load!() click to toggle source
# File lib/commands/plugin.rb, line 352
def load!
  contents = File.exist?(@cache_file) ? File.read(@cache_file) : defaults
  contents = defaults if contents.empty?
  @repositories = contents.split(/\n/).reject do |line|
    line =~ /^\s*#/ or line =~ /^\s*$/
  end.map { |source| Repository.new(source.strip) }
end
remove(uri) click to toggle source
# File lib/commands/plugin.rb, line 331
def remove(uri)
  @repositories.reject!{|repo| repo.uri == uri}
end
save() click to toggle source
# File lib/commands/plugin.rb, line 360
def save
  File.open(@cache_file, 'w') do |f|
    each do |repo|
      f.write(repo.uri)
      f.write("\n")
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.