redbreast 0.1.2 → 1.0.0
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 +9 -7
- data/lib/.DS_Store +0 -0
- data/lib/redbreast.rb +25 -18
- 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 +29 -29
- 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 -92
- 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 -7
- 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 +93 -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 +21 -22
- metadata +35 -11
- 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
Binary file
|
@@ -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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#import <UIKit/UIKit.h>
|
13
|
-
|
14
|
-
//THIS FILE IS AUTOGENERATED, DO NOT EDIT BY HAND
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
21
|
+
def m_template
|
22
|
+
<<~TEMPLATE
|
42
23
|
|
43
|
-
|
44
|
-
end
|
24
|
+
#import <UIKit/UIKit.h>
|
45
25
|
|
46
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
10
|
+
def template
|
11
|
+
<<~TEMPLATE
|
12
|
+
import UIKit
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def m_filename
|
12
|
+
raise NotImplementedError, 'Abstract Method'
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def h_template
|
16
|
+
raise NotImplementedError, 'Abstract Method'
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
data/lib/redbreast/version.rb
CHANGED
data/redbreast.gemspec
CHANGED
@@ -1,41 +1,40 @@
|
|
1
|
-
|
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
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
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
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
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'] =
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
19
|
else
|
21
|
-
raise
|
22
|
-
|
20
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
21
|
+
'public gem pushes.'
|
23
22
|
end
|
24
23
|
|
25
|
-
spec.files
|
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
|
29
|
-
spec.executables
|
30
|
-
spec.require_paths = [
|
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
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
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
|