cocoapods-src 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c70123a60f4b9bd3369aa251d178d10147ae3fc
4
- data.tar.gz: 48d9e520b82b5db0040a94b5b46b4247f4ae21ab
3
+ metadata.gz: 606aa66d7ec25f54fee7a80be667a09629003164
4
+ data.tar.gz: 81fa9597f7eb9a03d5f5fa8ad39c495ac34b319d
5
5
  SHA512:
6
- metadata.gz: 79d5c95fba8d328bb49e255dce4c05445570ee03e5e650cd464703f90c9cb343a4502eb3fd57801c6f36fde86059552c27af87250232fa921de141a26879d69a
7
- data.tar.gz: 4703eb9075e206d5ddd9f6fcf63915855d09b471abbe2d35046891acc226cfee9cb81d010697440b087ef3f515d08dfa23b539bdb880428420103dcb684dd049
6
+ metadata.gz: 0c56c670ea4b72949604c07bb458f6e13e3ba235cc9a0883b67b7be3bb4d75e7c664e6cb627f9052c745c9cdc713a801e85452a1ff12fb00576bda6186224593
7
+ data.tar.gz: 67379581d5bf2092cdedcfbf081c6d163f7e70e3b5ad533643c76b1496e6f3bc2958c376f4799b1b903f8da44f17611690a1f22dd953087d078d05684bbeeb35
data/README.md CHANGED
@@ -18,6 +18,14 @@ $ pod install
18
18
 
19
19
  After `pod install`, automatically `git clone POD_SOURCE ~/.cocoapods/src/POD_NAME` will be run.
20
20
 
21
+ ### ghq
22
+
23
+ You can download sources using `ghq` command ([motemen/ghq](https://github.com/motemen/ghq)) instead of `git clone`. If you like to do it, add `~/.podrc`, `~/.cocoapods/.podrc`, or `./.podrc`, and add a configuration like this.
24
+
25
+ ```yaml
26
+ cocoapods-src_use_ghq: true
27
+ ```
28
+
21
29
  ## Contribution
22
30
 
23
31
  1. Fork
@@ -1 +1,4 @@
1
+ require "pod"
2
+ require "pod/rc"
3
+ require "pod/src/downloader"
1
4
  require "pod/hook/post_install"
@@ -1,3 +1,3 @@
1
1
  module CocoapodsSrc
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,20 @@
1
+ module Pod
2
+ def self.rc
3
+ return @rc if not @rc.nil?
4
+
5
+ rc_paths.each do |rc_path|
6
+ if File.exist?(rc_path)
7
+ @rc = Rc.new(rc_path)
8
+ break
9
+ end
10
+ end
11
+
12
+ @rc
13
+ end
14
+
15
+ private
16
+
17
+ def self.rc_paths
18
+ ["#{Dir.home}/.podrc", "#{Dir.home}/.cocoapods/.podrc", "#{Dir.pwd}/.podrc"]
19
+ end
20
+ end
@@ -1,16 +1,3 @@
1
- require "cocoapods-downloader"
2
-
3
1
  Pod::HooksManager.register(:post_install) do |installer_context|
4
- target_dir = Pathname.new("#{Dir.home}/.cocoapods/src")
5
-
6
- specs = installer_context.umbrella_targets.map(&:specs).flatten.uniq
7
- specs.each do |spec|
8
- next if spec.source.nil? || spec.source[:git].nil?
9
-
10
- target_path = target_dir.join(spec.name)
11
- next if target_path.exist?
12
-
13
- source_url = spec.source[:git]
14
- Pod::Downloader.for_target(target_path, git: source_url).download
15
- end
2
+ Pod::Src::Downloader.new(installer_context).download
16
3
  end
@@ -0,0 +1,17 @@
1
+ require "yaml"
2
+
3
+ module Pod
4
+ class Rc
5
+ def initialize(path)
6
+ begin
7
+ @config = YAML.load_file(path) || {}
8
+ rescue
9
+ @config = {}
10
+ end
11
+ end
12
+
13
+ def [](key)
14
+ @config[key]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ require "cocoapods-downloader"
2
+
3
+ module Pod
4
+ module Src
5
+ class Downloader
6
+ def initialize(context)
7
+ @context = context
8
+ end
9
+
10
+ def download
11
+ specs.each do |spec|
12
+ next if spec.source.nil? || spec.source[:git].nil?
13
+
14
+ source_url = spec.source[:git]
15
+
16
+ if use_ghq?
17
+ download_by_ghq(source_url)
18
+ else
19
+ target_path = target_dir.join(spec.name)
20
+ next if target_path.exist?
21
+ download_by_pod_downloader(target_path, source_url)
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def specs
29
+ @specs ||= @context.umbrella_targets.map(&:specs).flatten.uniq
30
+ end
31
+
32
+ def target_dir
33
+ Pathname.new("#{Dir.home}/.cocoapods/src")
34
+ end
35
+
36
+ def use_ghq?
37
+ !Pod.rc.nil? && Pod.rc["cocoapods-src_use_ghq"]
38
+ end
39
+
40
+ def download_by_ghq(source_url)
41
+ system "ghq", "get", source_url
42
+ end
43
+
44
+ def download_by_pod_downloader(target_path, source_url)
45
+ Pod::Downloader.for_target(target_path, git: source_url).download
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-src
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoto Kaneko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,7 +53,10 @@ files:
53
53
  - cocoapods_src.gemspec
54
54
  - lib/cocoapods_plugin.rb
55
55
  - lib/cocoapods_src.rb
56
+ - lib/pod.rb
56
57
  - lib/pod/hook/post_install.rb
58
+ - lib/pod/rc.rb
59
+ - lib/pod/src/downloader.rb
57
60
  homepage: https://github.com/naoty/cocoapods-src
58
61
  licenses:
59
62
  - MIT