redbreast 0.1.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.DS_Store +0 -0
  3. data/.rubocop.yml +5 -0
  4. data/README.md +102 -4
  5. data/Rakefile +3 -3
  6. data/bin/console +3 -3
  7. data/exe/redbreast +17 -5
  8. data/lib/.DS_Store +0 -0
  9. data/lib/redbreast.rb +25 -17
  10. data/lib/redbreast/.DS_Store +0 -0
  11. data/lib/redbreast/commands/color_generator.rb +54 -0
  12. data/lib/redbreast/commands/color_test_generator.rb +57 -0
  13. data/lib/redbreast/commands/configuration_installer.rb +37 -0
  14. data/lib/redbreast/commands/image_generator.rb +49 -47
  15. data/lib/redbreast/commands/image_test_generator.rb +57 -0
  16. data/lib/redbreast/commands/setup.rb +139 -91
  17. data/lib/redbreast/crawlers/color_crawler.rb +38 -0
  18. data/lib/redbreast/crawlers/image_crawler.rb +30 -10
  19. data/lib/redbreast/error_handler.rb +7 -6
  20. data/lib/redbreast/helpers/general.rb +73 -63
  21. data/lib/redbreast/helpers/hash.rb +8 -8
  22. data/lib/redbreast/helpers/terminal.rb +2 -3
  23. data/lib/redbreast/io/config.rb +14 -15
  24. data/lib/redbreast/serializers/objc_serializer.rb +66 -19
  25. data/lib/redbreast/serializers/serializer.rb +17 -16
  26. data/lib/redbreast/serializers/swift_serializer.rb +90 -2
  27. data/lib/redbreast/template_generators/.DS_Store +0 -0
  28. data/lib/redbreast/template_generators/colors/objc_colors_template_generator.rb +35 -0
  29. data/lib/redbreast/template_generators/colors/swift_colors_template_generator.rb +22 -0
  30. data/lib/redbreast/template_generators/images/objc_images_template_generator.rb +27 -41
  31. data/lib/redbreast/template_generators/images/swift_images_template_generator.rb +16 -21
  32. data/lib/redbreast/template_generators/objc_template_generator.rb +19 -19
  33. data/lib/redbreast/template_generators/swift_template_generator.rb +9 -10
  34. data/lib/redbreast/template_generators/tests/colors/objc_colors_tests_template_generator.rb +35 -0
  35. data/lib/redbreast/template_generators/tests/colors/swift_colors_tests_template_generator.rb +27 -0
  36. data/lib/redbreast/template_generators/tests/images/objc_images_tests_template_generator.rb +36 -0
  37. data/lib/redbreast/template_generators/tests/images/swift_images_tests_template_generator.rb +27 -0
  38. data/lib/redbreast/version.rb +1 -1
  39. data/redbreast.gemspec +22 -22
  40. metadata +54 -15
  41. data/lib/redbreast/commands/test_generator.rb +0 -56
  42. data/lib/redbreast/template_generators/tests/objc_tests_template_generator.rb +0 -39
  43. 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