cocoapods-repo-sq 0.0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +13 -0
  4. data/CHANGES.md +0 -0
  5. data/CONTRIBUTING.md +4 -0
  6. data/Gemfile +12 -0
  7. data/LICENSE.txt +202 -0
  8. data/README.md +84 -0
  9. data/Rakefile +34 -0
  10. data/cocoapods-repo-sq.gemspec +45 -0
  11. data/doc/CocoapodsRepoSq/Downloader/Extensions.html +225 -0
  12. data/doc/CocoapodsRepoSq/Downloader.html +352 -0
  13. data/doc/CocoapodsRepoSq/DownloaderExtensions.html +227 -0
  14. data/doc/CocoapodsRepoSq/Repository.html +970 -0
  15. data/doc/CocoapodsRepoSq/RepositoryStore.html +962 -0
  16. data/doc/CocoapodsRepoSq/Source.html +342 -0
  17. data/doc/CocoapodsRepoSq/SquareExtensions.html +227 -0
  18. data/doc/CocoapodsRepoSq.html +149 -0
  19. data/doc/Pod/Command/RepoSq/Add.html +436 -0
  20. data/doc/Pod/Command/RepoSq/List.html +256 -0
  21. data/doc/Pod/Command/RepoSq/Remove.html +378 -0
  22. data/doc/Pod/Command/RepoSq/Update.html +380 -0
  23. data/doc/Pod/Command/RepoSq.html +157 -0
  24. data/doc/Pod/Command.html +137 -0
  25. data/doc/Pod/Downloader/Square.html +334 -0
  26. data/doc/Pod/Downloader/SquareExtensions.html +218 -0
  27. data/doc/Pod/Downloader.html +105 -0
  28. data/doc/Pod/SquareSource.html +416 -0
  29. data/doc/Pod.html +146 -0
  30. data/doc/_index.html +256 -0
  31. data/doc/class_list.html +51 -0
  32. data/doc/css/common.css +1 -0
  33. data/doc/css/full_list.css +58 -0
  34. data/doc/css/style.css +499 -0
  35. data/doc/file.README.html +132 -0
  36. data/doc/file_list.html +56 -0
  37. data/doc/frames.html +17 -0
  38. data/doc/index.html +132 -0
  39. data/doc/js/app.js +248 -0
  40. data/doc/js/full_list.js +216 -0
  41. data/doc/js/jquery.js +4 -0
  42. data/doc/method_list.html +291 -0
  43. data/doc/top-level-namespace.html +110 -0
  44. data/lib/cocoapods_plugin.rb +49 -0
  45. data/lib/cocoapods_repo_sq/downloader.rb +86 -0
  46. data/lib/cocoapods_repo_sq/repository.rb +109 -0
  47. data/lib/cocoapods_repo_sq/repository_store.rb +170 -0
  48. data/lib/cocoapods_repo_sq/source.rb +42 -0
  49. data/lib/cocoapods_repo_sq.rb +26 -0
  50. data/lib/pod/command/repo_sq/add.rb +87 -0
  51. data/lib/pod/command/repo_sq/list.rb +55 -0
  52. data/lib/pod/command/repo_sq/remove.rb +61 -0
  53. data/lib/pod/command/repo_sq/update.rb +62 -0
  54. data/lib/pod/command/repo_sq.rb +38 -0
  55. data/spec/spec_helper.rb +80 -0
  56. data/spec/test-repos/repo-1/.settings.yml +4 -0
  57. data/spec/test-repos/repo-2/.settings.yml +4 -0
  58. data/spec/unit/cocoapods_plugin_spec.rb +108 -0
  59. data/spec/unit/cocoapods_repo_sq/downloader_spec.rb +57 -0
  60. data/spec/unit/cocoapods_repo_sq/repository_spec.rb +57 -0
  61. data/spec/unit/cocoapods_repo_sq/repository_store_spec.rb +124 -0
  62. data/spec/unit/cocoapods_repo_sq/source_spec.rb +35 -0
  63. data/spec/unit/pod/command/add_spec.rb +73 -0
  64. data/spec/unit/pod/command/list_spec.rb +70 -0
  65. data/spec/unit/pod/command/remove_spec.rb +47 -0
  66. data/spec/unit/pod/command/update_spec.rb +49 -0
  67. metadata +184 -0
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.12
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="CocoapodsRepoSq.html" title="CocoapodsRepoSq (module)">CocoapodsRepoSq</a></span>, <span class='object_link'><a href="Pod.html" title="Pod (module)">Pod</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Fri Apr 27 10:49:52 2018 by
104
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.12 (ruby-2.4.0).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
+ </html>
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ # plugin main source files
23
+ require 'cocoapods_repo_sq/repository_store'
24
+ require 'cocoapods_repo_sq/repository'
25
+ require 'cocoapods_repo_sq/source'
26
+ require 'cocoapods_repo_sq/downloader'
27
+
28
+ # plugin repo-sq command line support
29
+ require 'pod/command/repo_sq'
30
+
31
+ Pod::HooksManager.register('cocoapods-repo-sq', :source_provider) do |context, options|
32
+ name = options.fetch('repository', nil)
33
+ raise Pod::Informative, "repository is needed for `cocoapods-repo-sq``" unless name
34
+
35
+ repository_store = CocoapodsRepoSq::RepositoryStore.default
36
+ unless repository_store.exists?(name)
37
+ raise Pod::Informative, "Square SDK repository `#{name}` does not exist"
38
+ end
39
+
40
+ repository = repository_store.get(name)
41
+ CocoapodsRepoSq::Repository.current = repository
42
+
43
+ # update specs when `pod update` is being ran
44
+ if ARGV.include?('--repo-update') ||
45
+ (ARGV.include?('update') && !ARGV.include?('--no-repo-update'))
46
+ repository.update_specs
47
+ end
48
+ context.add_source(CocoapodsRepoSq::Source.new(repository))
49
+ end
@@ -0,0 +1,86 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ # Main namespace for cocoapods-repo-sq plugin
23
+ module CocoapodsRepoSq
24
+ # Implemenents a {https://github.com/CocoaPods/cocoapods-downloader
25
+ # downloader strategy} to support downloading files from a Square SDK
26
+ # repository server over the HTTPS protocol with
27
+ # {https://tools.ietf.org/html/rfc7617 Basic HTTP Authentication RFC7617}
28
+ class Downloader < ::Pod::Downloader::Http
29
+ # Helper module used to override the {::Pod::Downloader::downloader_class_by_key} method to
30
+ # include a `:square` key pointing to {Downloader}. This allows square to be
31
+ # defined as the protocol for downloading Pods on the
32
+ # {https://guides.cocoapods.org/syntax/podspec.html#source
33
+ # podfile source setting}
34
+ module Extensions
35
+ # Map of downloaded classes supported by Cocoapods available to the
36
+ # {https://guides.cocoapods.org/syntax/podspec.html#source podfile source
37
+ # setting}. Square is included to add support for Square SDK repository
38
+ # hosted podspecs and pods.
39
+ #
40
+ # @return [Hash{Symbol=>Class}]
41
+ # a map where the key is a symbol used in the podspec source
42
+ # setting such as `:http`, `:git`, `:square` and the class is the one
43
+ # responsible for implementing a particular download strategy
44
+ def downloader_class_by_key
45
+ super.merge(:square => Downloader)
46
+ end
47
+ end
48
+
49
+ # Options accepted by this dowmloader strategy.
50
+ # The base class already supports `:flatten`, `:type`, `:sha256`, `:sha1`.
51
+ # {Downloader} supports passing a `:repository` option to indicate which
52
+ # Square SDK repository to download files from. If none is provided, it
53
+ # will try to use the current repository. See {Repository#current}
54
+ #
55
+ # @return [Array<Symbol>]
56
+ # a list of accepted options
57
+ def self.options
58
+ super + [:repository]
59
+ end
60
+
61
+ # Square SDK repository to be used by this downloader.
62
+ # It can be passed as an option when initializing this class or also taken
63
+ # from the current repository. See {Repository#current}
64
+ #
65
+ # @return [CocoapodsRepoSq::Repository]
66
+ # a Square SDK repository
67
+ def repository
68
+ @repository ||= options.fetch(:repository) { Repository.current }
69
+ end
70
+
71
+ private
72
+ def download_file(full_filename)
73
+ auth = "#{repository.username}:#{repository.password}"
74
+ download_url = File.join(repository.url, url)
75
+ curl! '-u', auth, '-f', '-L', '-o', full_filename, download_url, '--create-dirs', '--netrc-optional'
76
+ end
77
+ end
78
+ end
79
+
80
+ Pod::Downloader.class_eval do
81
+ class << self
82
+ # override `downloader_class_by_key` method. See documentation on the
83
+ # prepended class
84
+ prepend ::CocoapodsRepoSq::Downloader::Extensions
85
+ end
86
+ end
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ # Main namespace for cocoapods-repo-sq plugin
23
+ module CocoapodsRepoSq
24
+ # Class that represents the credentials needed to access a Square SDK
25
+ # repository of {https://guides.cocoapods.org/syntax/podspec.html podspecs}
26
+ # for a given Square Application. Responsible for downloading a copy of the
27
+ # repository from Square servers and cache it on the local filesystem.
28
+ class Repository
29
+ class << self
30
+ # Square SDK repository set by the plugin initialization on the
31
+ # {https://guides.cocoapods.org/syntax/podfile.html#plugin Podfile}.
32
+ # This setting is used by the {Downloader} class to know which repository
33
+ # to download files from in the context of a `pod install` or `pod update`
34
+ # command call. When a podspec indicates a Square source it does not have
35
+ # a Square SDK repository reference to provide to the Downloader class so
36
+ # this global setting is used instead.
37
+ #
38
+ # @return [CocoapodsRepoSq::Repository]
39
+ # current Square SDK repository
40
+ attr_accessor :current
41
+ end
42
+
43
+ # @return [String]
44
+ # nickname under which a Square SDK repository was registered on the
45
+ # {RepositoryStore}.
46
+ attr_reader :name
47
+
48
+ # @return [String]
49
+ # server user name used to access a specific Square SDK repository.
50
+ attr_reader :username
51
+
52
+ # @return [String]
53
+ # server password used to access a specific Square SDK repository.
54
+ attr_reader :password
55
+
56
+ # @return [String]
57
+ # Square SDK repositories server url.
58
+ attr_reader :url
59
+
60
+ # @return [String]
61
+ # local filesystem path where this repository cache of podspecs is stored.
62
+ attr_reader :path
63
+
64
+ # @param name [String]
65
+ # nickname under which a Square SDK repository was registered on the
66
+ # {RepositoryStore}.
67
+ #
68
+ # @param username [String]
69
+ # server user name used to access a specific Square SDK repository.
70
+ #
71
+ # @param password [String]
72
+ # server password used to access a specific Square SDK repository.
73
+ #
74
+ # @param url [String]
75
+ # Square SDK repositories server url.
76
+ #
77
+ # @param path [String]
78
+ # local filesystem path where this repository cache of podspecs is stored.
79
+ def initialize(name, username, password, url, path)
80
+ @name = name
81
+ @username = username
82
+ @url = url
83
+ @password = password
84
+ @path = path
85
+ end
86
+
87
+ # Updates the local copy of the podspecs from the Square SDK repository
88
+ def update_specs
89
+ # download new specs to a temp directory
90
+ new_specs_path = get_temporary_path
91
+ downloader = Downloader.new(new_specs_path, "specs.zip", :repository => self)
92
+ downloader.download
93
+
94
+ # perform cleanup
95
+ specs_path = File.join(@path, 'Specs')
96
+ FileUtils.rm(File.join(new_specs_path, "file.zip"))
97
+ FileUtils.rm_rf(specs_path)
98
+ FileUtils.mv(new_specs_path, specs_path)
99
+ nil
100
+ end
101
+
102
+ private
103
+ def get_temporary_path
104
+ temp_path = File.join(@path, 'Specs.new')
105
+ FileUtils.rm_rf(temp_path)
106
+ temp_path
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,170 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+ require 'yaml'
22
+
23
+ # Main namespace for cocoapods-repo-sq plugin
24
+ module CocoapodsRepoSq
25
+ # Class responsible for managing user configured Square SDK repositories.
26
+ # Repository settings and a local copy of the podspecs are stored on the
27
+ # filesystem inside Cocoapods' home directory.
28
+ class RepositoryStore
29
+ # Default store located in Cocoapods's home directory.
30
+ # Used by the plugin to look for registered repositories or by the `repo-sq`
31
+ # commands to manage registered repositories.
32
+ #
33
+ # @return [RepositoryStore]
34
+ # the default RepositoryStore
35
+ def self.default
36
+ @default ||= new
37
+ end
38
+
39
+ # @param path [String]
40
+ # the path where all Square SDK repositories will be stored. If no path
41
+ # is provided a default `$COCOAPODS_HOME/repo-sq` will be used
42
+ def initialize(path = nil)
43
+ path ||= File.join(Pod::Config.instance.home_dir, 'repo-sq')
44
+ @path = ensure_path(path)
45
+ end
46
+
47
+ # Indicates if a Square SDK repository has been added to the store
48
+ #
49
+ # @param name [String]
50
+ # the Square SDK repository name to look for
51
+ #
52
+ # @return [Boolean]
53
+ # `true` if the targeted Square SDK repository is configured in this
54
+ # repository store, otherwise `false`.
55
+ def exists?(name)
56
+ File.exists?(settings_path(name))
57
+ end
58
+
59
+ # Returns all repositories currently configured in the store as a list of
60
+ # {Repository} objects
61
+ #
62
+ # @return [Array<Repository>]
63
+ # the list of all Square SDK repositories
64
+ def list
65
+ Dir[File.join(@path, '*')].map do |dir|
66
+ name = File.basename(dir)
67
+ get(name)
68
+ end.compact
69
+ end
70
+
71
+ # Returns a {Repository} instance if a Square SDK repository exists in the
72
+ # store with the given name
73
+ #
74
+ # @param name [String]
75
+ # the Square SDK repository name to look for
76
+ #
77
+ # @return [Repository]
78
+ # a Square SDK repository
79
+ def get(name)
80
+ return unless exists?(name)
81
+
82
+ settings = load_settings!(name)
83
+ Repository.new(
84
+ settings[:name],
85
+ settings[:username],
86
+ settings[:password],
87
+ settings[:url],
88
+ repository_path(name)
89
+ )
90
+ end
91
+
92
+ # Registers a Square SDK repository on the local store
93
+ #
94
+ # @param name [String]
95
+ # the Square SDK repository name.
96
+ #
97
+ # @param username [String]
98
+ # the Square SDK repository username.
99
+ #
100
+ # @param password [String]
101
+ # the Square SDK repository password.
102
+ #
103
+ # @param url [String]
104
+ # the Square SDK repositories server URL.
105
+ #
106
+ # @return [Repository]
107
+ # a Square SDK repository
108
+ #
109
+ # @raise [Pod::Informative]
110
+ # if the repository has already been configured
111
+ def register(name, username, password, url)
112
+ if exists?(name)
113
+ message = "Square SDK repository `#{name}` is already configured"
114
+ raise Pod::Informative, message
115
+ end
116
+
117
+ begin
118
+ store_settings!(name, username, password, url)
119
+ Repository.new(name, username, password, url, repository_path(name))
120
+ rescue => error
121
+ remove(name)
122
+ raise error
123
+ end
124
+ end
125
+
126
+ # Removes a Square SDK repository from the local store
127
+ #
128
+ # @param name [String]
129
+ # the name of the Square SDK Repository to be removed.
130
+ #
131
+ # @return [Boolean]
132
+ # `true` if the targeted Square SDK repository was removed from the store,
133
+ # otherwise `false`.
134
+ def remove(name)
135
+ path = repository_path(name)
136
+ File.exists?(path) && FileUtils.rm_rf(path) && true
137
+ end
138
+
139
+ private
140
+ def load_settings!(name)
141
+ YAML.load_file(settings_path(name))
142
+ end
143
+
144
+ def store_settings!(name, username, password, url)
145
+ settings = {
146
+ name: name,
147
+ username: username,
148
+ password: password,
149
+ url: url
150
+ }
151
+
152
+ settings_filename = settings_path(name)
153
+ ensure_path(File.dirname(settings_filename))
154
+ File.open(settings_filename, 'w') { |f| YAML.dump(settings, f) }
155
+ end
156
+
157
+ def ensure_path(path)
158
+ FileUtils.mkpath(path)
159
+ path
160
+ end
161
+
162
+ def repository_path(name)
163
+ File.join(@path, name)
164
+ end
165
+
166
+ def settings_path(name)
167
+ File.join(repository_path(name), '.settings.yml')
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ # Main namespace for cocoapods-repo-sq plugin
23
+ module CocoapodsRepoSq
24
+ # Class responsible of managing a collection of podspecs and pods hosted at a
25
+ # Square SDK repository. Files are accessed via HTTPS with
26
+ # {https://tools.ietf.org/html/rfc7617 Basic HTTP Authentication RFC7617}
27
+ class Source < ::Pod::Source
28
+ # @return [Repository]
29
+ # an object representing a Square SDK repository
30
+ #
31
+ attr_reader :repository
32
+
33
+ # @param repository [Repository]
34
+ # an object representing a Square SDK repository where this source will
35
+ # get podspecs from.
36
+ #
37
+ def initialize(repository)
38
+ @repository = repository
39
+ super(repository.path)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ # Main namespace for cocoapods-repo-sq plugin
23
+ module CocoapodsRepoSq
24
+ # Plugin version
25
+ VERSION = '0.0.1'.freeze
26
+ end
@@ -0,0 +1,87 @@
1
+ # coding: utf-8
2
+
3
+ # This source file is part of the cocoapods-repo-sq plugin under the Apache 2.0
4
+ # license:
5
+ #
6
+ # Copyright 2018 Square Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ # =============================================================================
21
+
22
+ module Pod
23
+ class Command
24
+ class RepoSq < Command
25
+ # Subclass of {RepoSq}
26
+ # Provides support for the `pod repo-sq add` which adds a Square SDK
27
+ # repository to the user's cocoapods local repositories store.
28
+ class Add < RepoSq
29
+ # Default Square SDK repositories server URL.
30
+ # This URL can be customized by providing a fourth undocumented
31
+ # parameter to this command but not intended for public use.
32
+ #
33
+ # @return [String]
34
+ # default Square SDK repositories server URL.
35
+ DEFAULT_URL = 'https://sdk.squareup.com/ios'
36
+
37
+ self.summary = 'Add a Square SDK repository'
38
+
39
+ self.description = <<-DESC
40
+ Add a Square SDK repository for your application to your local Cocoapod's
41
+ sources registry. The remote can later be referred to by `NAME`.
42
+ DESC
43
+
44
+ self.arguments = [
45
+ CLAide::Argument.new('NAME', true),
46
+ CLAide::Argument.new('USERNAME', true),
47
+ CLAide::Argument.new('PASSWORD', true),
48
+ ]
49
+
50
+ def initialize(argv)
51
+ @name = argv.shift_argument
52
+ @username = argv.shift_argument
53
+ @password = argv.shift_argument
54
+ @url = argv.shift_argument || DEFAULT_URL
55
+ super
56
+ end
57
+
58
+ # Validates that all required arguments are present: `NAME`, `USERNAME`
59
+ # and `PASSWORD`
60
+ def validate!
61
+ super
62
+ unless @name && @username && @password
63
+ help! 'Adding a Square SDK repository needs a `NAME`, `USERNAME` and a `PASSWORD`.'
64
+ end
65
+ end
66
+
67
+ # Registers a Square SDK repository on the current user
68
+ # {CocoapodsRepoSq::RepositoryStore}.
69
+ # It checks that the user name and password are valid and that the
70
+ # repository exists on the Square server.
71
+ def run
72
+ section = "Adding Square SDK repository `#{@name}`"
73
+ UI.section(section) do
74
+ repository = repository_store.register(@name, @username, @password, @url)
75
+ begin
76
+ repository.update_specs
77
+ rescue => e
78
+ repository_store.remove(@name)
79
+ raise Informative, "Could not add `#{@name}`.\n" \
80
+ "#{e.class.name}: #{e.message}"
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end