Methods
Attributes
[RW] quiet
Public Class methods
new(urls_to_fetch, level = 1, cwd = ".")
     # File railties/lib/commands/plugin.rb, line 903
903:   def initialize(urls_to_fetch, level = 1, cwd = ".")
904:     @level = level
905:     @cwd = cwd
906:     @urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
907:     @quiet = false
908:   end
Public Instance methods
download(link)
     # File railties/lib/commands/plugin.rb, line 942
942:   def download(link)
943:     puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet
944:     open(link) do |stream|
945:       File.open(File.join(@cwd, File.basename(link)), "wb") do |file|
946:         file.write(stream.read)
947:       end
948:     end
949:   end
fetch(links = @urls_to_fetch)
     # File railties/lib/commands/plugin.rb, line 951
951:   def fetch(links = @urls_to_fetch)
952:     links.each do |l|
953:       (l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l)
954:     end
955:   end
fetch_dir(url)
     # File railties/lib/commands/plugin.rb, line 957
957:   def fetch_dir(url)
958:     @level += 1
959:     push_d(File.basename(url)) if @level > 0
960:     open(url) do |stream|
961:       contents =  stream.read
962:       fetch(links(url, contents))
963:     end
964:     pop_d if @level > 0
965:     @level -= 1
966:   end
links(base_url, contents)
     # File railties/lib/commands/plugin.rb, line 931
931:   def links(base_url, contents)
932:     links = []
933:     contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link|
934:       link = link.sub(/href="/i, "")
935:       next if link =~ /svnindex.xsl$/
936:       next if link =~ /^(\w*:|)\/\// || link =~ /^\./
937:       links << File.join(base_url, link)
938:     end
939:     links
940:   end
ls()
     # File railties/lib/commands/plugin.rb, line 910
910:   def ls
911:     @urls_to_fetch.collect do |url|
912:       if url =~ /^svn(\+ssh)?:\/\/.*/
913:         `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil
914:       else
915:         open(url) do |stream|
916:           links("", stream.read)
917:         end rescue nil
918:       end
919:     end.flatten
920:   end
pop_d()
     # File railties/lib/commands/plugin.rb, line 927
927:   def pop_d
928:     @cwd = File.dirname(@cwd)
929:   end
push_d(dir)
     # File railties/lib/commands/plugin.rb, line 922
922:   def push_d(dir)
923:     @cwd = File.join(@cwd, dir)
924:     FileUtils.mkdir_p(@cwd)
925:   end