Class: Pod::NexusSource

Inherits:
Source
  • Object
show all
Defined in:
lib/cocoapods-nexus/nexus_source.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo, url) ⇒ NexusSource

Returns a new instance of NexusSource.



7
8
9
10
# File 'lib/cocoapods-nexus/nexus_source.rb', line 7

def initialize(repo, url)
  @source_url = url
  super(repo)
end

Instance Method Details

#git?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cocoapods-nexus/nexus_source.rb', line 21

def git?
  false
end

#search(query) ⇒ Object

从nexus查询依赖

Parameters:

  • query (Object)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cocoapods-nexus/nexus_source.rb', line 31

def search(query)
  unless File.exist?("#{repo}/.nexus")
    raise Informative, "Unable to find a source named: `#{name}`"
  end

  found = find_local_podspec(query)
  # 本地没查询到,则从nexus服务查询
  if found == []
    # 暂时这样处理
    spec_version = query.requirement.requirements.last.last.to_s
    artifacte = nexus_find_artifacte(spec_name: query.root_name, spec_version: spec_version)
    if artifacte
      download_url = parse_artifacte_asset_url(artifacte, 'podspec')
      if download_url
        target_path = "#{@repo}/#{query.root_name}/#{spec_version}"
        downloader = Pod::Downloader::NexusHttp.new(target_path, download_url, {:type => 'podspec', :name => query.root_name})
        downloader.download

        found = find_local_podspec(query)
      end
    end
  end

  if found == [query.root_name]
    set = set(query.root_name)
    set if set.specification_name == query.root_name
  end
end

#specification(name, version) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods-nexus/nexus_source.rb', line 60

def specification(name, version)
  specification = super
  version = version.version if version.is_a?(Pod::Version)
  artifacte = nexus_find_artifacte(spec_name: name, spec_version: version)
  download_url = parse_artifacte_asset_url(artifacte, 'zip')
  if download_url
    specification.attributes_hash['source'] = {
        'http' => download_url
    }
    specification.attributes_hash['vendored_frameworks'] = "#{name}.framework"
  end
  specification
end

#typeObject



25
26
27
# File 'lib/cocoapods-nexus/nexus_source.rb', line 25

def type
  'nexus'
end

#urlObject



12
13
14
15
16
17
18
19
# File 'lib/cocoapods-nexus/nexus_source.rb', line 12

def url
  if @source_url
    @source_url.to_s
  else
    # after super(repo) repo is now the path to the repo
    File.read("#{repo}/.nexus") if File.exist?("#{repo}/.nexus")
  end
end