spec_handler 1.0.1

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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/spec_handler.rb +81 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5ffdc786369e26be7b370deefaf07d165b6bab0b
4
+ data.tar.gz: 000567af61c3556f697d5028fd18c7701cdb6174
5
+ SHA512:
6
+ metadata.gz: 11bb7decd388de2507161e48a97c0882df5e95689ea8fcaa276f0bea09d837a300dc28692aabe6a19be046739c1748092c16285c385a0e09d460474e54b6df0d
7
+ data.tar.gz: 983d9677120b8e65fcdfde4f3a6d48ac46886f8c640ca342c4c38442198ae55fc8c281437d756305fe99ff50ba143ef10af7c5c4a8517e2ad76dccec613146b9
@@ -0,0 +1,81 @@
1
+ require 'benchmark'
2
+
3
+ class SpecHandler < Pod::Spec
4
+ #SpecHandler created by Frederico Novack (fredynovack@gmail.com)
5
+ def initialize(path, spec, folder_name)
6
+ @path = path
7
+ @spec = spec
8
+ @folder_name = folder_name
9
+ end
10
+
11
+ def compile()
12
+ time = Benchmark.measure {
13
+ if self.path_is_valid(@path)
14
+ puts "> SpecHandler: Will Compile #{@folder_name} Recursively"
15
+ self.subspec_path(@path, @spec)
16
+ else
17
+ puts "> SpecHandler: Will Compile #{@folder_name} with expression"
18
+ spec.source_files = @folder_name + '/Source/**/*.swift'
19
+ spec.resource = @folder_name + '/**/*.{xib,xcassets}'
20
+ end
21
+ }
22
+ puts "Compiled #{@folder_name} in > %.3f seconds 😃" % time.real
23
+
24
+ end
25
+
26
+ def path_is_valid(path)
27
+ begin
28
+ Dir.entries(path)
29
+ rescue
30
+ return false
31
+ end
32
+ true
33
+ end
34
+
35
+ def format_path_for_spec(path)
36
+ if path[0] == '.' && path[1] == '/'
37
+ path[0] = ""
38
+ path[0] = ""
39
+ end
40
+ path
41
+ end
42
+
43
+ def number_of_files(path)
44
+ workable_extensions = ['.swift', '.xib', '.xcassets']
45
+ files_and_folders = Dir.entries(path)
46
+ files_array = files_and_folders.select {|element| element.include?('.swift') || element.include?('.xib') || element.include?('.xcassets')}
47
+ files_array.count
48
+ end
49
+
50
+ def remove_black_list_folders_and_files(foldersArray)
51
+ black_list = ['.', '..', '.DS_Store']
52
+ black_list.each do |item_to_remove|
53
+ foldersArray.delete(item_to_remove)
54
+ end
55
+ foldersArray = foldersArray.select {|a| !a.include?('.')}
56
+ foldersArray
57
+ end
58
+
59
+ def subspec_path(current_path, spec)
60
+ path_folders = remove_black_list_folders_and_files(Dir.entries(current_path))
61
+ subspec_name = current_path.split('/').last.gsub(' ','').to_s
62
+ if path_folders.count == 0
63
+ spec.subspec subspec_name do |theSubspec|
64
+ theSubspec.source_files = self.format_path_for_spec(current_path) + '/*.swift'
65
+ theSubspec.resource = self.format_path_for_spec(current_path) + '/*.{xib,xcassets}'
66
+ end
67
+ else
68
+ spec.subspec subspec_name do |theSubspec|
69
+ if self.number_of_files(current_path) > 0
70
+ theSubspec.source_files = self.format_path_for_spec(current_path) + '/*.swift'
71
+ theSubspec.resource = self.format_path_for_spec(current_path) + '/*.{xib,xcassets}'
72
+ end
73
+
74
+ path_folders.each do |sub_folder|
75
+ self.subspec_path(current_path + '/' + sub_folder, theSubspec)
76
+ end
77
+ end
78
+ end
79
+
80
+ end
81
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spec_handler
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Frederico Novack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A quite simple gem which helps your podspec compile your swift code.
14
+ It organizes the folders when building on xcode.
15
+ email: fredynovack@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/spec_handler.rb
21
+ homepage: http://rubygems.org/gems/spec_handler
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.14
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Compile you swift pod organizing your folders.
45
+ test_files: []