pakyow-bindr 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/lib/pakyow-bindr.rb +44 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: cbb2965c021adaf563ee0aa90bebb4295d46c6cc
|
|
4
|
+
data.tar.gz: 753ab20995e2112241ae8b4dd87de9868aa97e8e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: fffcf1ac49a4ebb4a789ee45c1e1bc8ec148f48f69f307f02b7a4d537bf91560a721c4089243314393d40bed1e9e35f52e631fcbdd74e4853309188283339326
|
|
7
|
+
data.tar.gz: d507ca1eadbe43aab467d020584146beaf0844ca9c8423edb35183f911195eb6dcc1bddb94a03495910351b011431a5e4baa59812b2892c5b5f4a7f4f9f44ab0
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012 Bryan Powell
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/pakyow-bindr.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class Pakyow::Presenter::View
|
|
2
|
+
def bindr(data, bindings: {}, context: nil, &block)
|
|
3
|
+
bind(data, bindings: bindings, context: context, &block)
|
|
4
|
+
return if data.nil?
|
|
5
|
+
|
|
6
|
+
data.each_pair do |data_scope, datum|
|
|
7
|
+
next unless view = scope(data_scope)
|
|
8
|
+
view.bindr(datum, bindings: bindings, context: context, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def applyr(data, bindings: {}, context: nil, &block)
|
|
13
|
+
views = apply(data, bindings: bindings, context: context, &block)
|
|
14
|
+
return if data.nil?
|
|
15
|
+
|
|
16
|
+
if data.is_a?(Array)
|
|
17
|
+
# map data across views
|
|
18
|
+
data.each_with_index do |datum,i|
|
|
19
|
+
views[i].applyr(datum, bindings: bindings, context: context, &block)
|
|
20
|
+
end
|
|
21
|
+
else
|
|
22
|
+
data.each_pair do |data_scope, datum|
|
|
23
|
+
next unless view = (views || self).scope(data_scope)
|
|
24
|
+
view.applyr(datum, bindings: bindings, context: context, &block)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Pakyow::Presenter::ViewCollection
|
|
31
|
+
def bindr(data, bindings: {}, context: nil, &block)
|
|
32
|
+
data = Array.ensure(data)
|
|
33
|
+
each_with_index do |view, i|
|
|
34
|
+
view.bindr(data[i], bindings: bindings, context: context, &block)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def applyr(data, bindings: {}, context: nil, &block)
|
|
39
|
+
data = Array.ensure(data)
|
|
40
|
+
each_with_index do |view, i|
|
|
41
|
+
view.applyr(data, bindings: bindings, context: context, &block)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pakyow-bindr
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bryan Powell
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: pakyow-presenter
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.9'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.9'
|
|
27
|
+
description: Adds recursive data binding to Pakyow, allowing deep structures to be
|
|
28
|
+
map to nested views.
|
|
29
|
+
email: bryan@metabahn.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- MIT-LICENSE
|
|
35
|
+
- lib/pakyow-bindr.rb
|
|
36
|
+
homepage: http://pakyow.com
|
|
37
|
+
licenses: []
|
|
38
|
+
metadata: {}
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 2.0.0
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 1.3.6
|
|
53
|
+
requirements: []
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 2.2.2
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: Recursive data binding for Pakyow.
|
|
59
|
+
test_files: []
|
|
60
|
+
has_rdoc:
|