objc-referee 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bcb63d18db2e93bca9a64df61564a0d3ba45d7f
4
- data.tar.gz: 07ed9bd6dda0b647b751d803d583967bd761d14a
3
+ metadata.gz: ab33621de6d2c048a7941e38fc2829ef73f41ba2
4
+ data.tar.gz: 87c5d7583369eaa5c8ff4644025d737751e51f62
5
5
  SHA512:
6
- metadata.gz: f291f795d14d164796afa6c372ec8ba42bbae833c74253946d007146485bc0cb812049c642a91a49330a939c008ea29f24284fff8a7253056cd3c733ee2b0509
7
- data.tar.gz: ccda4f5cc16b3979a4ad5c29b1b1b17f1b93deabdff66d640a10f7228b914d3fefe572b192872faea2367308f1ba56d49301c83c976cdac9a29f2c2bc8ae4080
6
+ metadata.gz: af7c0a621f8d1eb67f329824f03bb3df95c9f2fa95060a9225702c1a61cfed8baa473eb1cace69d1efbc0022425883f2fdeb00d4044d602a7ba602f8e2d82423
7
+ data.tar.gz: f4abbde63f073771b68d3ca791c893504cc45d2b8326ac0a7e328f327feca811a7a43ba5529f8af0479d4c353385d70e58bf5a16502aafa5b8ecaedce081d802
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -4,6 +4,7 @@ inherit_from: .rubocop_todo.yml
4
4
  AllCops:
5
5
  Exclude:
6
6
  - 'bin/*'
7
+ - 'spec/spec_helper.rb' # autogenerated file
7
8
 
8
9
  # Give us... a little more room.
9
10
  Metrics/LineLength:
data/.travis.yml CHANGED
@@ -2,11 +2,13 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - 2.0.0
5
+ - 2.0
6
6
  - 2.1
7
7
  - 2.2
8
+ - 2.3
8
9
  before_install: gem update --remote bundler
9
10
  install:
10
11
  - bundle install --retry=3
11
12
  script:
13
+ - bundle exec rspec
12
14
  - bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -3,7 +3,14 @@ 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
5
  ## [Unreleased]
6
- Forthcoming.
6
+ TODO
7
+
8
+ ## [0.3.0] - 2016-03-08
9
+ ### Added
10
+ - View controllers are now returned as the type they were defined to be in Interface Builder [(#2)](https://github.com/Dynamit/referee/issues/2).
11
+ - This removes the `as! FooViewController`-type code that was required in the past.
12
+ - As an update, to remove Xcode build warnings, you'll want to remove these forced casts from your own code. Regardless, existing code should still compile without an _error_, at least.
13
+ - Test suite to reduce regression errors. Travis-CI is running these against `master`.
7
14
 
8
15
  ## [0.2.4] - 2016-01-15
9
16
  ### Added
@@ -34,7 +41,8 @@ Forthcoming.
34
41
  ## [0.1.1] - 2015-09-02
35
42
  Initial public release.
36
43
 
37
- [unreleased]: https://github.com/dynamit/referee/compare/v0.2.4...HEAD
44
+ [unreleased]: https://github.com/dynamit/referee/compare/v0.3.0...HEAD
45
+ [0.3.0]: https://github.com/Dynamit/referee/tree/v0.3.0
38
46
  [0.2.4]: https://github.com/Dynamit/referee/tree/v0.2.4
39
47
  [0.2.3]: https://github.com/Dynamit/referee/tree/v0.2.3
40
48
  [0.2.2]: https://github.com/Dynamit/referee/tree/v0.2.2
data/Gemfile.lock CHANGED
@@ -20,6 +20,7 @@ GEM
20
20
  parser (~> 2.2)
21
21
  coderay (1.1.0)
22
22
  colored (1.2)
23
+ diff-lcs (1.2.5)
23
24
  i18n (0.7.0)
24
25
  json (1.8.3)
25
26
  method_source (0.8.2)
@@ -37,6 +38,15 @@ GEM
37
38
  slop (~> 3.4)
38
39
  rainbow (2.0.0)
39
40
  rake (10.4.2)
41
+ rspec-core (3.4.1)
42
+ rspec-support (~> 3.4.0)
43
+ rspec-expectations (3.4.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.4.0)
46
+ rspec-mocks (3.4.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.4.0)
49
+ rspec-support (3.4.1)
40
50
  rubocop (0.33.0)
41
51
  astrolabe (~> 1.3)
42
52
  parser (>= 2.2.2.5, < 3.0)
@@ -61,6 +71,9 @@ DEPENDENCIES
61
71
  objc-referee!
62
72
  pry (~> 0.10.1)
63
73
  rake (~> 10.0)
74
+ rspec-core (~> 3.4)
75
+ rspec-expectations (~> 3.4)
76
+ rspec-mocks (~> 3.4)
64
77
  rubocop (~> 0.33.0)
65
78
  rubygems-tasks (~> 0.2.4)
66
79
 
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Dynamit, LLC
3
+ Copyright (c) 2015-2016 Dynamit Technologies, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -20,14 +20,14 @@ Without `referee`, you can either maintain your own constants file in parallel w
20
20
 
21
21
  ```objc
22
22
  UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
23
- UIViewController *someViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"Some View Controller"];
23
+ SomeViewController *someViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"Some View Controller"];
24
24
  [someViewController performSegue:@"Some Segue"];
25
25
  ```
26
26
 
27
27
  With `referee`, you can replace this with references to a few automatically generated classes:
28
28
 
29
29
  ```objc
30
- UIViewController *someViewController = TSTResources.viewControllers.SomeViewController;
30
+ SomeViewController *someViewController = TSTResources.viewControllers.SomeViewController;
31
31
  [someViewController performSegue:TSTResources.segues.SomeSegue];
32
32
  ```
33
33
 
@@ -13,6 +13,20 @@ module Referee
13
13
  avPlayerViewController
14
14
  tabBarController)
15
15
 
16
+ DEFAULT_VIEW_CONTROLLER_TYPES = %w(
17
+ UIViewController
18
+ UITableViewController
19
+ UINavigationController
20
+ GLKViewController
21
+ UIPageViewController
22
+ UICollectionViewController
23
+ UISplitViewController
24
+ AVPlayerViewController
25
+ UITabBarController
26
+ )
27
+
28
+ VIEW_CONTROLLER_TYPE_MAP = Hash[VIEW_CONTROLLER_TAGS.zip(DEFAULT_VIEW_CONTROLLER_TYPES)]
29
+
16
30
  attr_accessor :config, :resources
17
31
 
18
32
  # Instantiate a new `Project` instance given a `Configuration`.
@@ -79,7 +93,14 @@ module Referee
79
93
  def view_controllers(xml)
80
94
  selector = VIEW_CONTROLLER_TAGS.join(',')
81
95
  controllers = xml.css(selector)
82
- controllers.map { |n| n['storyboardIdentifier'] }
96
+ controllers_list = controllers.map do |n|
97
+ tag_name = n.name
98
+ identifier = n['storyboardIdentifier']
99
+ klass = n['customClass'] || VIEW_CONTROLLER_TYPE_MAP[tag_name]
100
+ { identifier: identifier, class: klass }
101
+ end
102
+ controllers_list.delete_if { |c| c[:identifier].nil? || c[:identifier].strip.empty? }
103
+ controllers_list
83
104
  end
84
105
 
85
106
  def segues(xml)
@@ -3,11 +3,12 @@ module Referee
3
3
  class ViewController < Renderable
4
4
  attr_accessor :name, :storyboard, :config
5
5
 
6
- def initialize(name, storyboard, config)
6
+ def initialize(name, klass, storyboard, config)
7
7
  @name = name
8
+ @class = klass
8
9
  @storyboard = storyboard
9
- @type = 'UIViewController *'
10
- @swift_type = 'UIViewController'
10
+ @type = "#{@class} *"
11
+ @swift_type = @class
11
12
  @config = config
12
13
  end
13
14
 
@@ -17,15 +18,22 @@ module Referee
17
18
 
18
19
  def implementation
19
20
  bundle = bundle_accessor(@config.bundle_id)
20
- body = "[[UIStoryboard storyboardWithName:@\"#{@storyboard}\" bundle:#{bundle}] " \
21
+ body = "(#{@type})[[UIStoryboard storyboardWithName:@\"#{@storyboard}\" bundle:#{bundle}] " \
21
22
  "instantiateViewControllerWithIdentifier:@\"#{@name}\"]"
22
23
  simple_method_implementation @name, body
23
24
  end
24
25
 
25
26
  def swift_implementation
26
27
  bundle = swift_bundle_accessor(@config.bundle_id)
28
+
29
+ if @swift_type == 'UIViewController'
30
+ cast = ''
31
+ else
32
+ cast = " as! #{@swift_type}"
33
+ end
34
+
27
35
  body = "UIStoryboard(name: \"#{@storyboard}\", bundle: #{bundle})." \
28
- "instantiateViewControllerWithIdentifier(\"#{@name}\")"
36
+ "instantiateViewControllerWithIdentifier(\"#{@name}\")#{cast}"
29
37
  simple_swift_method @name, body
30
38
  end
31
39
  end
@@ -30,7 +30,11 @@ module Referee
30
30
  end
31
31
 
32
32
  def view_controllers
33
- @view_controllers.map { |c| ViewController.new(c, storyboard_name, @config) }
33
+ @view_controllers.map do |c|
34
+ identifier = c[:identifier]
35
+ klass = c[:class]
36
+ ViewController.new(identifier, klass, storyboard_name, @config)
37
+ end
34
38
  end
35
39
 
36
40
  def segues
@@ -1,4 +1,4 @@
1
1
  # Version information.
2
2
  module Referee
3
- VERSION = '0.2.4'
3
+ VERSION = '0.3.0'
4
4
  end
data/objc-referee.gemspec CHANGED
@@ -27,6 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rubocop', '~> 0.33.0'
28
28
  spec.add_development_dependency 'pry', '~> 0.10.1'
29
29
  spec.add_development_dependency 'rubygems-tasks', '~> 0.2.4'
30
+ spec.add_development_dependency 'rspec-core', '~> 3.4'
31
+ spec.add_development_dependency 'rspec-expectations', '~> 3.4'
32
+ spec.add_development_dependency 'rspec-mocks', '~> 3.4'
30
33
 
31
34
  spec.add_runtime_dependency 'xcodeproj', '~> 0.20.1'
32
35
  spec.add_runtime_dependency 'mustache', '~> 1.0', '>= 1.0.2'
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.2.4
4
+ version: 0.3.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: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.2.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-expectations
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-mocks
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.4'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: xcodeproj
85
127
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +186,7 @@ extensions: []
144
186
  extra_rdoc_files: []
145
187
  files:
146
188
  - ".gitignore"
189
+ - ".rspec"
147
190
  - ".rubocop.yml"
148
191
  - ".rubocop_todo.yml"
149
192
  - ".travis.yml"