cocoapods-podfile-generator 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +138 -1
- data/cocoapods-podfile-generator.gemspec +1 -1
- data/lib/cocoapods-podfile-generator/command/podfile.rb +39 -11
- data/lib/cocoapods-podfile-generator/version.rb +6 -2
- data/spec/Templates/Invalid_Template +2 -0
- data/spec/Templates/Podfile_Template +20 -0
- data/spec/{Bad_Pods_Format.txt → TextFiles/Bad_Pods_Format.txt} +0 -0
- data/spec/{Non_Existing_Pod.txt → TextFiles/Non_Existing_Pod.txt} +0 -0
- data/spec/{Pods.txt → TextFiles/Pods.txt} +0 -0
- data/spec/{TextFile → TextFiles/TextFile} +0 -0
- data/spec/command/podfile_spec.rb +70 -36
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf5d75b6358b40f6ef22c5e9e78d6d9a4de211e4d3eb97306dd2858af7e5fbc
|
4
|
+
data.tar.gz: 812a76cde235bdd4e078a975dcca70bb71ed16fb5220e29148cece26859ef10f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f1ca683b1e5e4870b50d84810b18c80efff2d258f91dce90fbc9baa4d15c0c3bf8260462dec61aad36830e5be1bfebb3f0e61ec740e355ec1bc6f0237f94f0
|
7
|
+
data.tar.gz: ccadae6fb4ac0a1c85aa15d7b6b05d116383c9772985e72bb27eb0f9cf3e0ff3939683ca0c4a227e4f6344741022cca2bde76ea1e3f53f3d30cac43208c7424b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,8 @@ You can pass some flags and options to generate some different tastes for the Po
|
|
25
25
|
| `--include-default-subspecs` | Include the `default_subspecs` values in the Podfile if any. |
|
26
26
|
| `--include-all-subspecs` | Include all the subspecs in the Podfile if any. |
|
27
27
|
| `--include-analyze` | Let cocoapods resolve the necessary dependencies for the provided pods and include them in the Podfile. |
|
28
|
-
| `--
|
28
|
+
| `--template` | A Podfile file to be used as the template for the final Podfile. Add the `{{CPG}}` keyword somewhere within your template and that will be replaced with the generated targets. Example: `--template=path/to/template_file` |
|
29
|
+
| `--text-file` | A text file containing the pods to add to the Podfile. Each row within the file should have the format: <POD_NAME>:<POD_VERSION>. Example: `--text-file=path/to/file.txt` |
|
29
30
|
| `--platforms` | Platforms to consider. If not set, all platforms supported by the pods will be used. A target will be generated per platform. Example: `--platforms=ios,tvos` |
|
30
31
|
| `--output` | Path where the Podfile will be saved. If not set, the Podfile will be saved where the command is running. Example: `--output=path/to/save/Podfile_name` |
|
31
32
|
|
@@ -70,6 +71,142 @@ target 'Target_for_tvos' do
|
|
70
71
|
end
|
71
72
|
```
|
72
73
|
|
74
|
+
## Use an existing Podfile as a template
|
75
|
+
|
76
|
+
The content of the Podfile file can be very simple (including only a few lines) or it can be quite complex (for example, adding custom code when using the `pre_install` hook).
|
77
|
+
|
78
|
+
To avoid adding a flag for each option supported by the `install!` method, or to add an option for adding your own code when using a hook, etc., the solution is that you bring your own Podfile into the scene. This way, you will have better control of all the options and code blocks you need to make your Podfile work.
|
79
|
+
|
80
|
+
In order to use your Podfile as a template, just add the keyword `{{CPG}}` where you need the targets created by this plugin. E.g., create the following Podfile:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
install! 'cocoapods', integrate_targets: false, generate_multiple_pod_projects: true
|
84
|
+
use_frameworks!
|
85
|
+
|
86
|
+
pre_install do |installer|
|
87
|
+
installer.pod_targets.each do |pod|
|
88
|
+
puts "Forcing a static_framework to false for #{pod.name}"
|
89
|
+
if Pod::VERSION >= "1.7.0"
|
90
|
+
if pod.build_as_static?
|
91
|
+
def pod.build_as_static?; false end
|
92
|
+
def pod.build_as_static_framework?; false end
|
93
|
+
def pod.build_as_dynamic?; true end
|
94
|
+
def pod.build_as_dynamic_framework?; true end
|
95
|
+
end
|
96
|
+
else
|
97
|
+
def pod.static_framework?; false end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
{{CPG}}
|
103
|
+
```
|
104
|
+
|
105
|
+
Then use it with the command
|
106
|
+
|
107
|
+
```sh
|
108
|
+
pod podfile Firebase:10.0.0 FBSDKCoreKit:15.0.0 --include-all-subspecs --template=Podfile
|
109
|
+
```
|
110
|
+
|
111
|
+
And you will get
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
install! 'cocoapods', integrate_targets: false, generate_multiple_pod_projects: true
|
115
|
+
use_frameworks!
|
116
|
+
|
117
|
+
pre_install do |installer|
|
118
|
+
installer.pod_targets.each do |pod|
|
119
|
+
puts "Forcing a static_framework to false for #{pod.name}"
|
120
|
+
if Pod::VERSION >= "1.7.0"
|
121
|
+
if pod.build_as_static?
|
122
|
+
def pod.build_as_static?; false end
|
123
|
+
def pod.build_as_static_framework?; false end
|
124
|
+
def pod.build_as_dynamic?; true end
|
125
|
+
def pod.build_as_dynamic_framework?; true end
|
126
|
+
end
|
127
|
+
else
|
128
|
+
def pod.static_framework?; false end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
target 'Target_for_ios' do
|
134
|
+
platform :ios, '12.0'
|
135
|
+
pod 'Firebase', '10.0.0'
|
136
|
+
pod 'FBSDKCoreKit', '15.0.0'
|
137
|
+
pod 'Firebase/Core', '10.0.0'
|
138
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
139
|
+
pod 'Firebase/Analytics', '10.0.0'
|
140
|
+
pod 'Firebase/AnalyticsWithAdIdSupport', '10.0.0'
|
141
|
+
pod 'Firebase/AnalyticsWithoutAdIdSupport', '10.0.0'
|
142
|
+
pod 'Firebase/ABTesting', '10.0.0'
|
143
|
+
pod 'Firebase/AppDistribution', '10.0.0'
|
144
|
+
pod 'Firebase/AppCheck', '10.0.0'
|
145
|
+
pod 'Firebase/Auth', '10.0.0'
|
146
|
+
pod 'Firebase/Crashlytics', '10.0.0'
|
147
|
+
pod 'Firebase/Database', '10.0.0'
|
148
|
+
pod 'Firebase/DynamicLinks', '10.0.0'
|
149
|
+
pod 'Firebase/Firestore', '10.0.0'
|
150
|
+
pod 'Firebase/Functions', '10.0.0'
|
151
|
+
pod 'Firebase/InAppMessaging', '10.0.0'
|
152
|
+
pod 'Firebase/Installations', '10.0.0'
|
153
|
+
pod 'Firebase/Messaging', '10.0.0'
|
154
|
+
pod 'Firebase/MLModelDownloader', '10.0.0'
|
155
|
+
pod 'Firebase/Performance', '10.0.0'
|
156
|
+
pod 'Firebase/RemoteConfig', '10.0.0'
|
157
|
+
pod 'Firebase/Storage', '10.0.0'
|
158
|
+
end
|
159
|
+
|
160
|
+
target 'Target_for_osx' do
|
161
|
+
platform :osx, '10.13'
|
162
|
+
pod 'Firebase', '10.0.0'
|
163
|
+
pod 'Firebase/Core', '10.0.0'
|
164
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
165
|
+
pod 'Firebase/Analytics', '10.0.0'
|
166
|
+
pod 'Firebase/AnalyticsWithAdIdSupport', '10.0.0'
|
167
|
+
pod 'Firebase/AnalyticsWithoutAdIdSupport', '10.0.0'
|
168
|
+
pod 'Firebase/ABTesting', '10.0.0'
|
169
|
+
pod 'Firebase/AppCheck', '10.0.0'
|
170
|
+
pod 'Firebase/Auth', '10.0.0'
|
171
|
+
pod 'Firebase/Crashlytics', '10.0.0'
|
172
|
+
pod 'Firebase/Database', '10.0.0'
|
173
|
+
pod 'Firebase/Firestore', '10.0.0'
|
174
|
+
pod 'Firebase/Functions', '10.0.0'
|
175
|
+
pod 'Firebase/Installations', '10.0.0'
|
176
|
+
pod 'Firebase/Messaging', '10.0.0'
|
177
|
+
pod 'Firebase/MLModelDownloader', '10.0.0'
|
178
|
+
pod 'Firebase/RemoteConfig', '10.0.0'
|
179
|
+
pod 'Firebase/Storage', '10.0.0'
|
180
|
+
end
|
181
|
+
|
182
|
+
target 'Target_for_tvos' do
|
183
|
+
platform :tvos, '12.0'
|
184
|
+
pod 'Firebase', '10.0.0'
|
185
|
+
pod 'FBSDKCoreKit', '15.0.0'
|
186
|
+
pod 'Firebase/Core', '10.0.0'
|
187
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
188
|
+
pod 'Firebase/Analytics', '10.0.0'
|
189
|
+
pod 'Firebase/AnalyticsWithAdIdSupport', '10.0.0'
|
190
|
+
pod 'Firebase/AnalyticsWithoutAdIdSupport', '10.0.0'
|
191
|
+
pod 'Firebase/ABTesting', '10.0.0'
|
192
|
+
pod 'Firebase/AppCheck', '10.0.0'
|
193
|
+
pod 'Firebase/Auth', '10.0.0'
|
194
|
+
pod 'Firebase/Crashlytics', '10.0.0'
|
195
|
+
pod 'Firebase/Database', '10.0.0'
|
196
|
+
pod 'Firebase/Firestore', '10.0.0'
|
197
|
+
pod 'Firebase/Functions', '10.0.0'
|
198
|
+
pod 'Firebase/InAppMessaging', '10.0.0'
|
199
|
+
pod 'Firebase/Installations', '10.0.0'
|
200
|
+
pod 'Firebase/Messaging', '10.0.0'
|
201
|
+
pod 'Firebase/MLModelDownloader', '10.0.0'
|
202
|
+
pod 'Firebase/Performance', '10.0.0'
|
203
|
+
pod 'Firebase/RemoteConfig', '10.0.0'
|
204
|
+
pod 'Firebase/Storage', '10.0.0'
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
73
208
|
## Known limitations
|
74
209
|
|
210
|
+
* Do not support pods with empty versions
|
75
211
|
* Does not support versions with optimistic operator (~>)
|
212
|
+
* Cannot pass custom options to a pod (E.g., `pod 'PonyDebugger', :configurations => ['Debug', 'Beta']` )
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['israel.spgh@gmail.com']
|
11
11
|
spec.summary = CocoapodsPodfileGenerator::SUMMARY
|
12
12
|
spec.description = CocoapodsPodfileGenerator::DESCRIPTION
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/SotoiGhost/cocoapods-podfile-generator'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -37,6 +37,7 @@ module Pod
|
|
37
37
|
["--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}", "Include the `default_subspecs` values in the Podfile if any."],
|
38
38
|
["--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}", "Include all the subspecs in the Podfile if any."],
|
39
39
|
["--#{CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME}", "Let cocoapods resolve the necessary dependencies for the provided pods and include them in the Podfile."],
|
40
|
+
["--#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}", "A Podfile file to be used as the template for the final Podfile. Add the \"#{CocoapodsPodfileGenerator::TEMPLATE_KEYWORD}\" keyword (without quotes) somewhere within your template and that will be replaced with the generated targets. Example: --#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}=path/to/template_file"],
|
40
41
|
["--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}", "A text file containing the pods to add to the Podfile. Each row within the file should have the format: <POD_NAME>:<POD_VERSION>. Example: --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=path/to/file.txt"],
|
41
42
|
["--#{CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME}", "Platforms to consider. If not set, all platforms supported by the pods will be used. A target will be generated per platform. Example: --#{CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME}=ios,tvos"],
|
42
43
|
["--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}", "Path where the Podfile will be saved. If not set, the Podfile will be saved where the command is running. Example: --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=path/to/save/Podfile_name"],
|
@@ -52,6 +53,7 @@ module Pod
|
|
52
53
|
@include_default_subspecs = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME)
|
53
54
|
@include_all_subspecs = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME)
|
54
55
|
@include_analyze = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME)
|
56
|
+
@template_file = argv.option(CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME)
|
55
57
|
@pods_text_file = argv.option(CocoapodsPodfileGenerator::FILE_OPTION_NAME)
|
56
58
|
@platforms = argv.option(CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME, "").split(",")
|
57
59
|
@podfile_output_path = argv.option(CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME, "#{Dir.pwd}/Podfile")
|
@@ -62,6 +64,12 @@ module Pod
|
|
62
64
|
super
|
63
65
|
help! "You must give a Pod argument or pass a path to a text file to parse the Pods." if @pods_args.empty? && @pods_text_file.nil?
|
64
66
|
|
67
|
+
# Validate the template
|
68
|
+
if @template_file
|
69
|
+
help! "The template was not found at #{@template_file}." if not File.exist?(@template_file)
|
70
|
+
help! "The template does not contain the #{CocoapodsPodfileGenerator::TEMPLATE_KEYWORD} keyword. Add the keyword somewhere within your template." if not File.open(@template_file).each_line.any?{ |line| line.include?(CocoapodsPodfileGenerator::TEMPLATE_KEYWORD) }
|
71
|
+
end
|
72
|
+
|
65
73
|
# Parse each argument passed if any
|
66
74
|
begin
|
67
75
|
@pods_args.each { |pod| @pods.merge!(parse_line(pod)) } if not @pods_args.empty?
|
@@ -109,7 +117,11 @@ module Pod
|
|
109
117
|
specs_by_platform = get_specs_by_platform(specs)
|
110
118
|
end
|
111
119
|
|
112
|
-
|
120
|
+
if @template_file
|
121
|
+
generate_podfile_using_template(@template_file, specs_by_platform, @podfile_output_path)
|
122
|
+
else
|
123
|
+
generate_podfile_file(specs_by_platform, @podfile_output_path)
|
124
|
+
end
|
113
125
|
end
|
114
126
|
|
115
127
|
private
|
@@ -217,24 +229,40 @@ module Pod
|
|
217
229
|
end
|
218
230
|
|
219
231
|
def generate_podfile_file(specs_by_platform, path)
|
220
|
-
|
221
|
-
|
232
|
+
podfile_pathname = Pathname.new(path)
|
233
|
+
podfile_pathname.dirname.mkpath
|
234
|
+
podfile_pathname.open("a") do |file|
|
235
|
+
file.write("install! 'cocoapods', integrate_targets: false\n")
|
236
|
+
file.write("use_frameworks!\n\n")
|
237
|
+
file.write(generate_targets(specs_by_platform))
|
238
|
+
end
|
239
|
+
end
|
222
240
|
|
241
|
+
def generate_podfile_using_template(template_file, specs_by_platform, path)
|
242
|
+
podfile_pathname = Pathname.new(path)
|
243
|
+
podfile_pathname.dirname.mkpath
|
244
|
+
podfile_pathname.open("a") do |file|
|
245
|
+
File.open(@template_file).each_line do |line|
|
246
|
+
l = line.include?(CocoapodsPodfileGenerator::TEMPLATE_KEYWORD) ? generate_targets(specs_by_platform) : line
|
247
|
+
file.write(l)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def generate_targets(specs_by_platform)
|
253
|
+
targets = ""
|
223
254
|
@platforms.each do |platform|
|
224
255
|
next if specs_by_platform[platform.name].empty?
|
225
256
|
|
226
257
|
platform_version = specs_by_platform[platform.name].map { |spec| Pod::Version.new(spec.deployment_target(platform.name) || "0") }
|
227
258
|
platform_version = platform_version.max
|
228
259
|
|
229
|
-
|
230
|
-
|
231
|
-
specs_by_platform[platform.name].each { |spec|
|
232
|
-
|
260
|
+
targets += "target 'Target_for_#{platform.name}' do\n"
|
261
|
+
targets += "\tplatform :#{platform.name}, '#{platform_version}'\n"
|
262
|
+
specs_by_platform[platform.name].each { |spec| targets += "\tpod '#{spec.name}', '#{spec.version}'\n" }
|
263
|
+
targets += "end\n\n"
|
233
264
|
end
|
234
|
-
|
235
|
-
podfile_pathname = Pathname.new(path)
|
236
|
-
podfile_pathname.dirname.mkpath
|
237
|
-
podfile_pathname.write(podfile)
|
265
|
+
targets
|
238
266
|
end
|
239
267
|
end
|
240
268
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module CocoapodsPodfileGenerator
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.5.0"
|
3
3
|
SUMMARY = "A Cocoapods plugin to generate a Podfile file with the pods provided."
|
4
4
|
DESCRIPTION = <<-DESC
|
5
5
|
A Cocoapods plugin that helps you generate a Podfile file with the pods provided.
|
@@ -24,7 +24,11 @@ module CocoapodsPodfileGenerator
|
|
24
24
|
INCLUDE_ANALYZE_FLAG_NAME = "include-analyze"
|
25
25
|
|
26
26
|
# CLAide Options
|
27
|
-
|
27
|
+
TEMPLATE_OPTION_NAME = "template"
|
28
|
+
FILE_OPTION_NAME = "text-file"
|
28
29
|
PLATFORMS_OPTION_NAME = "platforms"
|
29
30
|
OUTPUT_OPTION_NAME = "output"
|
31
|
+
|
32
|
+
# Misc
|
33
|
+
TEMPLATE_KEYWORD = "{{CPG}}"
|
30
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
install! 'cocoapods', integrate_targets: false, generate_multiple_pod_projects: true
|
2
|
+
use_frameworks!
|
3
|
+
|
4
|
+
pre_install do |installer|
|
5
|
+
installer.pod_targets.each do |pod|
|
6
|
+
puts "Forcing a static_framework to false for #{pod.name}"
|
7
|
+
if Pod::VERSION >= "1.7.0"
|
8
|
+
if pod.build_as_static?
|
9
|
+
def pod.build_as_static?; false end
|
10
|
+
def pod.build_as_static_framework?; false end
|
11
|
+
def pod.build_as_dynamic?; true end
|
12
|
+
def pod.build_as_dynamic_framework?; true end
|
13
|
+
end
|
14
|
+
else
|
15
|
+
def pod.static_framework?; false end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
{{CPG}}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -13,7 +13,7 @@ module Pod
|
|
13
13
|
Command.parse(%w{ podfile }).should.be.instance_of Command::Podfile
|
14
14
|
end
|
15
15
|
|
16
|
-
describe "Validate the
|
16
|
+
describe "Validate the basics" do
|
17
17
|
it "is well-formed" do
|
18
18
|
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} }).validate! }
|
19
19
|
.should.not.raise()
|
@@ -42,40 +42,59 @@ module Pod
|
|
42
42
|
.should.raise(PodfileGeneratorInformative)
|
43
43
|
.message.should.match(/There was a problem/)
|
44
44
|
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "Validate the text file" do
|
48
|
+
it "fails when the text file given does not exist" do
|
49
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Non_existing_file.txt }).validate! }
|
50
|
+
.should.raise(CLAide::Help)
|
51
|
+
.message.should.match(/The file was not found/)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "parses a text file correctly" do
|
55
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt }).validate! }
|
56
|
+
.should.not.raise()
|
57
|
+
end
|
58
|
+
|
59
|
+
it "fails when there's a bad line to parse in a text file" do
|
60
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Bad_Pods_Format.txt }).validate! }
|
61
|
+
.should.raise(CLAide::Help)
|
62
|
+
.message.should.match(/There was a problem parsing/)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "fails when a text file does not have the .txt extension" do
|
66
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/TextFile }).validate! }
|
67
|
+
.should.raise(CLAide::Help)
|
68
|
+
.message.should.match(/should have a .txt extension./)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "fails when a Pod in a text file does not exist" do
|
72
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Non_Existing_Pod.txt }).validate! }
|
73
|
+
.should.raise(PodfileGeneratorInformative)
|
74
|
+
.message.should.match(/There was a problem/)
|
75
|
+
end
|
76
|
+
end
|
45
77
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
78
|
+
describe "Validate the template file" do
|
79
|
+
it "fails when the template given does not exist" do
|
80
|
+
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} --#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}=./spec/Templates/Non_existing_template }).validate! }
|
81
|
+
.should.raise(CLAide::Help)
|
82
|
+
.message.should.match(/The template was not found/)
|
83
|
+
end
|
52
84
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
it "fails when there's a bad line to parse in a text file" do
|
59
|
-
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Bad_Pods_Format.txt }).validate! }
|
60
|
-
.should.raise(CLAide::Help)
|
61
|
-
.message.should.match(/There was a problem parsing/)
|
62
|
-
end
|
85
|
+
it "fails when the template does not contain the keyword" do
|
86
|
+
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} --#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}=./spec/Templates/Invalid_Template }).validate! }
|
87
|
+
.should.raise(CLAide::Help)
|
88
|
+
.message.should.match(/The template does not contain/)
|
89
|
+
end
|
63
90
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
.message.should.match(/should have a .txt extension./)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "fails when a Pod in a text file does not exist" do
|
71
|
-
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Non_Existing_Pod.txt }).validate! }
|
72
|
-
.should.raise(PodfileGeneratorInformative)
|
73
|
-
.message.should.match(/There was a problem/)
|
74
|
-
end
|
91
|
+
it "is a valid template" do
|
92
|
+
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} --#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}=./spec/Templates/Podfile_Template }).validate! }
|
93
|
+
.should.not.raise
|
75
94
|
end
|
76
95
|
end
|
77
96
|
|
78
|
-
describe "
|
97
|
+
describe "Validate the functionality" do
|
79
98
|
require 'pathname'
|
80
99
|
|
81
100
|
before do
|
@@ -120,7 +139,7 @@ module Pod
|
|
120
139
|
end
|
121
140
|
|
122
141
|
it "generates the Podfile from a text file at the default path" do
|
123
|
-
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt })
|
142
|
+
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt })
|
124
143
|
podfile.validate!
|
125
144
|
podfile.run
|
126
145
|
@default_podfile_pathname.exist?.should.be.true?
|
@@ -128,7 +147,7 @@ module Pod
|
|
128
147
|
end
|
129
148
|
|
130
149
|
it "generates the Podfile from a text file at a custom path" do
|
131
|
-
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname} })
|
150
|
+
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname} })
|
132
151
|
podfile.validate!
|
133
152
|
podfile.run
|
134
153
|
@podfile_pathname.exist?.should.be.true?
|
@@ -140,7 +159,7 @@ module Pod
|
|
140
159
|
podfile = Command.parse([
|
141
160
|
"podfile",
|
142
161
|
*pod_args,
|
143
|
-
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt"
|
162
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt"
|
144
163
|
])
|
145
164
|
podfile.validate!
|
146
165
|
podfile.run
|
@@ -153,7 +172,7 @@ module Pod
|
|
153
172
|
podfile = Command.parse([
|
154
173
|
"podfile",
|
155
174
|
*pod_args,
|
156
|
-
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
175
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt",
|
157
176
|
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
158
177
|
])
|
159
178
|
podfile.validate!
|
@@ -168,7 +187,7 @@ module Pod
|
|
168
187
|
"podfile",
|
169
188
|
*pod_args,
|
170
189
|
"--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}",
|
171
|
-
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
190
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt",
|
172
191
|
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
173
192
|
])
|
174
193
|
podfile.validate!
|
@@ -183,7 +202,7 @@ module Pod
|
|
183
202
|
"podfile",
|
184
203
|
*pod_args,
|
185
204
|
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
186
|
-
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
205
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt",
|
187
206
|
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
188
207
|
])
|
189
208
|
podfile.validate!
|
@@ -199,7 +218,7 @@ module Pod
|
|
199
218
|
*pod_args,
|
200
219
|
"--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}",
|
201
220
|
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
202
|
-
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
221
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFiles/Pods.txt",
|
203
222
|
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
204
223
|
podfile.validate!
|
205
224
|
podfile.run
|
@@ -275,6 +294,21 @@ module Pod
|
|
275
294
|
@podfile_pathname.exist?.should.be.true?
|
276
295
|
@podfile_pathname.empty?.should.be.false?
|
277
296
|
end
|
297
|
+
|
298
|
+
it "generates the Podfile using a template" do
|
299
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
300
|
+
podfile = Command.parse([
|
301
|
+
"podfile",
|
302
|
+
*pod_args,
|
303
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
304
|
+
"--#{CocoapodsPodfileGenerator::TEMPLATE_OPTION_NAME}=./spec/Templates/Podfile_Template",
|
305
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
306
|
+
])
|
307
|
+
podfile.validate!
|
308
|
+
podfile.run
|
309
|
+
@podfile_pathname.exist?.should.be.true?
|
310
|
+
@podfile_pathname.empty?.should.be.false?
|
311
|
+
end
|
278
312
|
end
|
279
313
|
end
|
280
314
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-podfile-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Israel Soto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,13 +64,15 @@ files:
|
|
64
64
|
- lib/cocoapods-podfile-generator/podfilegeneratorinformative.rb
|
65
65
|
- lib/cocoapods-podfile-generator/version.rb
|
66
66
|
- lib/cocoapods_plugin.rb
|
67
|
-
- spec/
|
68
|
-
- spec/
|
69
|
-
- spec/
|
70
|
-
- spec/
|
67
|
+
- spec/Templates/Invalid_Template
|
68
|
+
- spec/Templates/Podfile_Template
|
69
|
+
- spec/TextFiles/Bad_Pods_Format.txt
|
70
|
+
- spec/TextFiles/Non_Existing_Pod.txt
|
71
|
+
- spec/TextFiles/Pods.txt
|
72
|
+
- spec/TextFiles/TextFile
|
71
73
|
- spec/command/podfile_spec.rb
|
72
74
|
- spec/spec_helper.rb
|
73
|
-
homepage: https://github.com/
|
75
|
+
homepage: https://github.com/SotoiGhost/cocoapods-podfile-generator
|
74
76
|
licenses:
|
75
77
|
- MIT
|
76
78
|
metadata: {}
|
@@ -94,9 +96,11 @@ signing_key:
|
|
94
96
|
specification_version: 4
|
95
97
|
summary: A Cocoapods plugin to generate a Podfile file with the pods provided.
|
96
98
|
test_files:
|
97
|
-
- spec/
|
98
|
-
- spec/
|
99
|
-
- spec/
|
100
|
-
- spec/
|
99
|
+
- spec/Templates/Invalid_Template
|
100
|
+
- spec/Templates/Podfile_Template
|
101
|
+
- spec/TextFiles/Bad_Pods_Format.txt
|
102
|
+
- spec/TextFiles/Non_Existing_Pod.txt
|
103
|
+
- spec/TextFiles/Pods.txt
|
104
|
+
- spec/TextFiles/TextFile
|
101
105
|
- spec/command/podfile_spec.rb
|
102
106
|
- spec/spec_helper.rb
|