Class: Pod::RsyncSource
- Inherits:
-
Source
- Object
- Source
- Pod::RsyncSource
- Defined in:
- lib/rsync_source.rb
Overview
Subclass of Pod::Source to provide support for RSYNC Specs repositories
Class Method Summary collapse
Instance Method Summary collapse
- #argv ⇒ Object
- #argv=(argv) ⇒ Object
- #parse_config ⇒ Object
- #save_config ⇒ Object
- #url ⇒ Object
- #url=(url) ⇒ Object
Class Method Details
.rsync_repo?(dir) ⇒ Boolean
35 36 37 |
# File 'lib/rsync_source.rb', line 35 def self.rsync_repo?(dir) (dir+".rsync_config").exist? end |
.rsync_source_by_url(url) ⇒ Object
51 52 53 54 55 |
# File 'lib/rsync_source.rb', line 51 def self.rsync_source_by_url(url) rsync_sources.find do |source| source.url == url end end |
.rsync_sources ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rsync_source.rb', line 39 def self.rsync_sources if Pod::Config.instance.repos_dir.exist? dirs = Pod::Config.instance.repos_dir.children.select(&:directory?) dirs = dirs.select do |dir| RsyncSource.rsync_repo?(dir) end dirs.map { |dir| RsyncSource.new(dir) } else [] end end |
Instance Method Details
#argv ⇒ Object
26 27 28 29 |
# File 'lib/rsync_source.rb', line 26 def argv parse_config unless @argv @argv end |
#argv=(argv) ⇒ Object
31 32 33 |
# File 'lib/rsync_source.rb', line 31 def argv=(argv) @argv = argv end |
#parse_config ⇒ Object
5 6 7 8 9 |
# File 'lib/rsync_source.rb', line 5 def parse_config @url, @argv = File.open(repo + '.rsync_config', "r:UTF-8", &:read).split("\n").map { |c| c.strip } @url + "/" unless @url.end_with?("/") @argv ||= "" unless @argv end |
#save_config ⇒ Object
11 12 13 14 15 |
# File 'lib/rsync_source.rb', line 11 def save_config File.open(repo+".rsync_config", "w:UTF-8") do |f| f.write "#{@url}\n#{@argv}" end end |
#url ⇒ Object
17 18 19 20 |
# File 'lib/rsync_source.rb', line 17 def url parse_config unless @url @url end |
#url=(url) ⇒ Object
22 23 24 |
# File 'lib/rsync_source.rb', line 22 def url=(url) @url = url end |