Class: Pod::CodingArSource

Inherits:
Source
  • Object
show all
Defined in:
lib/coding_ar_source.rb

Instance Method Summary collapse

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_specsObject

Raises:

  • (Informative)


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

Returns:

  • (Boolean)


111
112
113
# File 'lib/coding_ar_source.rb', line 111

def git?
  false
end

#indexable?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/coding_ar_source.rb', line 115

def indexable?
  false
end

#nameObject



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_setsObject

Raises:

  • (Informative)


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

#podsObject

Raises:

  • (Informative)


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
# 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

  versions = list_version(query)
  if versions.class == Array and versions.length > 0
    set = set(query)
    set if set.specification_name == query
  end
end

#search_by_name(query, full_text_search = false) ⇒ Object

Raises:

  • (Informative)


80
81
82
# File 'lib/coding_ar_source.rb', line 80

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

Raises:

  • (ArgumentError)


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_dirObject



19
20
21
# File 'lib/coding_ar_source.rb', line 19

def specs_dir
  repo
end

#typeObject



15
16
17
# File 'lib/coding_ar_source.rb', line 15

def type
  'CODING-AR'
end

#update(_show_output) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/coding_ar_source.rb', line 84

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|
    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
  end
  UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output

  []
end

#updateable?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/coding_ar_source.rb', line 107

def updateable?
  true
end

#urlObject



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

Raises:

  • (ArgumentError)


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