Class: Pod::CodingArSource
Instance Method Summary collapse
- #all_specs ⇒ Object
- #git? ⇒ Boolean
- #indexable? ⇒ Boolean
-
#initialize(repo) ⇒ CodingArSource
constructor
A new instance of CodingArSource.
- #name ⇒ Object
- #pod_path(name) ⇒ Object
- #pod_sets ⇒ Object
- #pods ⇒ Object
- #search(query) ⇒ Object
- #search_by_name(query, full_text_search = false) ⇒ Object
- #specification_path(name, version) ⇒ Object
- #specs_dir ⇒ Object
- #type ⇒ Object
- #update(_show_output) ⇒ Object
- #updateable? ⇒ Boolean
- #url ⇒ Object
- #versions(name) ⇒ Object
Constructor Details
#initialize(repo) ⇒ CodingArSource
Returns a new instance of CodingArSource.
3 4 5 |
# File 'lib/coding_ar_source.rb', line 3 def initialize(repo) super(repo) end |
Instance Method Details
#all_specs ⇒ Object
57 58 59 |
# File 'lib/coding_ar_source.rb', line 57 def all_specs raise Informative, "Can't retrieve all the specs for a CODING-AR-backed source." end |
#git? ⇒ Boolean
138 139 140 |
# File 'lib/coding_ar_source.rb', line 138 def git? false end |
#indexable? ⇒ Boolean
142 143 144 |
# File 'lib/coding_ar_source.rb', line 142 def indexable? false end |
#name ⇒ Object
7 8 9 |
# File 'lib/coding_ar_source.rb', line 7 def name repo.basename.to_s end |
#pod_path(name) ⇒ Object
23 24 25 |
# File 'lib/coding_ar_source.rb', line 23 def pod_path(name) specs_dir.join(name) end |
#pod_sets ⇒ Object
61 62 63 |
# File 'lib/coding_ar_source.rb', line 61 def pod_sets raise Informative, "Can't retrieve all the pod sets for a CODING-AR-backed source." end |
#pods ⇒ Object
27 28 29 |
# File 'lib/coding_ar_source.rb', line 27 def pods raise Informative, "Can't retrieve all the pods for a CODING-AR-backed source." end |
#search(query) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/coding_ar_source.rb', line 65 def search(query) unless specs_dir raise Informative, "Unable to find a source named: `#{name}`" end if query.is_a?(Dependency) query = query.root_name end begin versions = list_version(query) if versions.class == Array and versions.length > 0 set = set(query) set if set.specification_name == query end rescue RuntimeError => e if e..include?('not found') return nil else raise e end end end |
#search_by_name(query, full_text_search = false) ⇒ Object
88 89 90 |
# File 'lib/coding_ar_source.rb', line 88 def search_by_name(query, full_text_search = false) raise Informative, "Can't search a CODING-AR-backed source by name." end |
#specification_path(name, version) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/coding_ar_source.rb', line 40 def specification_path(name, version) raise ArgumentError, 'No name' unless name raise ArgumentError, 'No version' unless version unless versions(name).include?(Version.new(version)) raise StandardError, "Unable to find the specification #{name} " \ "(#{version}) in the #{self.name} source." end spec_url = "#{url}/Specs/#{name}/#{version.to_s}/#{name}.podspec.json" spec_path = File.join(specs_dir, name, version.to_s, "#{name}.podspec.json") FileUtils.mkdir_p File.dirname(spec_path) require 'coding_ar_util' CodingArUtil.download(spec_url, spec_path) spec_path end |
#specs_dir ⇒ Object
19 20 21 |
# File 'lib/coding_ar_source.rb', line 19 def specs_dir repo end |
#type ⇒ Object
15 16 17 |
# File 'lib/coding_ar_source.rb', line 15 def type 'CODING-AR' end |
#update(_show_output) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/coding_ar_source.rb', line 92 def update(_show_output) require 'json' require 'coding_ar_util' changed_spec_paths = [] UI.puts "Updating CODING-AR-backed repo #{name}".yellow if _show_output Pathname.glob(repo.join('**/*/*.json')).map do |f| begin origin_content = File.read(f) spec = JSON.parse origin_content spec_url = "#{url}/Specs/#{spec['name']}/#{spec['version']}/#{spec['name']}.podspec.json" UI.puts "- Fetch #{spec_url}" if _show_output FileUtils.mkdir_p File.dirname(f) CodingArUtil.download(spec_url, f) latest_content = File.read(f) FileUtils.rm_rf(File.dirname(f)) if latest_content.to_s.start_with?('Pod not found') JSON.parse latest_content changed_spec_paths.push(f) if origin_content != latest_content rescue RuntimeError => e if e..include?('Spec not found') UI.puts "- Skipping #{spec['name']} #{spec['version']}: Spec not found".yellow if _show_output next elsif e..include?('URL using bad/illegal format') || e..include?('missing URL') UI.puts "- Skipping #{spec['name']} #{spec['version']}: Invalid URL format".yellow if _show_output next else UI.puts "- Skipping #{spec['name']} #{spec['version']}: #{e.}".yellow if _show_output next end rescue JSON::ParserError => e UI.puts "- Skipping #{f}: Invalid JSON format".yellow if _show_output next rescue => e UI.puts "- Skipping #{f}: #{e.}".yellow if _show_output next end end UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output [] end |
#updateable? ⇒ Boolean
134 135 136 |
# File 'lib/coding_ar_source.rb', line 134 def updateable? true end |
#url ⇒ Object
11 12 13 |
# File 'lib/coding_ar_source.rb', line 11 def url @url ||= File.read(repo.join('.coding_ar_url')).chomp.chomp('/') end |
#versions(name) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/coding_ar_source.rb', line 31 def versions(name) eturn nil unless specs_dir raise ArgumentError, 'No name' unless name list_version(name).map do |v| Version.new(v) end.compact.sort.reverse end |