obf 0.6.4 → 0.6.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 +4 -4
- data/lib/obf.rb +1 -0
- data/lib/obf/external.rb +2 -1
- data/lib/obf/sgrid.rb +148 -0
- data/lib/obf/unknown_file.rb +2 -0
- data/lib/obf/utils.rb +9 -2
- data/lib/obf/validator.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b79ac939f92a647ac73653cccb8609eebc16aace
|
4
|
+
data.tar.gz: 0b710379e5f53177b90aebbbe93de11809ec0b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d1090c6ca796b367d744564a6acf250ee0c57f4c380d4a3f10d365d23dd6cd854b33727fb721bc5cfd5c9e415346f0d089559847aeca6d86597be1790448214
|
7
|
+
data.tar.gz: d6ec22573bb37ac5eee8d7320894764317eda2e9039094413a04cd3093a1a415da089c7fd0566be60cbd40c502787466bcd3928e91dfdb759c98d35529a69214
|
data/lib/obf.rb
CHANGED
data/lib/obf/external.rb
CHANGED
@@ -120,11 +120,12 @@ module OBF::External
|
|
120
120
|
'duration' => original_sound['duration'],
|
121
121
|
'license' => OBF::Utils.parse_license(original_sound['license']),
|
122
122
|
'url' => original_sound['url'],
|
123
|
+
'data' => original_sound['data'],
|
123
124
|
'data_url' => original_sound['data_url'],
|
124
125
|
'content_type' => original_sound['content_type']
|
125
126
|
}
|
126
127
|
if !path_hash
|
127
|
-
sound['data'] = OBF::Utils.sound_base64(sound['url'])
|
128
|
+
sound['data'] = OBF::Utils.sound_base64(sound['url']) if sound['url']
|
128
129
|
else
|
129
130
|
if path_hash['sounds'] && path_hash['sounds'][sound['id']]
|
130
131
|
sound['path'] = path_hash['sounds'][sound['id']]['path']
|
data/lib/obf/sgrid.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
module OBF::Sgrid
|
2
|
+
EXT_PREFIX = 'ext_sgrid_'
|
3
|
+
|
4
|
+
def self.html_at(elem, css)
|
5
|
+
res = elem.css(css)[0]
|
6
|
+
if res && res.inner_html && res.inner_html.length > 0
|
7
|
+
res.inner_html
|
8
|
+
else
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.to_external(path)
|
14
|
+
xml = Nokogiri::XML(File.open(path))
|
15
|
+
grid = xml.css('sensorygrid grid')[0]
|
16
|
+
puts grid.to_s
|
17
|
+
puts grid.css('rows')[0].to_s
|
18
|
+
rows = html_at(grid, 'rows').to_i
|
19
|
+
columns = html_at(grid, 'cols').to_i
|
20
|
+
board = {
|
21
|
+
'id' => 'sgrid'
|
22
|
+
}
|
23
|
+
['selfclosing', 'titlebartext', 'customblockscan', 'predictionsource', 'oskcellratio', 'workspace_x', 'workspace_y', 'eyegazemonitor_x', 'eyegazemonitor_y'].each do |attr|
|
24
|
+
res = html_at(grid, attr)
|
25
|
+
board[EXT_PREFIX + attr] = res if res
|
26
|
+
end
|
27
|
+
if grid.css('background')[0]
|
28
|
+
bg = grid.css('background')[0]
|
29
|
+
board['ext_sgrid_background'] = {
|
30
|
+
'style' => bg['style'],
|
31
|
+
'backcolour' => html_at(bg, 'backcolour'),
|
32
|
+
'backcolour2' => html_at(bg, 'backcolour2'),
|
33
|
+
'picformat' => html_at(bg, 'picformat'),
|
34
|
+
'tilepicture' => html_at(bg, 'tilepicture')
|
35
|
+
}
|
36
|
+
end
|
37
|
+
commands = grid.children.detect{|c| c.name == 'commands'}
|
38
|
+
if commands
|
39
|
+
board['ext_sgrid_commands'] = []
|
40
|
+
commands.css('command').each do |command|
|
41
|
+
|
42
|
+
id = html_at(command, 'id')
|
43
|
+
board[EXT_PREFIX + 'commands'] << id if id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
board['name'] = board[EXT_PREFIX + 'titlebartext'] || "board"
|
48
|
+
board['grid'] = {
|
49
|
+
'rows' => rows,
|
50
|
+
'columns' => columns,
|
51
|
+
'order' => []
|
52
|
+
}
|
53
|
+
rows.times do |i|
|
54
|
+
row = []
|
55
|
+
columns.times do |j|
|
56
|
+
row << nil
|
57
|
+
end
|
58
|
+
board['grid']['order'] << row
|
59
|
+
end
|
60
|
+
|
61
|
+
buttons = []
|
62
|
+
images = []
|
63
|
+
button_id = 0
|
64
|
+
image_id = 0
|
65
|
+
grid.css('cells cell').each do |cell|
|
66
|
+
button = {
|
67
|
+
'id' => button_id
|
68
|
+
}
|
69
|
+
button_id += 1
|
70
|
+
row = cell['x'].to_i - 1
|
71
|
+
col = cell['y'].to_i - 1
|
72
|
+
['stylepreset', 'scanblock', 'magnifyx', 'magnifyy', 'tooltip', 'directactivate'].each do |attr|
|
73
|
+
res = html_at(cell, attr)
|
74
|
+
button[EXT_PREFIX + attr] = res if res
|
75
|
+
end
|
76
|
+
preset = button[EXT_PREFIX + 'stylepreset']
|
77
|
+
if preset == 'Blank cell (no style)'
|
78
|
+
button['background_color'] = 'rgb(255, 255, 255)'
|
79
|
+
button['border_color'] = 'rgb(150, 150, 150)'
|
80
|
+
elsif preset == 'Jump cell'
|
81
|
+
button['background_color'] = 'rgb(200, 225, 255)'
|
82
|
+
button['border_color'] = 'rgb(95, 135, 185)'
|
83
|
+
elsif preset == 'Action cell'
|
84
|
+
button['background_color'] = 'rgb(255, 200, 200)'
|
85
|
+
button['border_color'] = 'rgb(155, 75, 75)'
|
86
|
+
elsif preset == 'Vocab cell'
|
87
|
+
button['background_color'] = 'rgb(255, 255, 155)'
|
88
|
+
button['border_color'] = 'rgb(150, 135, 32)'
|
89
|
+
end
|
90
|
+
|
91
|
+
button['label'] = html_at(cell, 'caption')
|
92
|
+
button[EXT_PREFIX + 'commands'] = []
|
93
|
+
cell.css('commands command').each do |command|
|
94
|
+
type = html_at(command, 'id')
|
95
|
+
params = []
|
96
|
+
command.css('parameter').each do |param|
|
97
|
+
idx = param['index'].to_i - 1
|
98
|
+
val = param.inner_html
|
99
|
+
params[idx] = val
|
100
|
+
end
|
101
|
+
button[EXT_PREFIX + 'commands'] << {
|
102
|
+
'type' => type,
|
103
|
+
'parameters' => params
|
104
|
+
}
|
105
|
+
if type == 'type'
|
106
|
+
button['vocalization'] = params[0]
|
107
|
+
elsif type == 'action.clear'
|
108
|
+
button['action'] = ':clear'
|
109
|
+
else
|
110
|
+
button['action'] = ":" + EXT_PREFIX + type
|
111
|
+
end
|
112
|
+
end
|
113
|
+
button.delete(EXT_PREFIX + 'commands') if button[EXT_PREFIX + 'commands'].length == 0
|
114
|
+
hidden = html_at(cell, 'hidden')
|
115
|
+
button['hidden'] = true if hidden == 'true'
|
116
|
+
picture = html_at(cell, 'picture')
|
117
|
+
if picture
|
118
|
+
image = {
|
119
|
+
'id' => image_id
|
120
|
+
}
|
121
|
+
image_id += 1
|
122
|
+
puts picture.to_json
|
123
|
+
match = picture.match(/^(\[\w+\])?(.+)$/)
|
124
|
+
symbol_set = match && match[1][1..-2]
|
125
|
+
filename = match && match[2]
|
126
|
+
if symbol_set
|
127
|
+
image['symbol'] = {
|
128
|
+
'set' => symbol_set,
|
129
|
+
'filename' => filename
|
130
|
+
}
|
131
|
+
else
|
132
|
+
image[EXT_PREFIX + 'filename'] = filename
|
133
|
+
end
|
134
|
+
images << image
|
135
|
+
button['image_id'] = image['id']
|
136
|
+
end
|
137
|
+
|
138
|
+
col = cell['x'].to_i - 1
|
139
|
+
row = cell['y'].to_i - 1
|
140
|
+
buttons << button
|
141
|
+
board['grid']['order'][row][col] = button['id']
|
142
|
+
end
|
143
|
+
board['buttons'] = buttons
|
144
|
+
board['images'] = images
|
145
|
+
board['sounds'] = []
|
146
|
+
return board
|
147
|
+
end
|
148
|
+
end
|
data/lib/obf/unknown_file.rb
CHANGED
data/lib/obf/utils.rb
CHANGED
@@ -56,6 +56,14 @@ module OBF::Utils
|
|
56
56
|
rescue CFFormatError => e
|
57
57
|
end
|
58
58
|
|
59
|
+
xml = Nokogiri::XML(File.open(path)) rescue nil
|
60
|
+
if xml && xml.children.length > 0
|
61
|
+
if xml.children[0].name == 'sensorygrid'
|
62
|
+
return :sgrid
|
63
|
+
end
|
64
|
+
return :unknown
|
65
|
+
end
|
66
|
+
|
59
67
|
begin
|
60
68
|
type = nil
|
61
69
|
load_zip(path) do |zipper|
|
@@ -73,8 +81,7 @@ module OBF::Utils
|
|
73
81
|
end
|
74
82
|
end
|
75
83
|
return type if type
|
76
|
-
rescue => e
|
77
|
-
return :unknown
|
84
|
+
rescue Zip::Error => e
|
78
85
|
end
|
79
86
|
end
|
80
87
|
return :unknown
|
data/lib/obf/validator.rb
CHANGED
@@ -518,7 +518,7 @@ module OBF
|
|
518
518
|
err "button.action must start with either : or + if defined"
|
519
519
|
end
|
520
520
|
|
521
|
-
attrs = ['id', 'label', 'vocalization', 'image_id', 'hidden', 'background_color', 'border_color', 'action', 'load_board', 'top', 'left', 'width', 'height']
|
521
|
+
attrs = ['id', 'label', 'vocalization', 'image_id', 'sound_id', 'hidden', 'background_color', 'border_color', 'action', 'load_board', 'top', 'left', 'width', 'height']
|
522
522
|
button.keys.each do |key|
|
523
523
|
if !attrs.include?(key) && !key.match(/^ext_/)
|
524
524
|
warn "button.#{key} attribute is not defined in the spec, should be prefixed with ext_yourapp_"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Whitmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: nokogiri
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,7 @@ files:
|
|
140
154
|
- lib/obf/picto4me.rb
|
141
155
|
- lib/obf/png.rb
|
142
156
|
- lib/obf/sfy.rb
|
157
|
+
- lib/obf/sgrid.rb
|
143
158
|
- lib/obf/unknown_file.rb
|
144
159
|
- lib/obf/utils.rb
|
145
160
|
- lib/obf/validator.rb
|