cocoapods-square-stable 0.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1296 -0
  3. data/LICENSE +20 -0
  4. data/README.md +94 -0
  5. data/bin/pod +16 -0
  6. data/bin/sandbox-pod +120 -0
  7. data/lib/cocoapods.rb +77 -0
  8. data/lib/cocoapods/command.rb +116 -0
  9. data/lib/cocoapods/command/help.rb +23 -0
  10. data/lib/cocoapods/command/inter_process_communication.rb +178 -0
  11. data/lib/cocoapods/command/list.rb +77 -0
  12. data/lib/cocoapods/command/outdated.rb +56 -0
  13. data/lib/cocoapods/command/podfile_info.rb +91 -0
  14. data/lib/cocoapods/command/project.rb +88 -0
  15. data/lib/cocoapods/command/push.rb +172 -0
  16. data/lib/cocoapods/command/repo.rb +145 -0
  17. data/lib/cocoapods/command/search.rb +61 -0
  18. data/lib/cocoapods/command/setup.rb +134 -0
  19. data/lib/cocoapods/command/spec.rb +590 -0
  20. data/lib/cocoapods/config.rb +231 -0
  21. data/lib/cocoapods/downloader.rb +59 -0
  22. data/lib/cocoapods/executable.rb +118 -0
  23. data/lib/cocoapods/external_sources.rb +363 -0
  24. data/lib/cocoapods/file_list.rb +36 -0
  25. data/lib/cocoapods/gem_version.rb +7 -0
  26. data/lib/cocoapods/generator/acknowledgements.rb +107 -0
  27. data/lib/cocoapods/generator/acknowledgements/markdown.rb +40 -0
  28. data/lib/cocoapods/generator/acknowledgements/plist.rb +64 -0
  29. data/lib/cocoapods/generator/bridge_support.rb +22 -0
  30. data/lib/cocoapods/generator/copy_resources_script.rb +54 -0
  31. data/lib/cocoapods/generator/dummy_source.rb +22 -0
  32. data/lib/cocoapods/generator/prefix_header.rb +82 -0
  33. data/lib/cocoapods/generator/target_environment_header.rb +86 -0
  34. data/lib/cocoapods/generator/xcconfig.rb +185 -0
  35. data/lib/cocoapods/hooks/installer_representation.rb +134 -0
  36. data/lib/cocoapods/hooks/library_representation.rb +94 -0
  37. data/lib/cocoapods/hooks/pod_representation.rb +74 -0
  38. data/lib/cocoapods/installer.rb +571 -0
  39. data/lib/cocoapods/installer/analyzer.rb +559 -0
  40. data/lib/cocoapods/installer/analyzer/sandbox_analyzer.rb +253 -0
  41. data/lib/cocoapods/installer/file_references_installer.rb +179 -0
  42. data/lib/cocoapods/installer/pod_source_installer.rb +248 -0
  43. data/lib/cocoapods/installer/target_installer.rb +379 -0
  44. data/lib/cocoapods/installer/user_project_integrator.rb +180 -0
  45. data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +224 -0
  46. data/lib/cocoapods/library.rb +202 -0
  47. data/lib/cocoapods/open_uri.rb +24 -0
  48. data/lib/cocoapods/project.rb +209 -0
  49. data/lib/cocoapods/resolver.rb +212 -0
  50. data/lib/cocoapods/sandbox.rb +343 -0
  51. data/lib/cocoapods/sandbox/file_accessor.rb +217 -0
  52. data/lib/cocoapods/sandbox/headers_store.rb +96 -0
  53. data/lib/cocoapods/sandbox/path_list.rb +208 -0
  54. data/lib/cocoapods/sources_manager.rb +276 -0
  55. data/lib/cocoapods/user_interface.rb +304 -0
  56. data/lib/cocoapods/user_interface/error_report.rb +101 -0
  57. data/lib/cocoapods/validator.rb +350 -0
  58. metadata +238 -0
@@ -0,0 +1,172 @@
1
+ require 'fileutils'
2
+ require 'active_support/core_ext/string/inflections'
3
+
4
+ module Pod
5
+ class Command
6
+ class Push < Command
7
+ self.summary = 'Push new specifications to a spec-repo'
8
+
9
+ self.description = <<-DESC
10
+ Validates NAME.podspec or `*.podspec' in the current working dir, creates
11
+ a directory and version folder for the pod in the local copy of
12
+ REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory,
13
+ and finally it pushes REPO to its remote.
14
+ DESC
15
+
16
+ self.arguments = 'REPO [NAME.podspec]'
17
+
18
+ def self.options
19
+ [ ["--allow-warnings", "Allows pushing even if there are warnings"],
20
+ ["--local-only", "Does not perform the step of pushing REPO to its remote"] ].concat(super)
21
+ end
22
+
23
+ def initialize(argv)
24
+ @allow_warnings = argv.flag?('allow-warnings')
25
+ @local_only = argv.flag?('local-only')
26
+ @repo = argv.shift_argument
27
+ if @repo.nil?
28
+ @repo = "master"
29
+ elsif @repo.end_with? ".podspec"
30
+ @podspec = @repo
31
+ @repo = "master"
32
+ else
33
+ @podspec = argv.shift_argument
34
+ end
35
+ super
36
+ end
37
+
38
+ def validate!
39
+ super
40
+ help! "A spec-repo name is required." unless @repo
41
+ end
42
+
43
+ def run
44
+ validate_podspec_files
45
+ check_repo_status
46
+ update_repo
47
+ add_specs_to_repo
48
+ push_repo unless @local_only
49
+ end
50
+
51
+ #-----------------------------------------------------------------------#
52
+
53
+ private
54
+
55
+ # @!group Push sub-steps
56
+
57
+ extend Executable
58
+ executable :git
59
+
60
+ # Performs a full lint against the podspecs.
61
+ #
62
+ def validate_podspec_files
63
+ UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
64
+ podspec_files.each do |podspec|
65
+ validator = Validator.new(podspec)
66
+ validator.only_errors = @allow_warnings
67
+ begin
68
+ validator.validate
69
+ rescue Exception
70
+ raise Informative, "The `#{podspec}` specification does not validate."
71
+ end
72
+ raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
73
+ end
74
+ end
75
+
76
+ # Checks that the repo is clean.
77
+ #
78
+ # @raise If the repo is not clean.
79
+ #
80
+ # @todo Add specs for staged and unstaged files.
81
+ #
82
+ # @todo Gracefully handle the case where source is not under git
83
+ # source control.
84
+ #
85
+ # @return [void]
86
+ #
87
+ def check_repo_status
88
+ clean = Dir.chdir(repo_dir) { `git status --porcelain 2>&1` } == ''
89
+ raise Informative, "The repo `#{@repo}` is not clean" unless clean
90
+ end
91
+
92
+ # Updates the git repo against the remote.
93
+ #
94
+ # @return [void]
95
+ #
96
+ def update_repo
97
+ UI.puts "Updating the `#{@repo}' repo\n".yellow
98
+ Dir.chdir(repo_dir) { UI.puts `git pull 2>&1` }
99
+ end
100
+
101
+ # Commits the podspecs to the source, which should be a git repo.
102
+ #
103
+ # @note The pre commit hook of the repo is skipped as the podspecs have
104
+ # already been linted.
105
+ #
106
+ # @return [void]
107
+ #
108
+ def add_specs_to_repo
109
+ UI.puts "\nAdding the #{'spec'.pluralize(count)} to the `#{@repo}' repo\n".yellow
110
+ podspec_files.each do |spec_file|
111
+ spec = Pod::Specification.from_file(spec_file)
112
+ output_path = File.join(repo_dir, spec.name, spec.version.to_s)
113
+ if Pathname.new(output_path).exist?
114
+ message = "[Fix] #{spec}"
115
+ elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
116
+ message = "[Update] #{spec}"
117
+ else
118
+ message = "[Add] #{spec}"
119
+ end
120
+ UI.puts " - #{message}"
121
+
122
+ FileUtils.mkdir_p(output_path)
123
+ FileUtils.cp(spec_file, output_path)
124
+ Dir.chdir(repo_dir) do
125
+ git!("add #{spec.name}")
126
+ git!("commit --no-verify -m '#{message}'")
127
+ end
128
+ end
129
+ end
130
+
131
+ # Pushes the git repo against the remote.
132
+ #
133
+ # @return [void]
134
+ #
135
+ def push_repo
136
+ UI.puts "\nPushing the `#{@repo}' repo\n".yellow
137
+ Dir.chdir(repo_dir) { UI.puts `git push 2>&1` }
138
+ end
139
+
140
+ #-----------------------------------------------------------------------#
141
+
142
+ private
143
+
144
+ # @!group Private helpers
145
+
146
+ # @return [Pathname] The directory of the repository.
147
+ #
148
+ def repo_dir
149
+ dir = config.repos_dir + @repo
150
+ raise Informative, "`#{@repo}` repo not found" unless dir.exist?
151
+ dir
152
+ end
153
+
154
+ # @return [Array<Pathname>] The path of the specifications to push.
155
+ #
156
+ def podspec_files
157
+ files = Pathname.glob(@podspec || "*.podspec")
158
+ raise Informative, "Couldn't find any .podspec file in current directory" if files.empty?
159
+ files
160
+ end
161
+
162
+ # @return [Integer] The number of the podspec files to push.
163
+ #
164
+ def count
165
+ podspec_files.count
166
+ end
167
+
168
+ #-----------------------------------------------------------------------#
169
+
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,145 @@
1
+ require 'fileutils'
2
+
3
+ module Pod
4
+ class Command
5
+ class Repo < Command
6
+ self.abstract_command = true
7
+
8
+ # @todo should not show a usage banner!
9
+ #
10
+ self.summary = 'Manage spec-repositories'
11
+
12
+ class Add < Repo
13
+ self.summary = 'Add a spec repo.'
14
+
15
+ self.description = <<-DESC
16
+ Clones `URL` in the local spec-repos directory at `~/.cocoapods`. The
17
+ remote can later be referred to by `NAME`.
18
+ DESC
19
+
20
+ self.arguments = 'NAME URL [BRANCH]'
21
+
22
+ def initialize(argv)
23
+ @name, @url, @branch = argv.shift_argument, argv.shift_argument, argv.shift_argument
24
+ super
25
+ end
26
+
27
+ def validate!
28
+ super
29
+ unless @name && @url
30
+ help! "Adding a repo needs a `NAME` and a `URL`."
31
+ end
32
+ end
33
+
34
+ def run
35
+ UI.section("Cloning spec repo `#{@name}` from `#{@url}`#{" (branch `#{@branch}`)" if @branch}") do
36
+ config.repos_dir.mkpath
37
+ Dir.chdir(config.repos_dir) { git!("clone '#{@url}' #{@name}") }
38
+ Dir.chdir(dir) { git!("checkout #{@branch}") } if @branch
39
+ SourcesManager.check_version_information(dir)
40
+ end
41
+ end
42
+ end
43
+
44
+ #-----------------------------------------------------------------------#
45
+
46
+ class Update < Repo
47
+ self.summary = 'Update a spec repo.'
48
+
49
+ self.description = <<-DESC
50
+ Updates the local clone of the spec-repo `NAME`. If `NAME` is omitted
51
+ this will update all spec-repos in `~/.cocoapods`.
52
+ DESC
53
+
54
+ self.arguments = '[NAME]'
55
+
56
+ def initialize(argv)
57
+ @name = argv.shift_argument
58
+ super
59
+ end
60
+
61
+ def run
62
+ SourcesManager.update(@name, true)
63
+ end
64
+ end
65
+
66
+ #-----------------------------------------------------------------------#
67
+
68
+ class Lint < Repo
69
+ self.summary = 'Validates all specs in a repo.'
70
+
71
+ self.description = <<-DESC
72
+ Lints the spec-repo `NAME`. If a directory is provided it is assumed
73
+ to be the root of a repo. Finally, if `NAME` is not provided this
74
+ will lint all the spec-repos known to CocoaPods.
75
+ DESC
76
+
77
+ self.arguments = '[ NAME | DIRECTORY ]'
78
+
79
+ def self.options
80
+ [["--only-errors", "Lint presents only the errors"]].concat(super)
81
+ end
82
+
83
+ def initialize(argv)
84
+ @name = argv.shift_argument
85
+ @only_errors = argv.flag?('only-errors')
86
+ super
87
+ end
88
+
89
+ # @todo Part of this logic needs to be ported to cocoapods-core so web
90
+ # services can validate the repo.
91
+ #
92
+ # @todo add UI.print and enable print statements again.
93
+ #
94
+ def run
95
+ if @name
96
+ dirs = File.exists?(@name) ? [ Pathname.new(@name) ] : [ dir ]
97
+ else
98
+ dirs = config.repos_dir.children.select {|c| c.directory?}
99
+ end
100
+ dirs.each do |dir|
101
+ SourcesManager.check_version_information(dir)
102
+ UI.puts "\nLinting spec repo `#{dir.realpath.basename}`\n".yellow
103
+
104
+ validator = Source::HealthReporter.new(dir)
105
+ validator.pre_check do |name, version|
106
+ UI.print '.'
107
+ end
108
+ report = validator.analyze
109
+ UI.puts
110
+ UI.puts
111
+
112
+ report.pods_by_warning.each do |message, versions_by_name|
113
+ UI.puts "-> #{message}".yellow
114
+ versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
115
+ UI.puts
116
+ end
117
+
118
+ report.pods_by_error.each do |message, versions_by_name|
119
+ UI.puts "-> #{message}".red
120
+ versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
121
+ UI.puts
122
+ end
123
+
124
+ UI.puts "Analyzed #{report.analyzed_paths.count} podspecs files.\n\n"
125
+ if report.pods_by_error.count.zero?
126
+ UI.puts "All the specs passed validation.".green << "\n\n"
127
+ else
128
+ raise Informative, "#{report.pods_by_error.count} podspecs failed validation."
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ #-----------------------------------------------------------------------#
135
+
136
+ extend Executable
137
+ executable :git
138
+
139
+ def dir
140
+ config.repos_dir + @name
141
+ end
142
+ end
143
+ end
144
+ end
145
+
@@ -0,0 +1,61 @@
1
+ module Pod
2
+ class Command
3
+ class Search < Command
4
+ self.summary = 'Search pods'
5
+
6
+ self.description = <<-DESC
7
+ Searches for pods, ignoring case, whose name matches `QUERY'. If the
8
+ `--full' option is specified, this will also search in the summary and
9
+ description of the pods.
10
+ DESC
11
+
12
+ self.arguments = '[QUERY]'
13
+
14
+ def self.options
15
+ [
16
+ ["--full", "Search by name, summary, and description"],
17
+ ["--stats", "Show additional stats (like GitHub watchers and forks)"],
18
+ ["--ios", "Restricts the search to Pods supported on iOS"],
19
+ ["--osx", "Restricts the search to Pods supported on OS X"]
20
+ ].concat(super)
21
+ end
22
+
23
+ def initialize(argv)
24
+ @full_text_search = argv.flag?('full')
25
+ @stats = argv.flag?('stats')
26
+ @supported_on_ios = argv.flag?('ios')
27
+ @supported_on_osx = argv.flag?('osx')
28
+ @query = argv.shift_argument
29
+ super
30
+ end
31
+
32
+ def validate!
33
+ super
34
+ help! "A search query is required." unless @query
35
+ end
36
+
37
+ def run
38
+ sets = SourcesManager.search_by_name(@query.strip, @full_text_search)
39
+ if @supported_on_ios
40
+ sets.reject!{ |set| !set.specification.available_platforms.map(&:name).include?(:ios) }
41
+ end
42
+ if @supported_on_osx
43
+ sets.reject!{ |set| !set.specification.available_platforms.map(&:name).include?(:osx) }
44
+ end
45
+
46
+ statistics_provider = Specification::Set::Statistics.new(STATISTICS_CACHE_FILE)
47
+ sets.each do |set|
48
+ begin
49
+ if @stats
50
+ UI.pod(set, :stats, statistics_provider)
51
+ else
52
+ UI.pod(set, :normal)
53
+ end
54
+ rescue DSLError
55
+ UI.warn "Skipping `#{set.name}` because the podspec contains errors."
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,134 @@
1
+ module Pod
2
+ class Command
3
+ class Setup < Command
4
+ self.summary = 'Setup the CocoaPods environment'
5
+
6
+ self.description = <<-DESC
7
+ Creates a directory at `~/.cocoapods` which will hold your spec-repos.
8
+ This is where it will create a clone of the public `master` spec-repo from:
9
+
10
+ https://github.com/CocoaPods/Specs
11
+
12
+ If the clone already exists, it will ensure that it is up-to-date.
13
+ DESC
14
+
15
+ def self.options
16
+ [["--push", "Use this option to enable push access once granted"]].concat(super)
17
+ end
18
+
19
+ extend Executable
20
+ executable :git
21
+
22
+ def initialize(argv)
23
+ @push_option = argv.flag?('push')
24
+ super
25
+ end
26
+
27
+ def run
28
+ UI.section "Setting up CocoaPods master repo" do
29
+ if master_repo_dir.exist?
30
+ set_master_repo_url
31
+ set_master_repo_branch
32
+ update_master_repo
33
+ else
34
+ add_master_repo
35
+ end
36
+ end
37
+
38
+ access_type = push? ? "push" : "read-only"
39
+ UI.puts "Setup completed (#{access_type} access)".green
40
+ end
41
+
42
+ #--------------------------------------#
43
+
44
+ # @!group Setup steps
45
+
46
+ # Sets the url of the master repo according to whether it is push.
47
+ #
48
+ # @return [void]
49
+ #
50
+ def set_master_repo_url
51
+ Dir.chdir(master_repo_dir) do
52
+ git("remote set-url origin '#{url}'")
53
+ end
54
+ end
55
+
56
+ # Adds the master repo from the remote.
57
+ #
58
+ # @return [void]
59
+ #
60
+ def add_master_repo
61
+ @command ||= Repo::Add.parse(['master', url, 'master']).run
62
+ end
63
+
64
+ # Updates the master repo against the remote.
65
+ #
66
+ # @return [void]
67
+ #
68
+ def update_master_repo
69
+ SourcesManager.update('master', true)
70
+ end
71
+
72
+ # Sets the repo to the master branch.
73
+ #
74
+ # @note This is not needed anymore as it was used for CocoaPods 0.6
75
+ # release candidates.
76
+ #
77
+ # @return [void]
78
+ #
79
+ def set_master_repo_branch
80
+ Dir.chdir(master_repo_dir) do
81
+ git("checkout master")
82
+ end
83
+ end
84
+
85
+ #--------------------------------------#
86
+
87
+ # @!group Private helpers
88
+
89
+ # @return [String] the url to use according to whether push mode should
90
+ # be enabled.
91
+ #
92
+ def url
93
+ (push?) ? read_write_url : read_only_url
94
+ end
95
+
96
+ # @return [String] the read only url of the master repo.
97
+ #
98
+ def read_only_url
99
+ 'https://github.com/CocoaPods/Specs.git'
100
+ end
101
+
102
+ # @return [String] the read-write url of the master repo.
103
+ #
104
+ def read_write_url
105
+ 'git@github.com:CocoaPods/Specs.git'
106
+ end
107
+
108
+ # Checks if the user asked to setup the master repo in push mode or if
109
+ # the repo was already in push mode.
110
+ #
111
+ # @return [String] whether the master repo should be set up in push mode.
112
+ #
113
+ def push?
114
+ @push ||= (@push_option || master_repo_is_push?)
115
+ end
116
+
117
+ # @return [Bool] if the master repo is already configured in push mode.
118
+ #
119
+ def master_repo_is_push?
120
+ return false unless master_repo_dir.exist?
121
+ Dir.chdir(master_repo_dir) do
122
+ url = git('config --get remote.origin.url')
123
+ url.chomp == read_write_url
124
+ end
125
+ end
126
+
127
+ # @return [Pathname] the directory of the master repo.
128
+ #
129
+ def master_repo_dir
130
+ SourcesManager.master_repo_dir
131
+ end
132
+ end
133
+ end
134
+ end