cell_set 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,9 +20,9 @@ module CellSet
20
20
  unless (options.has_key?(:only) && !options[:only].include?("cells")) ||
21
21
  (options.has_key?(:except) && options[:except].include?("cells"))
22
22
  if options[:root]
23
- json.first[1]["cells"] = @cellHash
23
+ json.first[1]["cells"] = encodeHash(@cellHash)
24
24
  else
25
- json["cells"] = @cellHash
25
+ json["cells"] = encodeHash(@cellHash)
26
26
  end
27
27
  end
28
28
  json
@@ -72,15 +72,15 @@ module CellSet
72
72
  cells.each do |cell|
73
73
  if cell.is_a?(Cell)
74
74
  @cellHash[cell.ordinal.to_s] = {
75
- "formatted_value" => cell.formatted_value,
76
- "value" => cell.value
75
+ "formatted_value" => cell.formatted_value,
76
+ "value" => cell.value
77
77
  }
78
78
  else
79
79
  raise ArgumentError
80
80
  end
81
81
  end
82
82
  elsif cells.is_a?(Hash)
83
- @cellHash = cells
83
+ @cellHash = decodeHash(cells)
84
84
  else
85
85
  raise ArgumentError
86
86
  end
@@ -150,6 +150,37 @@ module CellSet
150
150
  private
151
151
  attr_accessor :cellHash
152
152
 
153
+ def decodeHash(hsh)
154
+ newhsh = {}
155
+ hsh.each do |key, value|
156
+ newhsh[key] = {}
157
+ value.each do |key2, value2|
158
+ newhsh[key][key2] = if value2.is_a?(String)
159
+ Base64.urlsafe_decode64(value2)
160
+ else
161
+ value2
162
+ end
163
+ end
164
+ end
165
+ newhsh
166
+ end
167
+
168
+ def encodeHash(hsh)
169
+ newhsh = {}
170
+ hsh.each do |key, value|
171
+ newhsh[key] = {}
172
+ value.each do |key2, value2|
173
+ newhsh[key][key2] = if value2.is_a?(String)
174
+ Base64.urlsafe_encode64(value2)
175
+ else
176
+ value2
177
+ end
178
+ end
179
+ end
180
+ newhsh
181
+ end
182
+
183
+
153
184
  def getCellInternal(pos)
154
185
  cell = @cellHash[pos.to_s]
155
186
  if cell.nil?
@@ -1,3 +1,3 @@
1
1
  module Version
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cell_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-06 00:00:00.000000000Z
12
+ date: 2012-04-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport