vdom-rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,81 @@
1
+ require 'vdom/content'
2
+
3
+ module VDOM
4
+ class Table
5
+ class Column
6
+
7
+ attr_reader :id # unique in table, default to field
8
+
9
+ # Content procs with arity 2 should expect context to be [table, section, row]
10
+ # where table is a Table; section is :head, :body or :foot; row is an element in
11
+ # head_rows, body_rows or foot_rows.
12
+
13
+ attr_reader :head_content # Content or String or nil.
14
+ attr_reader :body_content # Content or String or nil.
15
+ attr_reader :foot_content # Content or String or nil.
16
+
17
+ # OPTIONS:
18
+ # :id # unique in table
19
+ # :sort # column may be sorted : boolean or nil
20
+ # :hide # column may be hidden : boolean or nil
21
+ # :master # column used for grouping in accordion table
22
+ # :head_content # Content or String or nil for column head
23
+ # :body_content # Content or String or nil for column body
24
+ # :foot_content # Content or String or nil for column foot
25
+
26
+ # TODO:
27
+ # width:
28
+
29
+ def initialize(**options)
30
+ @id = options[:id]
31
+ @sort_callback = options[:sort]
32
+ @hide = !!options[:hide]
33
+ @master = !!options[:master]
34
+ @head_content = options[:head_content]
35
+ @body_content = options[:body_content]
36
+ @foot_content = options[:foot_content]
37
+ end
38
+
39
+ def hash
40
+ @id.hash
41
+ end
42
+
43
+ def eql?(other)
44
+ @id == other.id
45
+ end
46
+
47
+ def ==(other)
48
+ @id == other.id
49
+ end
50
+
51
+ def master?
52
+ @master
53
+ end
54
+
55
+ def sort_callback
56
+ @sort_callback
57
+ end
58
+
59
+ def sort?
60
+ !!@sort_callback
61
+ end
62
+
63
+ def hide?
64
+ @hide
65
+ end
66
+
67
+ # section is :head, :body or :foot
68
+ def section_content(section)
69
+ send(:"#{section}_content")
70
+ end
71
+
72
+ # Returns a (hopefully) unique column id.
73
+ def self.unique_id
74
+ @@id_chars ||= ('0'..'9').to_a + ('A'..'F').to_a
75
+ 'COL_' + @@id_chars.shuffle.reduce('') {|r,c| r + c}
76
+ end
77
+
78
+ end
79
+ end
80
+ end
81
+
data/opal/vdom/util.rb ADDED
@@ -0,0 +1,12 @@
1
+ module VDOM
2
+ module Util
3
+ module_function
4
+
5
+ def debug(file, line, method, msg = nil)
6
+ s = "#{file}[#{line}] #{self.is_a?(Class) ? (self.name + '#') : self.class.name}##{method}"
7
+ s = s + " >> #{msg}" if msg
8
+ `console.log(s)`
9
+ end
10
+
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vdom-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Colin Gunn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: clearwater
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0.beta5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0.beta5
41
+ description: Adaptation and extension of Clearwater Ruby web framework
42
+ email:
43
+ - colgunn@icloud.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/vdom-rb.rb
49
+ - lib/vdom/version.rb
50
+ - opal/vdom.rb
51
+ - opal/vdom/component.rb
52
+ - opal/vdom/content.rb
53
+ - opal/vdom/instance.rb
54
+ - opal/vdom/registry.rb
55
+ - opal/vdom/renderer.rb
56
+ - opal/vdom/table.rb
57
+ - opal/vdom/table_column.rb
58
+ - opal/vdom/util.rb
59
+ homepage: https://github.com/balmoral/vdom-rb
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Adaptation and extension of Clearwater Ruby web framework
83
+ test_files: []
84
+ has_rdoc: