redbreast 1.0.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +34 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/lib/redbreast/commands/color_generator.rb +3 -0
- data/lib/redbreast/commands/color_test_generator.rb +3 -0
- data/lib/redbreast/commands/image_generator.rb +3 -0
- data/lib/redbreast/commands/image_test_generator.rb +3 -0
- data/lib/redbreast/commands/setup.rb +15 -1
- data/lib/redbreast/helpers/general.rb +11 -0
- data/lib/redbreast/serializers/objc_serializer.rb +2 -2
- data/lib/redbreast/serializers/swift_serializer.rb +11 -9
- data/lib/redbreast/serializers/swiftui_serializer.rb +107 -0
- data/lib/redbreast/template_generators/colors/swift_colors_template_generator.rb +1 -0
- data/lib/redbreast/template_generators/colors/swiftui_colors_template_generator.rb +23 -0
- data/lib/redbreast/template_generators/images/swift_images_template_generator.rb +1 -0
- data/lib/redbreast/template_generators/images/swiftui_images_template_generator.rb +24 -0
- data/lib/redbreast/template_generators/swiftui_template_generator.rb +11 -0
- data/lib/redbreast/template_generators/tests/colors/swiftui_colors_tests_template_generator.rb +27 -0
- data/lib/redbreast/template_generators/tests/images/swiftui_images_tests_template_generator.rb +27 -0
- data/lib/redbreast/version.rb +1 -1
- data/lib/redbreast.rb +6 -0
- data/redbreast.gemspec +2 -2
- metadata +13 -10
- data/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/redbreast/.DS_Store +0 -0
- data/lib/redbreast/template_generators/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9840f88046197446fc6c9eb46afd5abe82c66fb1f48aee16827fbc00541992ef
|
4
|
+
data.tar.gz: 2dd93e1ea1cce94ff8202a472a4fff651a778cdd3e802dd9cd1a641dbabc1fdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e1622222467886c0c4e84519e0bad43ac4f82c6c8efc3d0aca75e5141d422ac9e5167227f377162b714081a7f11b102d60aaa665222a7a89d43af14146b0ed5
|
7
|
+
data.tar.gz: bdb375e6d106a93874da0ed1b3567ed43386ff68c51c76be1575ed40e3355068816bff4584cb2d4bd16b699e3aa3a1d0d07bc42ae9e84d4a10b8d99621616010
|
data/.gitignore
CHANGED
@@ -10,3 +10,37 @@
|
|
10
10
|
|
11
11
|
# rspec failure tracking
|
12
12
|
.rspec_status
|
13
|
+
|
14
|
+
# Created by https://www.toptal.com/developers/gitignore/api/macos
|
15
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
|
16
|
+
|
17
|
+
### macOS ###
|
18
|
+
# General
|
19
|
+
.DS_Store
|
20
|
+
.AppleDouble
|
21
|
+
.LSOverride
|
22
|
+
|
23
|
+
# Icon must end with two \r
|
24
|
+
Icon
|
25
|
+
|
26
|
+
|
27
|
+
# Thumbnails
|
28
|
+
._*
|
29
|
+
|
30
|
+
# Files that might appear in the root of a volume
|
31
|
+
.DocumentRevisions-V100
|
32
|
+
.fseventsd
|
33
|
+
.Spotlight-V100
|
34
|
+
.TemporaryItems
|
35
|
+
.Trashes
|
36
|
+
.VolumeIcon.icns
|
37
|
+
.com.apple.timemachine.donotpresent
|
38
|
+
|
39
|
+
# Directories potentially created on remote AFP share
|
40
|
+
.AppleDB
|
41
|
+
.AppleDesktop
|
42
|
+
Network Trash Folder
|
43
|
+
Temporary Items
|
44
|
+
.apdisk
|
45
|
+
|
46
|
+
# End of https://www.toptal.com/developers/gitignore/api/macos
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/.travis.yml
CHANGED
@@ -39,6 +39,9 @@ module Redbreast
|
|
39
39
|
when 'swift'
|
40
40
|
serializer = Redbreast::Serializer::Swift
|
41
41
|
template_generator = Redbreast::TemplateGenerator::Color::Swift
|
42
|
+
when 'swiftui'
|
43
|
+
serializer = Redbreast::Serializer::SwiftUI
|
44
|
+
template_generator = Redbreast::TemplateGenerator::Color::SwiftUI
|
42
45
|
end
|
43
46
|
serializer.new(color_names, bundle, app_name).save(output_source_path: output_path, template_generator: template_generator.new, generate_colors: true)
|
44
47
|
end
|
@@ -41,6 +41,9 @@ module Redbreast
|
|
41
41
|
when 'swift'
|
42
42
|
serializer = Redbreast::Serializer::Swift
|
43
43
|
template_generator = Redbreast::TemplateGenerator::ColorTest::Swift
|
44
|
+
when 'swiftui'
|
45
|
+
serializer = Redbreast::Serializer::SwiftUI
|
46
|
+
template_generator = Redbreast::TemplateGenerator::ColorTest::SwiftUI
|
44
47
|
end
|
45
48
|
serializer.new(color_names, bundle, app_name).save(output_source_path: output_path, template_generator: template_generator.new, generate_colors: true)
|
46
49
|
|
@@ -39,6 +39,9 @@ module Redbreast
|
|
39
39
|
when 'swift'
|
40
40
|
serializer = Redbreast::Serializer::Swift
|
41
41
|
template_generator = Redbreast::TemplateGenerator::Image::Swift
|
42
|
+
when 'swiftui'
|
43
|
+
serializer = Redbreast::Serializer::SwiftUI
|
44
|
+
template_generator = Redbreast::TemplateGenerator::Image::SwiftUI
|
42
45
|
end
|
43
46
|
serializer.new(image_names, bundle, app_name).save(output_source_path: output_path, template_generator: template_generator.new, generate_colors: false)
|
44
47
|
|
@@ -41,6 +41,9 @@ module Redbreast
|
|
41
41
|
when 'swift'
|
42
42
|
serializer = Redbreast::Serializer::Swift
|
43
43
|
template_generator = Redbreast::TemplateGenerator::ImageTest::Swift
|
44
|
+
when 'swiftui'
|
45
|
+
serializer = Redbreast::Serializer::SwiftUI
|
46
|
+
template_generator = Redbreast::TemplateGenerator::ImageTest::SwiftUI
|
44
47
|
end
|
45
48
|
serializer.new(image_names, bundle, app_name).save(output_source_path: output_path, template_generator: template_generator.new, generate_colors: false)
|
46
49
|
|
@@ -56,7 +56,7 @@ module Redbreast
|
|
56
56
|
# Language
|
57
57
|
|
58
58
|
def language_prompt
|
59
|
-
languages = { 'Swift' => 'swift', 'Objective-C' => 'objc' }
|
59
|
+
languages = { 'Swift' => 'swift', 'SwiftUI' => 'swiftui', 'Objective-C' => 'objc', }
|
60
60
|
prompt.select('Choose a language: ', languages)
|
61
61
|
end
|
62
62
|
|
@@ -76,6 +76,8 @@ module Redbreast
|
|
76
76
|
prompt.ask(prompt_text, default: 'mainBundle')
|
77
77
|
when 'swift'
|
78
78
|
prompt.ask(prompt_text, default: 'main')
|
79
|
+
when 'swiftui'
|
80
|
+
prompt.ask(prompt_text, default: 'main')
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
@@ -85,6 +87,8 @@ module Redbreast
|
|
85
87
|
"[NSBundle #{bundle_name}]"
|
86
88
|
when 'swift'
|
87
89
|
".#{bundle_name}"
|
90
|
+
when 'swiftui'
|
91
|
+
".#{bundle_name}"
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
@@ -97,6 +101,8 @@ module Redbreast
|
|
97
101
|
prompt.ask(prompt_text, default: './Common/Categories/Images')
|
98
102
|
when 'swift'
|
99
103
|
prompt.ask(prompt_text, default: './Common/Extensions/UIImageExtension.swift')
|
104
|
+
when 'swiftui'
|
105
|
+
prompt.ask(prompt_text, default: './Common/Extensions/ImageExtension.swift')
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
@@ -109,6 +115,8 @@ module Redbreast
|
|
109
115
|
prompt.ask(prompt_text, default: './Common/Categories/Colors')
|
110
116
|
when 'swift'
|
111
117
|
prompt.ask(prompt_text, default: './Common/Extensions/UIColorExtension.swift')
|
118
|
+
when 'swiftui'
|
119
|
+
prompt.ask(prompt_text, default: './Common/Extensions/ColorExtension.swift')
|
112
120
|
end
|
113
121
|
end
|
114
122
|
|
@@ -125,6 +133,8 @@ module Redbreast
|
|
125
133
|
prompt.ask(prompt_text, default: './Common/Categories/ImagesTest')
|
126
134
|
when 'swift'
|
127
135
|
prompt.ask(prompt_text, default: './Common/Extensions/UIImageExtensionTest.swift')
|
136
|
+
when 'swiftui'
|
137
|
+
prompt.ask(prompt_text, default: './Common/Extensions/ImageExtensionTest.swift')
|
128
138
|
end
|
129
139
|
end
|
130
140
|
|
@@ -135,6 +145,8 @@ module Redbreast
|
|
135
145
|
prompt.ask(prompt_text, default: './Common/Categories/ColorsTest')
|
136
146
|
when 'swift'
|
137
147
|
prompt.ask(prompt_text, default: './Common/Extensions/UIColorExtensionTest.swift')
|
148
|
+
when 'swiftui'
|
149
|
+
prompt.ask(prompt_text, default: './Common/Extensions/ColorExtensionTest.swift')
|
138
150
|
end
|
139
151
|
end
|
140
152
|
|
@@ -144,6 +156,8 @@ module Redbreast
|
|
144
156
|
nil
|
145
157
|
when 'swift'
|
146
158
|
prompt.ask("Please enter a name that will be used for testable import in #{bundle} bundle?", default: "#{app_name}", required: true)
|
159
|
+
when 'swiftui'
|
160
|
+
prompt.ask("Please enter a name that will be used for testable import in #{bundle} bundle?", default: "#{app_name}", required: true)
|
147
161
|
end
|
148
162
|
end
|
149
163
|
|
@@ -45,6 +45,17 @@ module Redbreast
|
|
45
45
|
escape_with_underscore_if_needed(clean_name)
|
46
46
|
end
|
47
47
|
|
48
|
+
def upper_camel_case(name)
|
49
|
+
clean_name = name
|
50
|
+
.split(/[^0-9a-zA-Z]/)
|
51
|
+
.reject(&:empty?)
|
52
|
+
.each_with_index
|
53
|
+
.map { |v, i| i.zero? ? v.tap { |char| char[0] = char[0].upcase } : v.capitalize }
|
54
|
+
.join
|
55
|
+
|
56
|
+
escape_with_underscore_if_needed(clean_name)
|
57
|
+
end
|
58
|
+
|
48
59
|
def clean_case_name(name)
|
49
60
|
clean_variable_name(name)
|
50
61
|
end
|
@@ -40,7 +40,7 @@ module Redbreast
|
|
40
40
|
text = ''
|
41
41
|
|
42
42
|
names.each do |name|
|
43
|
-
temp_arr = name.split('/')
|
43
|
+
temp_arr = name.split('/').map { |folder| upper_camel_case(folder) }
|
44
44
|
|
45
45
|
variable_name = temp_arr.length == 1 ? clean_variable_name(name) : temp_arr.unshift(temp_arr.shift.downcase).join('')
|
46
46
|
text += variable_declaration % variable_name + variable_implementation % [name, bundle_name[:reference]]
|
@@ -54,7 +54,7 @@ module Redbreast
|
|
54
54
|
text = ''
|
55
55
|
|
56
56
|
names.each do |name|
|
57
|
-
temp_arr = name.split('/')
|
57
|
+
temp_arr = name.split('/').map { |folder| upper_camel_case(folder) }
|
58
58
|
variable_name = temp_arr.length == 1 ? clean_variable_name(name) : temp_arr.unshift(temp_arr.shift.downcase).join('')
|
59
59
|
text += variable % variable_name
|
60
60
|
end
|
@@ -5,6 +5,7 @@ module Redbreast
|
|
5
5
|
# Used to save swift files
|
6
6
|
class Swift < Base
|
7
7
|
include Helper::General
|
8
|
+
SPACER = " "
|
8
9
|
|
9
10
|
def save(output_source_path:, template_generator:, generate_colors:)
|
10
11
|
directory = File.dirname(output_source_path)
|
@@ -14,7 +15,7 @@ module Redbreast
|
|
14
15
|
File.write(output_source_path, file)
|
15
16
|
end
|
16
17
|
|
17
|
-
def generate_file_swift(names:, spacing:
|
18
|
+
def generate_file_swift(names:, spacing: SPACER, indentation: '', variable:, bundle:)
|
18
19
|
return if names.empty?
|
19
20
|
|
20
21
|
text = ''
|
@@ -22,25 +23,25 @@ module Redbreast
|
|
22
23
|
|
23
24
|
vars, arr = generate_variables(names: names, spacing: spacing, indentation: indentation, variable: variable, bundle: bundle, text: text, array: arr)
|
24
25
|
|
25
|
-
arr = arr.uniq
|
26
|
-
|
26
|
+
arr = arr.uniq.sort_by(&:downcase)
|
27
|
+
|
27
28
|
arr.each do |enum_name|
|
28
29
|
names_new = []
|
29
30
|
names_new_enum = []
|
30
31
|
new_enum_name = enum_name
|
31
32
|
|
32
|
-
text += "\n" + spacing + 'enum ' + enum_name + ' {'
|
33
|
+
text += "\n" + spacing + 'enum ' + upper_camel_case(enum_name) + ' {'
|
33
34
|
names_new, names_new_enum = separate_variables_from_folders(names: names, enum_name: enum_name, new_enum_name: new_enum_name, names_new_enum: names_new_enum, names_new: names_new)
|
34
35
|
|
35
36
|
if !names_new_enum.empty? && new_enum_name == enum_name
|
36
37
|
indentation += indentation.empty? || indentation[-1] == '/' ? '' : '/'
|
37
|
-
text += "\n" + generate_file_swift(names: names_new_enum, spacing: spacing +
|
38
|
+
text += "\n" + generate_file_swift(names: names_new_enum, spacing: spacing + SPACER, indentation: indentation + enum_name, variable: variable, bundle: bundle)
|
38
39
|
end
|
39
40
|
|
40
41
|
unless names_new.empty?
|
41
42
|
|
42
43
|
indentation += indentation.empty? || indentation[-1] == '/' ? '' : '/'
|
43
|
-
text += generate_file_swift(names: names_new, spacing: spacing +
|
44
|
+
text += generate_file_swift(names: names_new, spacing: spacing + SPACER, indentation: indentation + enum_name, variable: variable, bundle: bundle)
|
44
45
|
end
|
45
46
|
|
46
47
|
text += "\n" + spacing + '}' + "\n"
|
@@ -53,7 +54,7 @@ module Redbreast
|
|
53
54
|
|
54
55
|
return text if app_name.nil? || app_name.empty?
|
55
56
|
|
56
|
-
text + "
|
57
|
+
text + SPACER + "enum " + app_name + " {}\n}\n\nextension " + extended_class + '.' + app_name + " {"
|
57
58
|
end
|
58
59
|
|
59
60
|
def create_swift_test_cases(names:, declaration:, app_name:)
|
@@ -64,7 +65,8 @@ module Redbreast
|
|
64
65
|
temp_array = name.split('/')
|
65
66
|
variable = temp_array.pop
|
66
67
|
additional_text = temp_array.count.zero? ? '' : '.'
|
67
|
-
|
68
|
+
|
69
|
+
text += SPACER + SPACER + declaration + app_name_text + temp_array.map { |enum| upper_camel_case(enum) }.join('.') + additional_text + clean_variable_name(variable)
|
68
70
|
text += name == names.last ? '' : "\n"
|
69
71
|
end
|
70
72
|
|
@@ -72,7 +74,7 @@ module Redbreast
|
|
72
74
|
end
|
73
75
|
|
74
76
|
def generate_variables(names:, spacing:, indentation:, bundle:, variable:, text:, array:)
|
75
|
-
names.each do |name|
|
77
|
+
names.sort_by(&:downcase).each do |name|
|
76
78
|
temp_arr = name.split('/')
|
77
79
|
|
78
80
|
if temp_arr.length != 1
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require_relative 'serializer'
|
2
|
+
|
3
|
+
module Redbreast
|
4
|
+
module Serializer
|
5
|
+
# Used to save swift files
|
6
|
+
class SwiftUI < Base
|
7
|
+
include Helper::General
|
8
|
+
|
9
|
+
def save(output_source_path:, template_generator:, generate_colors:)
|
10
|
+
directory = File.dirname(output_source_path)
|
11
|
+
FileUtils.mkdir_p directory unless File.exist? directory
|
12
|
+
|
13
|
+
file = ERB.new(template_generator.template, nil, '-').result(binding)
|
14
|
+
File.write(output_source_path, file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_file_swift(names:, spacing: "\t", indentation: '', variable:, bundle:)
|
18
|
+
return if names.empty?
|
19
|
+
|
20
|
+
text = ''
|
21
|
+
arr = []
|
22
|
+
|
23
|
+
vars, arr = generate_variables(names: names, spacing: spacing, indentation: indentation, variable: variable, bundle: bundle, text: text, array: arr)
|
24
|
+
|
25
|
+
arr = arr.uniq
|
26
|
+
|
27
|
+
arr.each do |enum_name|
|
28
|
+
names_new = []
|
29
|
+
names_new_enum = []
|
30
|
+
new_enum_name = enum_name
|
31
|
+
|
32
|
+
text += "\n" + spacing + 'enum ' + upper_camel_case(enum_name) + ' {'
|
33
|
+
names_new, names_new_enum = separate_variables_from_folders(names: names, enum_name: enum_name, new_enum_name: new_enum_name, names_new_enum: names_new_enum, names_new: names_new)
|
34
|
+
|
35
|
+
if !names_new_enum.empty? && new_enum_name == enum_name
|
36
|
+
indentation += indentation.empty? || indentation[-1] == '/' ? '' : '/'
|
37
|
+
text += "\n" + generate_file_swift(names: names_new_enum, spacing: spacing + "\t", indentation: indentation + enum_name, variable: variable, bundle: bundle)
|
38
|
+
end
|
39
|
+
|
40
|
+
unless names_new.empty?
|
41
|
+
|
42
|
+
indentation += indentation.empty? || indentation[-1] == '/' ? '' : '/'
|
43
|
+
text += generate_file_swift(names: names_new, spacing: spacing + "\t", indentation: indentation + enum_name, variable: variable, bundle: bundle)
|
44
|
+
end
|
45
|
+
|
46
|
+
text += "\n" + spacing + '}' + "\n"
|
47
|
+
end
|
48
|
+
text + vars
|
49
|
+
end
|
50
|
+
|
51
|
+
def generate_extension(extended_class, app_name)
|
52
|
+
text = 'extension ' + extended_class + " {\n"
|
53
|
+
|
54
|
+
return text if app_name.nil? || app_name.empty?
|
55
|
+
|
56
|
+
text + "\tenum " + app_name + " {}\n}\n\nextension " + extended_class + '.' + app_name + " {"
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_swift_test_cases(names:, declaration:, app_name:)
|
60
|
+
text = ''
|
61
|
+
app_name_text = app_name.nil? || app_name.empty? ? '' : app_name + '.'
|
62
|
+
|
63
|
+
names.each do |name|
|
64
|
+
temp_array = name.split('/')
|
65
|
+
variable = temp_array.pop
|
66
|
+
additional_text = temp_array.count.zero? ? '' : '.'
|
67
|
+
text += "\t\t" + declaration + app_name_text + temp_array.join('.') + additional_text + clean_variable_name(variable)
|
68
|
+
text += name == names.last ? '' : "\n"
|
69
|
+
end
|
70
|
+
|
71
|
+
text
|
72
|
+
end
|
73
|
+
|
74
|
+
def generate_variables(names:, spacing:, indentation:, bundle:, variable:, text:, array:)
|
75
|
+
names.each do |name|
|
76
|
+
temp_arr = name.split('/')
|
77
|
+
|
78
|
+
if temp_arr.length != 1
|
79
|
+
array.push(temp_arr.first)
|
80
|
+
else
|
81
|
+
name_prefix = indentation.empty? ? '' : '/'
|
82
|
+
text += "\n" + spacing + variable % [clean_variable_name(name), indentation + name_prefix + name, bundle[:reference]]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
[text, array]
|
87
|
+
end
|
88
|
+
|
89
|
+
def separate_variables_from_folders(names:, enum_name:, new_enum_name:, names_new_enum:, names_new:)
|
90
|
+
names.each do |name|
|
91
|
+
temp_arr = name.split('/')
|
92
|
+
|
93
|
+
next if temp_arr.length == 1
|
94
|
+
|
95
|
+
if temp_arr.length > 2
|
96
|
+
names_new_enum.push(temp_arr.drop(1).join('/')) if temp_arr.first == new_enum_name
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
100
|
+
names_new.push(temp_arr.drop(1).join('/')) if temp_arr[0] == enum_name
|
101
|
+
end
|
102
|
+
|
103
|
+
[names_new, names_new_enum]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -11,6 +11,7 @@ module Redbreast
|
|
11
11
|
import UIKit
|
12
12
|
|
13
13
|
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
14
|
+
// swiftlint:disable file_length type_body_length line_length superfluous_disable_command
|
14
15
|
<%= generate_extension('UIColor', app_name) %>
|
15
16
|
<%= generate_file_swift(names: asset_names, variable: 'static var %s: UIColor { return UIColor(named: "%s", in: %s, compatibleWith: nil)! }', bundle: bundle) %>
|
16
17
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../swiftui_template_generator'
|
2
|
+
|
3
|
+
module Redbreast
|
4
|
+
module TemplateGenerator
|
5
|
+
module Color
|
6
|
+
# Used for creating colors in swift.
|
7
|
+
class SwiftUI < TemplateGenerator::SwiftUI
|
8
|
+
include ERB::Util
|
9
|
+
def template
|
10
|
+
<<~TEMPLATE
|
11
|
+
import SwiftUI
|
12
|
+
|
13
|
+
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
14
|
+
// swiftlint:disable file_length type_body_length line_length superfluous_disable_command
|
15
|
+
<%= generate_extension('Color', app_name) %>
|
16
|
+
<%= generate_file_swift(names: asset_names, variable: 'static var %s: Color { Color("%s", bundle: %s) }', bundle: bundle) %>
|
17
|
+
}
|
18
|
+
TEMPLATE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -12,6 +12,7 @@ module Redbreast
|
|
12
12
|
import UIKit
|
13
13
|
|
14
14
|
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
15
|
+
// swiftlint:disable file_length type_body_length line_length superfluous_disable_command
|
15
16
|
<%= generate_extension('UIImage', app_name) %>
|
16
17
|
<%= generate_file_swift(names: asset_names, variable: 'static var %s: UIImage { return UIImage(named: "%s", in: %s, compatibleWith: nil)! }', bundle: bundle) %>
|
17
18
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../swiftui_template_generator'
|
2
|
+
|
3
|
+
module Redbreast
|
4
|
+
module TemplateGenerator
|
5
|
+
module Image
|
6
|
+
# Used for creating images in swift.
|
7
|
+
class SwiftUI < TemplateGenerator::SwiftUI
|
8
|
+
include ERB::Util
|
9
|
+
|
10
|
+
def template
|
11
|
+
<<~TEMPLATE
|
12
|
+
import SwiftUI
|
13
|
+
|
14
|
+
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
15
|
+
// swiftlint:disable file_length type_body_length line_length superfluous_disable_command
|
16
|
+
<%= generate_extension('Image', app_name) %>
|
17
|
+
<%= generate_file_swift(names: asset_names, variable: 'static var %s: Image { Image("%s", bundle: %s) }', bundle: bundle) %>
|
18
|
+
}
|
19
|
+
TEMPLATE
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/redbreast/template_generators/tests/colors/swiftui_colors_tests_template_generator.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'redbreast/template_generators/swiftui_template_generator'
|
2
|
+
|
3
|
+
module Redbreast
|
4
|
+
module TemplateGenerator
|
5
|
+
module ColorTest
|
6
|
+
# Used for creating color tests in swift.
|
7
|
+
class SwiftUI < TemplateGenerator::SwiftUI
|
8
|
+
include ERB::Util
|
9
|
+
def template
|
10
|
+
<<~TEMPLATE
|
11
|
+
import SwiftUI
|
12
|
+
import XCTest
|
13
|
+
@testable import <%= bundle[:testableImport] %>
|
14
|
+
|
15
|
+
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
16
|
+
class <%= File.basename(bundle[:outputTestPathColors], ".*") %>: XCTestCase {
|
17
|
+
|
18
|
+
func testIfColorsArePresent() {
|
19
|
+
<%= create_swift_test_cases(names: asset_names, declaration: '_ = Color.', app_name: app_name) %>
|
20
|
+
}
|
21
|
+
}
|
22
|
+
TEMPLATE
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/redbreast/template_generators/tests/images/swiftui_images_tests_template_generator.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'redbreast/template_generators/swiftui_template_generator'
|
2
|
+
|
3
|
+
module Redbreast
|
4
|
+
module TemplateGenerator
|
5
|
+
module ImageTest
|
6
|
+
# Used for creating image tests in swift.
|
7
|
+
class SwiftUI < TemplateGenerator::SwiftUI
|
8
|
+
include ERB::Util
|
9
|
+
def template
|
10
|
+
<<~TEMPLATE
|
11
|
+
import SwiftUI
|
12
|
+
import XCTest
|
13
|
+
@testable import <%= bundle[:testableImport] %>
|
14
|
+
|
15
|
+
// THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
16
|
+
class <%= File.basename(bundle[:outputTestPathImages], ".*") %>: XCTestCase {
|
17
|
+
|
18
|
+
func testIfImagesArePresent() {
|
19
|
+
<%= create_swift_test_cases(names: asset_names, declaration: '_ = Image.', app_name: app_name) %>
|
20
|
+
}
|
21
|
+
}
|
22
|
+
TEMPLATE
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/redbreast/version.rb
CHANGED
data/lib/redbreast.rb
CHANGED
@@ -27,18 +27,24 @@ require 'redbreast/crawlers/color_crawler'
|
|
27
27
|
require 'redbreast/serializers/serializer'
|
28
28
|
require 'redbreast/serializers/objc_serializer'
|
29
29
|
require 'redbreast/serializers/swift_serializer'
|
30
|
+
require 'redbreast/serializers/swiftui_serializer'
|
30
31
|
|
31
32
|
# Template generators
|
32
33
|
require 'redbreast/template_generators/objc_template_generator'
|
33
34
|
require 'redbreast/template_generators/swift_template_generator'
|
35
|
+
require 'redbreast/template_generators/swiftui_template_generator'
|
34
36
|
require 'redbreast/template_generators/images/objc_images_template_generator'
|
35
37
|
require 'redbreast/template_generators/images/swift_images_template_generator'
|
38
|
+
require 'redbreast/template_generators/images/swiftui_images_template_generator'
|
36
39
|
require 'redbreast/template_generators/colors/objc_colors_template_generator'
|
37
40
|
require 'redbreast/template_generators/colors/swift_colors_template_generator'
|
41
|
+
require 'redbreast/template_generators/colors/swiftui_colors_template_generator'
|
38
42
|
require 'redbreast/template_generators/tests/colors/objc_colors_tests_template_generator'
|
39
43
|
require 'redbreast/template_generators/tests/colors/swift_colors_tests_template_generator'
|
44
|
+
require 'redbreast/template_generators/tests/colors/swiftui_colors_tests_template_generator'
|
40
45
|
require 'redbreast/template_generators/tests/images/objc_images_tests_template_generator'
|
41
46
|
require 'redbreast/template_generators/tests/images/swift_images_tests_template_generator'
|
47
|
+
require 'redbreast/template_generators/tests/images/swiftui_images_tests_template_generator'
|
42
48
|
|
43
49
|
# Error Handler
|
44
50
|
require 'redbreast/error_handler'
|
data/redbreast.gemspec
CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.add_development_dependency 'bundler', '~>
|
32
|
-
spec.add_development_dependency 'rake', '~>
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
34
|
spec.add_development_dependency 'rubocop', '~> 0.77'
|
35
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redbreast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maroje
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,10 +130,10 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
-
- ".DS_Store"
|
134
133
|
- ".gitignore"
|
135
134
|
- ".rspec"
|
136
135
|
- ".rubocop.yml"
|
136
|
+
- ".ruby-version"
|
137
137
|
- ".travis.yml"
|
138
138
|
- CODE_OF_CONDUCT.md
|
139
139
|
- Gemfile
|
@@ -143,9 +143,7 @@ files:
|
|
143
143
|
- bin/console
|
144
144
|
- bin/setup
|
145
145
|
- exe/redbreast
|
146
|
-
- lib/.DS_Store
|
147
146
|
- lib/redbreast.rb
|
148
|
-
- lib/redbreast/.DS_Store
|
149
147
|
- lib/redbreast/commands/color_generator.rb
|
150
148
|
- lib/redbreast/commands/color_test_generator.rb
|
151
149
|
- lib/redbreast/commands/configuration_installer.rb
|
@@ -162,17 +160,22 @@ files:
|
|
162
160
|
- lib/redbreast/serializers/objc_serializer.rb
|
163
161
|
- lib/redbreast/serializers/serializer.rb
|
164
162
|
- lib/redbreast/serializers/swift_serializer.rb
|
165
|
-
- lib/redbreast/
|
163
|
+
- lib/redbreast/serializers/swiftui_serializer.rb
|
166
164
|
- lib/redbreast/template_generators/colors/objc_colors_template_generator.rb
|
167
165
|
- lib/redbreast/template_generators/colors/swift_colors_template_generator.rb
|
166
|
+
- lib/redbreast/template_generators/colors/swiftui_colors_template_generator.rb
|
168
167
|
- lib/redbreast/template_generators/images/objc_images_template_generator.rb
|
169
168
|
- lib/redbreast/template_generators/images/swift_images_template_generator.rb
|
169
|
+
- lib/redbreast/template_generators/images/swiftui_images_template_generator.rb
|
170
170
|
- lib/redbreast/template_generators/objc_template_generator.rb
|
171
171
|
- lib/redbreast/template_generators/swift_template_generator.rb
|
172
|
+
- lib/redbreast/template_generators/swiftui_template_generator.rb
|
172
173
|
- lib/redbreast/template_generators/tests/colors/objc_colors_tests_template_generator.rb
|
173
174
|
- lib/redbreast/template_generators/tests/colors/swift_colors_tests_template_generator.rb
|
175
|
+
- lib/redbreast/template_generators/tests/colors/swiftui_colors_tests_template_generator.rb
|
174
176
|
- lib/redbreast/template_generators/tests/images/objc_images_tests_template_generator.rb
|
175
177
|
- lib/redbreast/template_generators/tests/images/swift_images_tests_template_generator.rb
|
178
|
+
- lib/redbreast/template_generators/tests/images/swiftui_images_tests_template_generator.rb
|
176
179
|
- lib/redbreast/version.rb
|
177
180
|
- redbreast.gemspec
|
178
181
|
homepage: https://github.com/infinum/redbreast
|
data/.DS_Store
DELETED
Binary file
|
data/lib/.DS_Store
DELETED
Binary file
|
data/lib/redbreast/.DS_Store
DELETED
Binary file
|
Binary file
|