objc-referee 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +21 -3
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +1 -1
- data/README.md +17 -4
- data/lib/referee/cli.rb +22 -1
- data/lib/referee/codegenerator.rb +27 -3
- data/lib/referee/configuration.rb +2 -1
- data/lib/referee/project.rb +1 -1
- data/lib/referee/renderable.rb +32 -1
- data/lib/referee/renderables/collectioncell.rb +5 -0
- data/lib/referee/renderables/segue.rb +5 -0
- data/lib/referee/renderables/storyboard.rb +13 -2
- data/lib/referee/renderables/tablecell.rb +5 -0
- data/lib/referee/renderables/viewcontroller.rb +13 -3
- data/lib/referee/resourcegroup.rb +5 -4
- data/lib/referee/templaterenderer.rb +6 -0
- data/lib/referee/version.rb +1 -1
- data/objc-referee.gemspec +2 -0
- data/resources/default.swift +43 -0
- data/resources/implementation.m +2 -0
- data/resources/interface.h +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f60008ff9e0157920cdbf6c4404e6414e56893a8
|
4
|
+
data.tar.gz: cde3171f49c6a231cb1df75c098fe3672151c016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52d9458d5bc961f6d7aebcdb5dd5e90f81b1fd93cd45b64a8cb6f4f31240df2b92cbcdd7cbde8db1792bd77e026323df646aa0c2ed2c394103b1890070b3d30b
|
7
|
+
data.tar.gz: 5361f120a1d0acd261a9011b856696f66b963490febcffcf86b4e30f8b4a77d146a763b05d505640fc9e4187d3bc60c8ea427b2928f93ccb88f8918877e8c37c
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2015-
|
3
|
+
# on 2015-11-04 13:39:32 -0500 using RuboCop version 0.33.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -8,9 +8,27 @@
|
|
8
8
|
|
9
9
|
# Offense count: 3
|
10
10
|
Metrics/AbcSize:
|
11
|
-
Max:
|
11
|
+
Max: 33
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
Metrics/CyclomaticComplexity:
|
15
|
+
Max: 11
|
16
|
+
|
17
|
+
# Offense count: 2
|
18
|
+
# Configuration parameters: AllowURI, URISchemes.
|
19
|
+
Metrics/LineLength:
|
20
|
+
Max: 138
|
12
21
|
|
13
22
|
# Offense count: 3
|
14
23
|
# Configuration parameters: CountComments.
|
15
24
|
Metrics/MethodLength:
|
16
|
-
Max:
|
25
|
+
Max: 40
|
26
|
+
|
27
|
+
# Offense count: 1
|
28
|
+
# Configuration parameters: CountKeywordArgs.
|
29
|
+
Metrics/ParameterLists:
|
30
|
+
Max: 6
|
31
|
+
|
32
|
+
# Offense count: 1
|
33
|
+
Metrics/PerceivedComplexity:
|
34
|
+
Max: 11
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,21 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/) and this file attempts to follow the guidelines provided by [Keep a CHANGELOG](http://keepachangelog.com/).
|
4
4
|
|
5
|
+
## [Unreleased][unreleased]
|
6
|
+
Coming soon.
|
7
|
+
|
8
|
+
## [0.2.0] - 2015-09-02
|
9
|
+
### Added
|
10
|
+
- Ensures Gemspec has a minimum Ruby version. Choosing 2.x, as this is default on Yosemite machines.
|
11
|
+
- Adds in Swift code generation via `--language swift`. To keep compatibility with older versions, the default is still `objc`. Swift code generation will output a file `Resources.swift`.
|
12
|
+
- An autogeneration warning has been added to the output files. Notes that changes to the given files will eventually be lost.
|
13
|
+
- Ability to specify the `NSBundle` the resources should be accessed from. Handy for developing frameworks with resources.
|
14
|
+
- By default (if no bundle is specified) the main bundle will be used.
|
15
|
+
- The `--bundle-id` flag can set a custom bundle ID.
|
16
|
+
|
5
17
|
## [0.1.1] - 2015-09-02
|
6
18
|
Initial public release.
|
7
19
|
|
8
|
-
[
|
20
|
+
[unreleased]: https://github.com/dynamit/referee/compare/0.2.0...HEAD
|
21
|
+
[0.2.0]: https://github.com/dynamit/referee/compare/0.2.0...HEAD
|
22
|
+
[0.1.1]: https://github.com/Dynamit/referee/tree/0.1.1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/Dynamit/referee) [](http://badge.fury.io/rb/objc-referee)
|
4
4
|
|
5
|
-
Referee is a script that generates Objective-C
|
5
|
+
Referee is a script that generates Objective-C or Swift objects for easily referencing your resources in code, providing IDE auto-complete and compile-time safety for your app.
|
6
6
|
|
7
7
|
The currently supported resource types are:
|
8
8
|
|
@@ -31,6 +31,13 @@ UIViewController *someViewController = TSTResources.viewControllers.SomeViewCont
|
|
31
31
|
[someViewController performSegue:TSTResources.segues.SomeSegue];
|
32
32
|
```
|
33
33
|
|
34
|
+
Using Swift, this code will look like:
|
35
|
+
|
36
|
+
```swift
|
37
|
+
let someViewController = Resources.ViewControllers.SomeViewController()
|
38
|
+
someViewController.performSegue(Resources.Segues.SomeSegue)
|
39
|
+
```
|
40
|
+
|
34
41
|
Now, if you change an identifier in your storyboard, your code won't compile unless it matches as well, providing you with the confidence that your code and UI are in sync.
|
35
42
|
|
36
43
|
## Installation
|
@@ -61,18 +68,24 @@ Finally, if you are using a `Gemfile` to manage Ruby dependencies for your app o
|
|
61
68
|
## Xcode Integration
|
62
69
|
This script was designed to be easily integrated into your Xcode project workflow.
|
63
70
|
|
64
|
-
Begin by adding a Run Script to your Build Phases. For the script portion, enter:
|
71
|
+
Begin by adding a Run Script to your Build Phases. For the script portion, enter one of the following:
|
65
72
|
|
66
|
-
/usr/local/bin/referee --prefix <your class prefix>
|
73
|
+
/usr/local/bin/referee --prefix <your class prefix> # for Objective-C
|
74
|
+
/usr/local/bin/referee --language swift # for Swift
|
67
75
|
|
68
76
|
_**Ensure that this Run Script runs before the Compile Sources step. Otherwise, your new changes won't get compiled!**_
|
69
77
|
|
70
|
-
Build the project and open your source folder.
|
78
|
+
Build the project and open your source folder. When using Objective-C, there should be two new files at the root of that folder: `<Prefix>Resources.h` and `<Prefix>Resources.m`. Add these files to the Xcode project, ensuring "Copy Files" is _not_ selected. When using Swift, a single file called `Resources.swift` will be generated. Follow the same steps to add the files to Xcode.
|
71
79
|
|
72
80
|
From now on, when you make changes in your Storyboard files, they will be reflected in these source files upon compiling.
|
73
81
|
|
74
82
|
If you need to setup different paths or configure `referee` further, check the `--help` flag for more information and documentation.
|
75
83
|
|
84
|
+
## Custom Frameworks
|
85
|
+
It is possible to generate resource accessors for a custom `.framework` with embedded resources simply by switching the generated code's accessed Bundle.
|
86
|
+
|
87
|
+
By default, all resources will be accessed from the Main Bundle, however, the `--bundle-id com.example.bundle-id` flag allows setting a custom Bundle Identifier. This allows you to access resources inside of a custom, third-party framework.
|
88
|
+
|
76
89
|
## Development
|
77
90
|
|
78
91
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/referee/cli.rb
CHANGED
@@ -24,6 +24,8 @@ module Referee
|
|
24
24
|
prefix: nil,
|
25
25
|
output: default_output_directory,
|
26
26
|
error_on_missing_storyboard_ids: false,
|
27
|
+
language: 'objc',
|
28
|
+
bundle_id: nil,
|
27
29
|
verbose: false }
|
28
30
|
|
29
31
|
optparse = OptionParser.new do |opts|
|
@@ -43,6 +45,14 @@ module Referee
|
|
43
45
|
options[:error_on_missing_storyboard_ids] = true
|
44
46
|
end
|
45
47
|
|
48
|
+
opts.on('-l', '--language LANGUAGE', 'Toggle language between objc and swift') do |language|
|
49
|
+
options[:language] = language.downcase
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on('-b', '--bundle-id IDENTIFIER', 'Set the bundle identifier in the generated code (Main bundle by default)') do |bundle_id|
|
53
|
+
options[:bundle_id] = bundle_id
|
54
|
+
end
|
55
|
+
|
46
56
|
opts.on('-v', '--verbose', 'Enable verbose mode') do
|
47
57
|
options[:verbose] = true
|
48
58
|
end
|
@@ -63,12 +73,23 @@ module Referee
|
|
63
73
|
Configuration.new(options)
|
64
74
|
end
|
65
75
|
|
76
|
+
def validate_bundle_id(bundle_id)
|
77
|
+
# Note: `nil` bundle ID will indicate main bundle default.
|
78
|
+
# We'll accept nil or a "<something>.<something>..." format.
|
79
|
+
bundle_regex = /[-a-zA-Z0-9]+(\.[-a-zA-Z0-9])+/
|
80
|
+
(!bundle_id || bundle_id.match(bundle_regex))
|
81
|
+
end
|
82
|
+
|
66
83
|
def validate_config
|
84
|
+
is_swift = (@config.language == 'swift')
|
67
85
|
output_valid = File.exist?(@config.output) && File.writable?(@config.output)
|
68
|
-
build_output.die 'Class prefix must be provided' unless @config.prefix
|
86
|
+
build_output.die 'Class prefix must be provided' unless is_swift || @config.prefix
|
87
|
+
build_output.info 'Class prefix will ignored...' if is_swift && @config.prefix
|
69
88
|
build_output.die 'Output directory must exist and be writable' unless output_valid
|
70
89
|
build_output.die 'An Xcode project is required!' unless @config.project
|
71
90
|
build_output.die 'Xcode project must exist!' unless File.exist?(@config.project)
|
91
|
+
build_output.die 'Invalid language specified!' unless %w(swift objc).index(@config.language)
|
92
|
+
build_output.die 'Invalid bundle identifier' unless validate_bundle_id(@config.bundle_id)
|
72
93
|
build_output.info 'Loaded and validated configuration...'
|
73
94
|
end
|
74
95
|
|
@@ -9,6 +9,16 @@ module Referee
|
|
9
9
|
public
|
10
10
|
|
11
11
|
def generate!
|
12
|
+
if @config.language == 'objc'
|
13
|
+
generate_objc!
|
14
|
+
else
|
15
|
+
generate_swift!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def generate_objc!
|
12
22
|
# Substitute out template information.
|
13
23
|
iface = renderer.render_interface(dictionary_representation)
|
14
24
|
impl = renderer.render_implementation(dictionary_representation)
|
@@ -22,7 +32,16 @@ module Referee
|
|
22
32
|
File.write(implementation_path, impl)
|
23
33
|
end
|
24
34
|
|
25
|
-
|
35
|
+
def generate_swift!
|
36
|
+
# Substitute out template information.
|
37
|
+
swift_impl = renderer.render_swift_implementation(dictionary_representation)
|
38
|
+
|
39
|
+
# Generate path.
|
40
|
+
file_path = resource_file('swift')
|
41
|
+
|
42
|
+
# Write to file.
|
43
|
+
File.write(file_path, swift_impl)
|
44
|
+
end
|
26
45
|
|
27
46
|
def dictionary_representation
|
28
47
|
@dictionary_representation ||= create_dictionary_representation
|
@@ -49,8 +68,13 @@ module Referee
|
|
49
68
|
end
|
50
69
|
|
51
70
|
def resource_file(extension)
|
52
|
-
|
53
|
-
|
71
|
+
if @config.language == 'objc'
|
72
|
+
filename = "#{@config.prefix}Resources.#{extension}"
|
73
|
+
File.join(@config.output, filename)
|
74
|
+
else
|
75
|
+
filename = "Resources.#{extension}"
|
76
|
+
File.join(@config.output, filename)
|
77
|
+
end
|
54
78
|
end
|
55
79
|
|
56
80
|
def renderer
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Referee
|
2
2
|
# Configuration container.
|
3
3
|
class Configuration
|
4
|
-
attr_accessor :project, :prefix, :output, :error_on_missing_storyboard_ids, :verbose
|
4
|
+
attr_accessor :project, :prefix, :output, :error_on_missing_storyboard_ids, :verbose, :language,
|
5
|
+
:bundle_id
|
5
6
|
|
6
7
|
def initialize(config)
|
7
8
|
config.each do |key, value|
|
data/lib/referee/project.rb
CHANGED
@@ -37,7 +37,7 @@ module Referee
|
|
37
37
|
segues = segues(xml)
|
38
38
|
|
39
39
|
# Add to resources collection
|
40
|
-
group = ResourceGroup.new(storyboard, table_cells, collection_cells, non_empty_view_controllers, segues)
|
40
|
+
group = ResourceGroup.new(storyboard, table_cells, collection_cells, non_empty_view_controllers, segues, @config)
|
41
41
|
@resources << group
|
42
42
|
|
43
43
|
# Check for missing view controller IDs in this storyboard.
|
data/lib/referee/renderable.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Referee
|
2
2
|
# Abstract class defining how renderable resources must behave.
|
3
3
|
class Renderable
|
4
|
-
attr_accessor :type
|
4
|
+
attr_accessor :type, :swift_type
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
fail 'Abstract class Renderable may not be instantiated!'
|
@@ -17,6 +17,27 @@ module Referee
|
|
17
17
|
fail 'Subclasses must implement implementation()!'
|
18
18
|
end
|
19
19
|
|
20
|
+
# NOTE: Subclasses must implement this method.
|
21
|
+
def swift_implementation
|
22
|
+
fail 'Subclasses must implement swift_implementation()!'
|
23
|
+
end
|
24
|
+
|
25
|
+
def bundle_accessor(bundle_id)
|
26
|
+
if bundle_id
|
27
|
+
"[NSBundle bundleWithIdentifier:\"#{bundle_id}\"]"
|
28
|
+
else
|
29
|
+
'[NSBundle mainBundle]'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def swift_bundle_accessor(bundle_id)
|
34
|
+
if bundle_id
|
35
|
+
"NSBundle(identifier: \"#{bundle_id}\")"
|
36
|
+
else
|
37
|
+
'NSBundle.mainBundle()'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
20
41
|
def methodize_name(name)
|
21
42
|
name.gsub(/[^a-zA-Z0-9]/, '')
|
22
43
|
end
|
@@ -30,5 +51,15 @@ module Referee
|
|
30
51
|
clean_name = methodize_name(name)
|
31
52
|
"- (#{@type})#{clean_name}\n{\n\treturn #{body};\n}"
|
32
53
|
end
|
54
|
+
|
55
|
+
def simple_swift_method(name, body)
|
56
|
+
clean_name = methodize_name(name)
|
57
|
+
"func #{clean_name}() -> #{@swift_type} {\n\t\t\treturn #{body}\n\t\t}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def simple_swift_string_case(name)
|
61
|
+
clean_name = methodize_name(name)
|
62
|
+
"case #{clean_name} = \"#{name}\""
|
63
|
+
end
|
33
64
|
end
|
34
65
|
end
|
@@ -4,6 +4,7 @@ module Referee
|
|
4
4
|
def initialize(identifier)
|
5
5
|
@identifier = identifier
|
6
6
|
@type = 'NSString *'
|
7
|
+
@swift_type = 'String'
|
7
8
|
end
|
8
9
|
|
9
10
|
def declaration
|
@@ -13,5 +14,9 @@ module Referee
|
|
13
14
|
def implementation
|
14
15
|
simple_method_implementation @identifier, "@\"#{@identifier}\""
|
15
16
|
end
|
17
|
+
|
18
|
+
def swift_implementation
|
19
|
+
simple_swift_string_case @identifier
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
@@ -4,6 +4,7 @@ module Referee
|
|
4
4
|
def initialize(identifier)
|
5
5
|
@identifier = identifier
|
6
6
|
@type = 'NSString *'
|
7
|
+
@swift_type = 'String'
|
7
8
|
end
|
8
9
|
|
9
10
|
def declaration
|
@@ -13,5 +14,9 @@ module Referee
|
|
13
14
|
def implementation
|
14
15
|
simple_method_implementation @identifier, "@\"#{@identifier}\""
|
15
16
|
end
|
17
|
+
|
18
|
+
def swift_implementation
|
19
|
+
simple_swift_string_case @identifier
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Referee
|
2
2
|
# Renderable implementation for UIStoryboards in a project.
|
3
3
|
class Storyboard < Renderable
|
4
|
-
|
4
|
+
attr_accessor :name, :config
|
5
|
+
|
6
|
+
def initialize(name, config)
|
5
7
|
@name = name
|
6
8
|
@type = 'UIStoryboard *'
|
9
|
+
@swift_type = 'UIStoryboard'
|
10
|
+
@config = config
|
7
11
|
end
|
8
12
|
|
9
13
|
def declaration
|
@@ -11,8 +15,15 @@ module Referee
|
|
11
15
|
end
|
12
16
|
|
13
17
|
def implementation
|
14
|
-
|
18
|
+
bundle = bundle_accessor(@config.bundle_id)
|
19
|
+
body = "[UIStoryboard storyboardWithName:@\"#{@name}\" bundle:#{bundle}]"
|
15
20
|
simple_method_implementation @name, body
|
16
21
|
end
|
22
|
+
|
23
|
+
def swift_implementation
|
24
|
+
bundle = swift_bundle_accessor(@config.bundle_id)
|
25
|
+
body = "UIStoryboard(name: \"#{@name}\", bundle: #{bundle})"
|
26
|
+
simple_swift_method @name, body
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
@@ -4,6 +4,7 @@ module Referee
|
|
4
4
|
def initialize(identifier)
|
5
5
|
@identifier = identifier
|
6
6
|
@type = 'NSString *'
|
7
|
+
@swift_type = 'String'
|
7
8
|
end
|
8
9
|
|
9
10
|
def declaration
|
@@ -13,5 +14,9 @@ module Referee
|
|
13
14
|
def implementation
|
14
15
|
simple_method_implementation @identifier, "@\"#{@identifier}\""
|
15
16
|
end
|
17
|
+
|
18
|
+
def swift_implementation
|
19
|
+
simple_swift_string_case @identifier
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module Referee
|
2
2
|
# Renderable implementation for UIViewControllers embedded in storyboards.
|
3
3
|
class ViewController < Renderable
|
4
|
-
attr_accessor :name, :storyboard
|
4
|
+
attr_accessor :name, :storyboard, :config
|
5
5
|
|
6
|
-
def initialize(name, storyboard)
|
6
|
+
def initialize(name, storyboard, config)
|
7
7
|
@name = name
|
8
8
|
@storyboard = storyboard
|
9
9
|
@type = 'UIViewController *'
|
10
|
+
@swift_type = 'UIViewController'
|
11
|
+
@config = config
|
10
12
|
end
|
11
13
|
|
12
14
|
def declaration
|
@@ -14,9 +16,17 @@ module Referee
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def implementation
|
17
|
-
|
19
|
+
bundle = bundle_accessor(@config.bundle_id)
|
20
|
+
body = "[[UIStoryboard storyboardWithName:@\"#{@storyboard}\" bundle:#{bundle}] " \
|
18
21
|
"instantiateViewControllerWithIdentifier:@\"#{@name}\"]"
|
19
22
|
simple_method_implementation @name, body
|
20
23
|
end
|
24
|
+
|
25
|
+
def swift_implementation
|
26
|
+
bundle = swift_bundle_accessor(@config.bundle_id)
|
27
|
+
body = "UIStoryboard(name: \"#{@name}\", bundle: #{bundle})." \
|
28
|
+
"instantiateViewControllerWithIdentifier(\"#{@name}\")"
|
29
|
+
simple_swift_method @name, body
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module Referee
|
2
2
|
# Representation of all of the resources contained in a given storyboard.
|
3
3
|
class ResourceGroup
|
4
|
-
attr_accessor :storyboard, :table_cells, :collection_cells, :view_controllers, :segues
|
4
|
+
attr_accessor :storyboard, :table_cells, :collection_cells, :view_controllers, :segues, :config
|
5
5
|
|
6
|
-
def initialize(storyboard, table_cells, collection_cells, view_controllers, segues)
|
6
|
+
def initialize(storyboard, table_cells, collection_cells, view_controllers, segues, config)
|
7
7
|
@storyboard = storyboard
|
8
8
|
@table_cells = table_cells
|
9
9
|
@collection_cells = collection_cells
|
10
10
|
@view_controllers = view_controllers
|
11
11
|
@segues = segues
|
12
|
+
@config = config
|
12
13
|
end
|
13
14
|
|
14
15
|
def storyboard_name
|
@@ -17,7 +18,7 @@ module Referee
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def storyboard
|
20
|
-
Storyboard.new(storyboard_name)
|
21
|
+
Storyboard.new(storyboard_name, @config)
|
21
22
|
end
|
22
23
|
|
23
24
|
def table_cells
|
@@ -29,7 +30,7 @@ module Referee
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def view_controllers
|
32
|
-
@view_controllers.map { |c| ViewController.new(c, storyboard_name) }
|
33
|
+
@view_controllers.map { |c| ViewController.new(c, storyboard_name, @config) }
|
33
34
|
end
|
34
35
|
|
35
36
|
def segues
|
@@ -3,6 +3,7 @@ module Referee
|
|
3
3
|
class TemplateRenderer
|
4
4
|
INTERFACE_TEMPLATE_NAME = 'interface.h'
|
5
5
|
IMPLEMENTATION_TEMPLATE_NAME = 'implementation.m'
|
6
|
+
SWIFT_TEMPLATE_NAME = 'default.swift'
|
6
7
|
|
7
8
|
private
|
8
9
|
|
@@ -28,5 +29,10 @@ module Referee
|
|
28
29
|
def render_interface(dict)
|
29
30
|
template(INTERFACE_TEMPLATE_NAME).call(dict)
|
30
31
|
end
|
32
|
+
|
33
|
+
# Renders the Swift implementation file as a string.
|
34
|
+
def render_swift_implementation(dict)
|
35
|
+
template(SWIFT_TEMPLATE_NAME).call(dict)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/referee/version.rb
CHANGED
data/objc-referee.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
+
spec.required_ruby_version = '~> 2.0'
|
24
|
+
|
23
25
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
24
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
27
|
spec.add_development_dependency 'rubocop', '~> 0.33.0'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/** THIS FILE IS AUTOGENERATED. DO NOT EDIT. CHANGES WILL BE DESTROYED. */
|
2
|
+
|
3
|
+
import Foundation
|
4
|
+
import UIKit
|
5
|
+
|
6
|
+
struct Resources {
|
7
|
+
static let Storyboards = _Storyboards()
|
8
|
+
static let ViewControllers = _ViewControllers()
|
9
|
+
|
10
|
+
/// UIStoryboard accessors.
|
11
|
+
struct _Storyboards {
|
12
|
+
{{# storyboards #}}
|
13
|
+
{{{ swift_implementation }}}
|
14
|
+
{{/ storyboards }}
|
15
|
+
}
|
16
|
+
|
17
|
+
{{# table_cells #}}
|
18
|
+
/// UITableViewCell identifier accessors.
|
19
|
+
enum TableViewCells: String {
|
20
|
+
{{{ swift_implementation }}}
|
21
|
+
}
|
22
|
+
{{/ table_cells }}
|
23
|
+
|
24
|
+
{{# collection_cells #}}
|
25
|
+
enum CollectionViewCells: String {
|
26
|
+
{{{ swift_implementation }}}
|
27
|
+
}
|
28
|
+
{{/ collection_cells }}
|
29
|
+
|
30
|
+
/// UIViewController accessors.
|
31
|
+
struct _ViewControllers {
|
32
|
+
{{# view_controllers #}}
|
33
|
+
{{{ swift_implementation }}}
|
34
|
+
{{/ view_controllers }}
|
35
|
+
}
|
36
|
+
|
37
|
+
{{# segues #}}
|
38
|
+
/// Segue accessors.
|
39
|
+
enum Segues: String {
|
40
|
+
{{{ swift_implementation }}}
|
41
|
+
}
|
42
|
+
{{/ segues }}
|
43
|
+
}
|
data/resources/implementation.m
CHANGED
data/resources/interface.h
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: objc-referee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Drake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/referee/templaterenderer.rb
|
173
173
|
- lib/referee/version.rb
|
174
174
|
- objc-referee.gemspec
|
175
|
+
- resources/default.swift
|
175
176
|
- resources/implementation.m
|
176
177
|
- resources/interface.h
|
177
178
|
homepage: http://dynamit.com
|
@@ -184,9 +185,9 @@ require_paths:
|
|
184
185
|
- lib
|
185
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
187
|
requirements:
|
187
|
-
- - "
|
188
|
+
- - "~>"
|
188
189
|
- !ruby/object:Gem::Version
|
189
|
-
version: '0'
|
190
|
+
version: '2.0'
|
190
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
192
|
requirements:
|
192
193
|
- - ">="
|