redbreast 0.1.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.DS_Store +0 -0
- data/.rubocop.yml +5 -0
- data/README.md +102 -4
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/exe/redbreast +17 -5
- data/lib/.DS_Store +0 -0
- data/lib/redbreast.rb +25 -17
- data/lib/redbreast/.DS_Store +0 -0
- data/lib/redbreast/commands/color_generator.rb +54 -0
- data/lib/redbreast/commands/color_test_generator.rb +57 -0
- data/lib/redbreast/commands/configuration_installer.rb +37 -0
- data/lib/redbreast/commands/image_generator.rb +49 -47
- data/lib/redbreast/commands/image_test_generator.rb +57 -0
- data/lib/redbreast/commands/setup.rb +139 -91
- data/lib/redbreast/crawlers/color_crawler.rb +38 -0
- data/lib/redbreast/crawlers/image_crawler.rb +30 -10
- data/lib/redbreast/error_handler.rb +7 -6
- data/lib/redbreast/helpers/general.rb +73 -63
- data/lib/redbreast/helpers/hash.rb +8 -8
- data/lib/redbreast/helpers/terminal.rb +2 -3
- data/lib/redbreast/io/config.rb +14 -15
- data/lib/redbreast/serializers/objc_serializer.rb +66 -19
- data/lib/redbreast/serializers/serializer.rb +17 -16
- data/lib/redbreast/serializers/swift_serializer.rb +90 -2
- data/lib/redbreast/template_generators/.DS_Store +0 -0
- data/lib/redbreast/template_generators/colors/objc_colors_template_generator.rb +35 -0
- data/lib/redbreast/template_generators/colors/swift_colors_template_generator.rb +22 -0
- data/lib/redbreast/template_generators/images/objc_images_template_generator.rb +27 -41
- data/lib/redbreast/template_generators/images/swift_images_template_generator.rb +16 -21
- data/lib/redbreast/template_generators/objc_template_generator.rb +19 -19
- data/lib/redbreast/template_generators/swift_template_generator.rb +9 -10
- data/lib/redbreast/template_generators/tests/colors/objc_colors_tests_template_generator.rb +35 -0
- data/lib/redbreast/template_generators/tests/colors/swift_colors_tests_template_generator.rb +27 -0
- data/lib/redbreast/template_generators/tests/images/objc_images_tests_template_generator.rb +36 -0
- data/lib/redbreast/template_generators/tests/images/swift_images_tests_template_generator.rb +27 -0
- data/lib/redbreast/version.rb +1 -1
- data/redbreast.gemspec +22 -22
- metadata +54 -15
- data/lib/redbreast/commands/test_generator.rb +0 -56
- data/lib/redbreast/template_generators/tests/objc_tests_template_generator.rb +0 -39
- data/lib/redbreast/template_generators/tests/swift_tests_template_generator.rb +0 -31
@@ -1,56 +0,0 @@
|
|
1
|
-
module Redbreast
|
2
|
-
module Command
|
3
|
-
class TestGenerator
|
4
|
-
include Helper::Terminal
|
5
|
-
include Helper::General
|
6
|
-
|
7
|
-
def self.init
|
8
|
-
new.call
|
9
|
-
end
|
10
|
-
|
11
|
-
def call
|
12
|
-
filtered_bundles = bundles.select { |bundle| bundle[:outputTestPath] }
|
13
|
-
return if filtered_bundles.empty?
|
14
|
-
|
15
|
-
prompt.say("Generating test resources...")
|
16
|
-
generate_test_sources(bundles, programming_language)
|
17
|
-
success("Test resources generated!")
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def generate_test_sources(bundles, programming_language)
|
23
|
-
bundles.each do |bundle|
|
24
|
-
image_names = pull_asset_names(bundle[:assetsSearchPath])
|
25
|
-
|
26
|
-
write_tests(image_names, bundle, programming_language)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Serializing data
|
31
|
-
|
32
|
-
def write_tests(image_names, bundle, programming_language)
|
33
|
-
output_path = bundle[:outputTestPath]
|
34
|
-
return if output_path.to_s.empty?
|
35
|
-
case programming_language.downcase
|
36
|
-
when "objc"
|
37
|
-
serializer = Redbreast::Serializer::ObjC
|
38
|
-
template_generator = Redbreast::TemplateGenerator::Test::ObjC
|
39
|
-
when "swift"
|
40
|
-
serializer = Redbreast::Serializer::Swift
|
41
|
-
template_generator = Redbreast::TemplateGenerator::Test::Swift
|
42
|
-
end
|
43
|
-
serializer.new(image_names, bundle).save(output_path, template_generator.new)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Pulling data
|
47
|
-
|
48
|
-
def pull_asset_names(assetsSearchPath)
|
49
|
-
Redbreast::Crawler::Image
|
50
|
-
.image_names_uniq(assetsSearchPath)
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require_relative '../objc_template_generator'
|
2
|
-
|
3
|
-
module Redbreast
|
4
|
-
module TemplateGenerator
|
5
|
-
module Test
|
6
|
-
class ObjC < TemplateGenerator::ObjC
|
7
|
-
include ERB::Util
|
8
|
-
|
9
|
-
def h_template()
|
10
|
-
nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def m_template()
|
14
|
-
<<-TEMPLATE
|
15
|
-
|
16
|
-
#import <XCTest/XCTest.h>
|
17
|
-
#import <"UIImage+<%= File.basename(bundle[:outputSourcePath]) %>.h">
|
18
|
-
|
19
|
-
@interface <%= File.basename(bundle[:outputTestPath]) %> : XCTestCase
|
20
|
-
|
21
|
-
@end
|
22
|
-
|
23
|
-
@implementation Test
|
24
|
-
|
25
|
-
- (void)testExample {
|
26
|
-
<%- image_names.each do |name| -%>
|
27
|
-
[UIImage clean_variable_name(name)];
|
28
|
-
<%- end -%>
|
29
|
-
}
|
30
|
-
|
31
|
-
@end
|
32
|
-
|
33
|
-
TEMPLATE
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative '../swift_template_generator'
|
2
|
-
|
3
|
-
module Redbreast
|
4
|
-
module TemplateGenerator
|
5
|
-
module Test
|
6
|
-
class Swift < TemplateGenerator::Swift
|
7
|
-
include ERB::Util
|
8
|
-
|
9
|
-
def template()
|
10
|
-
<<-TEMPLATE
|
11
|
-
|
12
|
-
import UIKit
|
13
|
-
@testable import <%= bundle[:testableImport] %>
|
14
|
-
|
15
|
-
//THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
16
|
-
class <%= File.basename(bundle[:outputTestPath], ".*") %>: XCTestCase {
|
17
|
-
|
18
|
-
func testIfImagesArePresent() {
|
19
|
-
<%- image_names.each do |name| -%>
|
20
|
-
_ = UIImage.<%= clean_variable_name(name) %>
|
21
|
-
<%- end -%>
|
22
|
-
}
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
TEMPLATE
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|