motion-objection 0.5
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 +15 -0
- data/.gitignore +36 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +21 -0
- data/README.md +32 -0
- data/Rakefile +15 -0
- data/app/app_delegate.rb +5 -0
- data/lib/motion-objection.rb +13 -0
- data/lib/motion-objection/jsobjection.rb +3 -0
- data/lib/motion-objection/jsobjection_injector.rb +11 -0
- data/lib/motion-objection/objection.rb +67 -0
- data/lib/motion-objection/ruby_property_reflector.rb +11 -0
- data/lib/motion-objection/version.rb +3 -0
- data/motion_objection.gemspec +23 -0
- data/resources/Default-568h@2x.png +0 -0
- data/spec/helpers/objection_classes.rb +46 -0
- data/spec/helpers/objection_modules.rb +19 -0
- data/spec/objection_spec.rb +68 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGY0M2YxMGNiZGQ3NTNlNDUyMDNjOGI1MTE4OTE2YjU2ZWQ4MTcxNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzcwOWM0NmVmNDMzYzFkNGNhMGQ3Nzg5N2ZmM2ZlZTA1NmE4MWRlYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDkyMmRlNzdhMjQ3YjE3MDA2Y2Y4ZDBjMjhmNTA0Mzk3NzFjM2E4MTgxMDgz
|
10
|
+
NDllMjdjMDA1MTg1ZmI1YjkxNDBhMjE0MWI5MzdlN2NhNTk1YzdhNGRmMzFj
|
11
|
+
NWQ4YjdhZGQzYTIxNzY4ZDczNWI2MGJiNmZkNjdmNzAxNjJlMDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzgyM2M2YTEzNTQ3ZjI0ZDBkOTY5Yjk4YzAyOTdjZDhjNTFmMzkwYzI2MGJk
|
14
|
+
ZWUyNjdhOTkzZWRkMTIwYjgwZDExYjIzYWU2YTAwZTI1ZDU0YTQ2MWZlZGI3
|
15
|
+
ZmExNmI3MGVkNGEyNTY2NTUwYTE2MWVkMWQ3YTc5ZjZjOWZmZWU=
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
.repl_history
|
2
|
+
build
|
3
|
+
tags
|
4
|
+
app/pixate_code.rb
|
5
|
+
resources/*.nib
|
6
|
+
resources/*.momd
|
7
|
+
resources/*.storyboardc
|
8
|
+
.DS_Store
|
9
|
+
nbproject
|
10
|
+
.redcar
|
11
|
+
#*#
|
12
|
+
*~
|
13
|
+
*.sw[po]
|
14
|
+
.eprj
|
15
|
+
.sass-cache
|
16
|
+
.idea
|
17
|
+
=======
|
18
|
+
*.gem
|
19
|
+
*.rbc
|
20
|
+
.bundle
|
21
|
+
.config
|
22
|
+
coverage
|
23
|
+
InstalledFiles
|
24
|
+
lib/bundler/man
|
25
|
+
pkg
|
26
|
+
rdoc
|
27
|
+
spec/reports
|
28
|
+
test/tmp
|
29
|
+
test/version_tmp
|
30
|
+
tmp
|
31
|
+
vendor
|
32
|
+
|
33
|
+
# YARD artifacts
|
34
|
+
.yardoc
|
35
|
+
_yardoc
|
36
|
+
doc/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
motion-objection (0.5)
|
5
|
+
motion-cocoapods (~> 1.3.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (3.2.14)
|
11
|
+
i18n (~> 0.6, >= 0.6.4)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
claide (0.3.2)
|
14
|
+
cocoapods (0.22.3)
|
15
|
+
activesupport (~> 3.2.13)
|
16
|
+
claide (~> 0.3.2)
|
17
|
+
cocoapods-core (= 0.22.3)
|
18
|
+
cocoapods-downloader (~> 0.1.1)
|
19
|
+
colored (~> 1.2)
|
20
|
+
escape (~> 0.0.4)
|
21
|
+
json (~> 1.8.0)
|
22
|
+
open4 (~> 1.3.0)
|
23
|
+
xcodeproj (~> 0.8.1)
|
24
|
+
cocoapods-core (0.22.3)
|
25
|
+
activesupport (~> 3.2.13)
|
26
|
+
json (~> 1.8.0)
|
27
|
+
nap (~> 0.5.1)
|
28
|
+
cocoapods-downloader (0.1.2)
|
29
|
+
colored (1.2)
|
30
|
+
escape (0.0.4)
|
31
|
+
i18n (0.6.4)
|
32
|
+
json (1.8.0)
|
33
|
+
motion-cocoapods (1.3.5)
|
34
|
+
cocoapods (>= 0.17.0)
|
35
|
+
multi_json (1.7.7)
|
36
|
+
nap (0.5.1)
|
37
|
+
open4 (1.3.0)
|
38
|
+
rake (10.0.4)
|
39
|
+
xcodeproj (0.8.1)
|
40
|
+
activesupport (~> 3.2.13)
|
41
|
+
colored (~> 1.2)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
motion-objection!
|
48
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012-2013 Justin DeWind
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
motion-objection
|
2
|
+
================
|
3
|
+
|
4
|
+
Wrapping Objection in RubyMotion.
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
class Car
|
8
|
+
include Objection
|
9
|
+
compose_with :engine, :brakes
|
10
|
+
end
|
11
|
+
|
12
|
+
class Engine
|
13
|
+
include Objection
|
14
|
+
singleton
|
15
|
+
compose_with 'engine/crank_shaft', 'engine/rod'
|
16
|
+
|
17
|
+
def shift(wat)
|
18
|
+
puts "SHIFT!"
|
19
|
+
end
|
20
|
+
|
21
|
+
class CrankShaft
|
22
|
+
end
|
23
|
+
|
24
|
+
class Rod
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Brakes
|
29
|
+
def brake!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project/template/ios'
|
4
|
+
require "motion-cocoapods"
|
5
|
+
|
6
|
+
$:.unshift("./lib/")
|
7
|
+
require './lib/motion-objection'
|
8
|
+
|
9
|
+
Motion::Project::App.setup do |app|
|
10
|
+
# Use `rake config' to see complete project settings.
|
11
|
+
app.name = 'motion-objection'
|
12
|
+
app.pods do
|
13
|
+
pod "Objection", "~>1.0.3"
|
14
|
+
end
|
15
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
Motion::Project::App.setup do |app|
|
6
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'motion-objection/**/*.rb')).each do |file|
|
7
|
+
app.files.unshift(file)
|
8
|
+
end
|
9
|
+
|
10
|
+
app.pods do
|
11
|
+
pod 'Objection', "~>1.0.3"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Objection
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.send :extend, ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.injector(*modules)
|
8
|
+
if modules.empty?
|
9
|
+
JSObjection.createInjector
|
10
|
+
elsif modules.size == 1
|
11
|
+
JSObjection.createInjector modules.first
|
12
|
+
else
|
13
|
+
JSObjection.createInjectorWithModulesArray modules
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Initializer
|
18
|
+
def objectionInitializer
|
19
|
+
@_initializer
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
|
25
|
+
def compose_with(*args)
|
26
|
+
props = args.map { |x| x.split("/").last }
|
27
|
+
props.each { |x| attr_accessor x }
|
28
|
+
@_types_mappings = {}
|
29
|
+
props.each_index { |i| @_types_mappings[props[i]] = args[i] }
|
30
|
+
@_dependencies = NSSet.setWithArray(props.map(&:to_s))
|
31
|
+
end
|
32
|
+
|
33
|
+
def singleton
|
34
|
+
JSObjection.registerClass self, scope: JSObjectionScopeSingleton
|
35
|
+
end
|
36
|
+
|
37
|
+
def initializer(selector, *args)
|
38
|
+
self.send :extend, Initializer
|
39
|
+
@_initializer = {
|
40
|
+
"initializer" => selector,
|
41
|
+
"arguments" => args
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def objectionRequires
|
48
|
+
@_dependencies ||= NSSet.set
|
49
|
+
if self.superclass.respondsToSelector :objectionRequires
|
50
|
+
set = NSMutableSet.setWithSet self.superclass.objectionRequires
|
51
|
+
set.unionSet @_dependencies
|
52
|
+
set
|
53
|
+
else
|
54
|
+
@_dependencies
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def objectionTypeMappings
|
59
|
+
@_types_mappings ||= {}
|
60
|
+
if self.superclass.respondsToSelector :objectionTypeMappings
|
61
|
+
@_types_mappings.merge self.superclass.objectionTypeMappings
|
62
|
+
else
|
63
|
+
@_types_mappings
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class RubyPropertyReflector
|
2
|
+
NAMESPACE_SEPARTOR = "/"
|
3
|
+
|
4
|
+
def self.propertyForClass(klass, andProperty: property)
|
5
|
+
scopes = klass.send(:objectionTypeMappings)[property].to_s.split(NAMESPACE_SEPARTOR).map { |x| x.split("_") }.map { |x| x.map { |y| y.capitalize }.join("") }
|
6
|
+
klass = scopes.inject(Object) do |const, name|
|
7
|
+
const.const_get name
|
8
|
+
end
|
9
|
+
JSObjectionPropertyInfo.new(klass, JSObjectionTypeClass).value
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../lib/motion-objection/version.rb', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'motion-objection'
|
5
|
+
gem.version = Objection::VERSION
|
6
|
+
gem.licenses = ['MIT']
|
7
|
+
|
8
|
+
gem.authors = 'Justin DeWind'
|
9
|
+
gem.email = 'dewind@atomicobject.com'
|
10
|
+
|
11
|
+
gem.description = <<-DESC
|
12
|
+
motion-objection is a wrapper around Objection which is a dependency
|
13
|
+
injection framework written for Objective-C
|
14
|
+
DESC
|
15
|
+
|
16
|
+
gem.summary = 'A ruby motion library wrapping the popular dependency injection library Objection'
|
17
|
+
gem.homepage = 'https://github.com/atomicobject/motion-objection'
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($\)
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
22
|
+
gem.add_dependency "motion-cocoapods", "~>1.3.5"
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Car
|
2
|
+
include Objection
|
3
|
+
compose_with :engine, :brakes
|
4
|
+
end
|
5
|
+
|
6
|
+
class Engine
|
7
|
+
include Objection
|
8
|
+
singleton
|
9
|
+
compose_with 'engine/crank_shaft', 'engine/rod'
|
10
|
+
|
11
|
+
def shift(wat)
|
12
|
+
puts "SHIFT!"
|
13
|
+
end
|
14
|
+
|
15
|
+
class CrankShaft
|
16
|
+
end
|
17
|
+
|
18
|
+
class Rod
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class V6Engine < Engine; end
|
23
|
+
|
24
|
+
class Brakes
|
25
|
+
def brake!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class ABSBrakes < Brakes
|
30
|
+
def abs_brake!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class ViewController < NSObject
|
35
|
+
include Objection
|
36
|
+
initializer "initWithNibName:bundle:", "Home"
|
37
|
+
|
38
|
+
attr_reader :name
|
39
|
+
|
40
|
+
def initWithNibName(name, bundle: bundle)
|
41
|
+
self.init
|
42
|
+
self.tap do
|
43
|
+
@name = name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AppModule < JSObjectionModule
|
2
|
+
attr_reader :v6_engine
|
3
|
+
|
4
|
+
def init
|
5
|
+
super.tap do
|
6
|
+
@v6_engine = V6Engine.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure
|
11
|
+
bind @v6_engine, toClass: Engine
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class AppModuleII < JSObjectionModule
|
16
|
+
def configure
|
17
|
+
bindClass ABSBrakes, toClass: Brakes
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
describe "Objection" do
|
2
|
+
before do
|
3
|
+
@injector = Objection.injector
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "dependency injection" do
|
7
|
+
it "supports inheritance" do
|
8
|
+
@engine = @injector[V6Engine]
|
9
|
+
|
10
|
+
@engine.crank_shaft.class.should.be.same_as Engine::CrankShaft
|
11
|
+
@engine.rod.class.should.be.same_as Engine::Rod
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can construct an object with dependencies" do
|
15
|
+
@car = @injector.get_object Car
|
16
|
+
@car.engine.class.should.be.same_as Engine
|
17
|
+
@car.brakes.class.should.be.same_as Brakes
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has support for singletons" do
|
21
|
+
@engine1 = @injector[Engine]
|
22
|
+
@engine2 = @injector[Engine]
|
23
|
+
|
24
|
+
@engine1.should.be.same_as @engine2
|
25
|
+
end
|
26
|
+
|
27
|
+
it "will not construct a singleton by default" do
|
28
|
+
@brakes1 = @injector[Brakes]
|
29
|
+
@brakes2 = @injector[Brakes]
|
30
|
+
|
31
|
+
@brakes1.should.not.be.same_as @brakes2
|
32
|
+
end
|
33
|
+
|
34
|
+
it "understands namespaced classes" do
|
35
|
+
@engine = @injector[Engine]
|
36
|
+
|
37
|
+
@engine.crank_shaft.class.should.be.same_as Engine::CrankShaft
|
38
|
+
@engine.rod.class.should.be.same_as Engine::Rod
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "modules" do
|
43
|
+
before do
|
44
|
+
@app_module = AppModule.alloc.init
|
45
|
+
@app_module2 = AppModuleII.alloc.init
|
46
|
+
end
|
47
|
+
|
48
|
+
it "has support for an injector with a module" do
|
49
|
+
@injector = Objection.injector @app_module
|
50
|
+
|
51
|
+
@injector[Engine].should.equal @app_module.v6_engine
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has support for an injector with multiple modules" do
|
55
|
+
@injector = Objection.injector @app_module, @app_module2
|
56
|
+
|
57
|
+
@injector[Engine].should.equal @app_module.v6_engine
|
58
|
+
@injector[Brakes].should.respond_to? :abs_brake!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "initializer" do
|
63
|
+
it "has support for default initializers" do
|
64
|
+
@controller = @injector[ViewController]
|
65
|
+
@controller.name.should.equal "Home"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-objection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.5'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin DeWind
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: motion-cocoapods
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.5
|
27
|
+
description: ! " motion-objection is a wrapper around Objection which is a dependency\n
|
28
|
+
\ injection framework written for Objective-C\n"
|
29
|
+
email: dewind@atomicobject.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- app/app_delegate.rb
|
41
|
+
- lib/motion-objection.rb
|
42
|
+
- lib/motion-objection/jsobjection.rb
|
43
|
+
- lib/motion-objection/jsobjection_injector.rb
|
44
|
+
- lib/motion-objection/objection.rb
|
45
|
+
- lib/motion-objection/ruby_property_reflector.rb
|
46
|
+
- lib/motion-objection/version.rb
|
47
|
+
- motion_objection.gemspec
|
48
|
+
- resources/Default-568h@2x.png
|
49
|
+
- spec/helpers/objection_classes.rb
|
50
|
+
- spec/helpers/objection_modules.rb
|
51
|
+
- spec/objection_spec.rb
|
52
|
+
homepage: https://github.com/atomicobject/motion-objection
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.0.3
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: A ruby motion library wrapping the popular dependency injection library Objection
|
76
|
+
test_files:
|
77
|
+
- spec/helpers/objection_classes.rb
|
78
|
+
- spec/helpers/objection_modules.rb
|
79
|
+
- spec/objection_spec.rb
|