redbreast 0.1.2 → 1.0.0

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 +9 -7
  8. data/lib/.DS_Store +0 -0
  9. data/lib/redbreast.rb +25 -18
  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 +29 -29
  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 -92
  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 -7
  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 +93 -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 +21 -22
  40. metadata +35 -11
  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
@@ -0,0 +1,35 @@
1
+ require_relative '../objc_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module Color
6
+ # Used for creating colors in objective-c.
7
+ class ObjC < TemplateGenerator::ObjC
8
+ include ERB::Util
9
+ def h_template
10
+ <<~TEMPLATE
11
+
12
+ #import <UIKit/UIKit.h>
13
+
14
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
15
+ <%= generate_category('interface', 'UIColor', app_name) %>
16
+ <%= generate_h_file_objc(names: asset_names, variable: '+ (UIColor *)%s;\n')%>
17
+ @end
18
+ TEMPLATE
19
+ end
20
+
21
+ def m_template
22
+ <<~TEMPLATE
23
+
24
+ #import <UIKit/UIKit.h>
25
+
26
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
27
+ <%= generate_category('implementation', 'UIColor', app_name) %>
28
+ <%= generate_m_file_objc(names: asset_names, variable_declaration: '+ (UIColor *)%s\n{', variable_implementation: '\n\treturn [UIColor colorNamed:@"%s" inBundle:%s compatibleWithTraitCollection:nil];\n}\n', bundle_name: bundle) %>
29
+ @end
30
+ TEMPLATE
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../swift_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module Color
6
+ # Used for creating colors in swift.
7
+ class Swift < TemplateGenerator::Swift
8
+ include ERB::Util
9
+ def template
10
+ <<~TEMPLATE
11
+ import UIKit
12
+
13
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
14
+ <%= generate_extension('UIColor', app_name) %>
15
+ <%= generate_file_swift(names: asset_names, variable: 'static var %s: UIColor { return UIColor(named: "%s", in: %s, compatibleWith: nil)! }', bundle: bundle) %>
16
+ }
17
+ TEMPLATE
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,49 +1,35 @@
1
1
  require_relative '../objc_template_generator'
2
2
 
3
3
  module Redbreast
4
- module TemplateGenerator
5
- module Image
6
- class ObjC < Redbreast::TemplateGenerator::ObjC
7
- include ERB::Util
8
-
9
- def h_template()
10
- <<-TEMPLATE
11
-
12
- #import <UIKit/UIKit.h>
13
-
14
- //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
15
- @interface UIImage (<%= File.basename(bundle[:outputSourcePath]) %>)
16
-
17
- <%- image_names.each do |name| -%>
18
- + (instancetype)<%= clean_variable_name(name) %>;
19
- <%- end -%>
20
-
21
- @end
22
-
23
- TEMPLATE
24
- end
25
-
26
- def m_template()
27
- <<-TEMPLATE
28
-
29
- #import <UIKit/UIKit.h>
30
-
31
- //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
32
- @implementation UIImage (<%= File.basename(bundle[:outputSourcePath]) %>)
33
-
34
- <%- image_names.each do |name| -%>
35
- +(instancetype)<%= clean_variable_name(name) %>
36
- {
37
- [UIImage imageNamed:@"<%= name %>" inBundle:<%= bundle[:reference] %> compatibleWithTraitCollection:nil];
38
- }
39
- <%- end -%>
4
+ module TemplateGenerator
5
+ module Image
6
+ # Used for creating images in objective-c.
7
+ class ObjC < TemplateGenerator::ObjC
8
+ include ERB::Util
9
+ def h_template
10
+ <<~TEMPLATE
11
+
12
+ #import <UIKit/UIKit.h>
13
+
14
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
15
+ <%= generate_category('interface', 'UIImage', app_name) %>
16
+ <%= generate_h_file_objc(names: asset_names, variable: '+ (UIColor *)%s;\n')%>
17
+ @end
18
+ TEMPLATE
19
+ end
40
20
 
41
- @end
21
+ def m_template
22
+ <<~TEMPLATE
42
23
 
43
- TEMPLATE
44
- end
24
+ #import <UIKit/UIKit.h>
45
25
 
46
- end
26
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
27
+ <%= generate_category('implementation', 'UIImage', app_name) %>
28
+ <%= generate_m_file_objc(names: asset_names, variable_declaration: '+ (UIImage *)%s\n{', variable_implementation: '\n\treturn [UIColor imageNamed:@"%s" inBundle:%s compatibleWithTraitCollection:nil];\n}\n', bundle_name: bundle) %>
29
+ @end
30
+ TEMPLATE
47
31
  end
32
+ end
48
33
  end
49
- end
34
+ end
35
+ end
@@ -1,28 +1,23 @@
1
- require_relative '../swift_template_generator'
1
+ require_relative '../swift_template_generator'
2
2
 
3
3
  module Redbreast
4
- module TemplateGenerator
5
- module Image
6
- class Swift < TemplateGenerator::Swift
7
- include ERB::Util
4
+ module TemplateGenerator
5
+ module Image
6
+ # Used for creating images in swift.
7
+ class Swift < TemplateGenerator::Swift
8
+ include ERB::Util
8
9
 
9
- def template()
10
- <<-TEMPLATE
10
+ def template
11
+ <<~TEMPLATE
12
+ import UIKit
11
13
 
12
- import UIKit
13
-
14
- //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
15
- extension UIImage {
16
-
17
- <%- image_names.each do |name| -%>
18
- static var <%= clean_variable_name(name) %>: UIImage { return UIImage(named: "<%= name %>", in: <%= bundle[:reference] %>, compatibleWith: nil)! }
19
- <%- end -%>
20
-
21
- }
22
-
23
- TEMPLATE
24
- end
25
- end
14
+ //THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
15
+ <%= generate_extension('UIImage', app_name) %>
16
+ <%= generate_file_swift(names: asset_names, variable: 'static var %s: UIImage { return UIImage(named: "%s", in: %s, compatibleWith: nil)! }', bundle: bundle) %>
17
+ }
18
+ TEMPLATE
26
19
  end
20
+ end
27
21
  end
22
+ end
28
23
  end
@@ -1,24 +1,24 @@
1
+
1
2
  module Redbreast
2
- module TemplateGenerator
3
- class ObjC
4
- include ERB::Util
5
-
6
- def h_filename()
7
- fail NotImplementedError, 'Abstract Method'
8
- end
3
+ module TemplateGenerator
4
+ # Class for creating ObjC templates
5
+ class ObjC
6
+ include ERB::Util
7
+ def h_filename
8
+ raise NotImplementedError, 'Abstract Method'
9
+ end
9
10
 
10
- def m_filename()
11
- fail NotImplementedError, 'Abstract Method'
12
- end
11
+ def m_filename
12
+ raise NotImplementedError, 'Abstract Method'
13
+ end
13
14
 
14
- def h_template()
15
- fail NotImplementedError, 'Abstract Method'
16
- end
15
+ def h_template
16
+ raise NotImplementedError, 'Abstract Method'
17
+ end
17
18
 
18
- def m_template()
19
- fail NotImplementedError, 'Abstract Method'
20
- end
21
-
22
- end
19
+ def m_template
20
+ raise NotImplementedError, 'Abstract Method'
21
+ end
23
22
  end
24
- end
23
+ end
24
+ end
@@ -1,12 +1,11 @@
1
1
  module Redbreast
2
- module TemplateGenerator
3
- class Swift
4
- include ERB::Util
5
-
6
- def template()
7
- fail NotImplementedError, 'Abstract Method'
8
- end
9
-
10
- end
2
+ module TemplateGenerator
3
+ # Class for creating Swift templates
4
+ class Swift
5
+ include ERB::Util
6
+ def template
7
+ raise NotImplementedError, 'Abstract Method'
8
+ end
11
9
  end
12
- end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require 'redbreast/template_generators/objc_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module ColorTest
6
+ # Used for creating color tests in objective-c.
7
+ class ObjC < TemplateGenerator::ObjC
8
+ include ERB::Util
9
+ def h_template
10
+ nil
11
+ end
12
+
13
+ def m_template
14
+ <<~TEMPLATE
15
+
16
+ #import <XCTest/XCTest.h>
17
+ #import "UIColor+<%= app_name.nil? ? "Common" : app_name %>.h"
18
+
19
+ @interface <%= File.basename(bundle[:outputTestPathColors]) %> : XCTestCase
20
+
21
+ @end
22
+
23
+ @implementation Test
24
+
25
+ - (void)testExample
26
+ {<%= create_objc_test_cases(names: asset_names, variable: '\n\t[UIColor %s];')%>
27
+ }
28
+
29
+ @end
30
+ TEMPLATE
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ require 'redbreast/template_generators/swift_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module ColorTest
6
+ # Used for creating color tests in swift.
7
+ class Swift < TemplateGenerator::Swift
8
+ include ERB::Util
9
+ def template
10
+ <<~TEMPLATE
11
+ import UIKit
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: '_ = UIColor.', app_name: app_name) %>
20
+ }
21
+ }
22
+ TEMPLATE
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'redbreast/template_generators/objc_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module ImageTest
6
+ # Used for creating image tests in objective-c.
7
+ class ObjC < TemplateGenerator::ObjC
8
+ include ERB::Util
9
+ def h_template
10
+ nil
11
+ end
12
+
13
+ def m_template
14
+ <<~TEMPLATE
15
+
16
+ #import <XCTest/XCTest.h>
17
+ #import "UIImage+<%= app_name.nil? ? "Common" : app_name %>.h"
18
+
19
+ @interface <%= File.basename(bundle[:outputTestPathImages]) %> : XCTestCase
20
+
21
+ @end
22
+
23
+ @implementation Test
24
+
25
+ - (void)testExample
26
+ {<%= create_objc_test_cases(names: asset_names, variable: '\n\t[UIImage %s];')%>
27
+ }
28
+
29
+ @end
30
+ TEMPLATE
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,27 @@
1
+ require 'redbreast/template_generators/swift_template_generator'
2
+
3
+ module Redbreast
4
+ module TemplateGenerator
5
+ module ImageTest
6
+ # Used for creating image tests in swift.
7
+ class Swift < TemplateGenerator::Swift
8
+ include ERB::Util
9
+ def template
10
+ <<~TEMPLATE
11
+ import UIKit
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: '_ = UIImage.', app_name: app_name) %>
20
+ }
21
+ }
22
+ TEMPLATE
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Redbreast
2
- VERSION = "0.1.2"
2
+ VERSION = '1.0.0'
3
3
  end
data/redbreast.gemspec CHANGED
@@ -1,41 +1,40 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'redbreast/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "redbreast"
8
- spec.version = Redbreast::VERSION
9
- spec.authors = ["Vlaho"]
10
- spec.email = ["vlaho.poluta@infinum.hr"]
6
+ spec.name = 'redbreast'
7
+ spec.version = Redbreast::VERSION
8
+ spec.authors = ['Maroje']
9
+ spec.email = ['maroje.marcelic@infinum.com']
11
10
 
12
- spec.summary = "A CLI for safe and strongly typed resources"
13
- spec.homepage = "https://github.com/infinum/redbreast"
14
- spec.license = "MIT"
11
+ spec.summary = 'A CLI for safe and strongly typed resources'
12
+ spec.homepage = 'https://github.com/infinum/redbreast'
13
+ spec.license = 'MIT'
15
14
 
16
15
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
16
  # to allow pushing to a single host or delete this section to allow pushing to any host.
18
17
  if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
18
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
19
  else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
20
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
21
+ 'public gem pushes.'
23
22
  end
24
23
 
25
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
25
  f.match(%r{^(test|spec|features)/})
27
26
  end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
31
30
 
32
- spec.add_development_dependency "bundler", "~> 1.14"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency 'bundler', '~> 1.14'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.77'
35
35
 
36
- spec.add_dependency 'tty-prompt'
37
- spec.add_dependency 'commander'
38
36
  spec.add_dependency 'activesupport'
37
+ spec.add_dependency 'commander'
38
+ spec.add_dependency 'tty-prompt'
39
39
  spec.add_dependency 'xcodeproj'
40
-
41
40
  end