grand_central-dev_tools 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: d064f30d62199d135226b937cef4b0787b505e78923ce4f599cd0666eb2f2c21
4
- data.tar.gz: d093c0b24c760641a110a8470d6157a2b2b9f770e574d99da34b0afc039f1eb6
2
+ SHA1:
3
+ metadata.gz: 6ad719db4ae179ed632575a58957572dd3c7bd48
4
+ data.tar.gz: e91f7d6b6238760d22d0d2e9048a9369076a016d
5
5
  SHA512:
6
- metadata.gz: 4e5a4f0125d8d055377535b2d401093f1cb6cbbc5d32e0bdfde24ef41ee70077351d110d155ecbe31404d0204bcee198a6a32e3700719d5488b4fdc5568a57af
7
- data.tar.gz: 546eec823b0c2290f6b5bcbc8332c12d3bb3bcc804be02848329128c9b6975564727948ce9cf05e330b887d946f68ad023a1bec8a44092962c15cb4b8c2db2b9
6
+ metadata.gz: f7497c238832791ea4a311fd5e99706d5010296f4a1f932322300d668e084cb85af2d8363334ed700e8c90e54af836eab8d6c9f9f7110be134f98043570fd5f9
7
+ data.tar.gz: 8715a8108d8b3c3bb3a2de33a3e14333233f33e243b3f78a42283ecfe0f34fd7309c53e73a734acd902a49a6fbc8204b907e3f2064470a24ff2c4c9da7550066
@@ -1,5 +1,5 @@
1
1
  module GrandCentral
2
2
  module DevTools
3
- VERSION = "0.1.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -221,20 +221,82 @@ module GrandCentral
221
221
  end
222
222
 
223
223
  class ArrayPresenter < Presenter
224
+ SEGMENT_SIZE = 100
225
+
224
226
  alias array model
225
227
 
226
228
  def render
227
229
  div({ style: { display: 'inline-block' } }, [
228
230
  '[',
229
- button({ onclick: set(:show_contents, !@show_contents) }, @show_contents ? '-' : "#{array.count} items"),
231
+ button({ onclick: set(:show_contents, !@show_contents) }, [
232
+ @show_contents ? '-' : "#{array.count} items",
233
+ ]),
234
+
230
235
  if @show_contents
231
236
  div({ style: { padding_left: '1em' } }, [
232
- array.map { |item| div(serialize_value(item)) },
237
+ if array.size > SEGMENT_SIZE
238
+ segments
239
+ else
240
+ array.map { |item| div(serialize_value(item)) }
241
+ end
233
242
  ])
234
243
  end,
244
+
235
245
  ']',
236
246
  ])
237
247
  end
248
+
249
+ def segments
250
+ array.each_slice(SEGMENT_SIZE).map.with_index do |slice, index|
251
+ start = SEGMENT_SIZE * index
252
+ finish = start + slice.size
253
+ Segment.memoize(slice, self, start...finish, open: index.zero? && slice.size < SEGMENT_SIZE)
254
+ end
255
+ end
256
+
257
+ class Segment < Presenter
258
+ attr_reader :segment
259
+
260
+ def initialize segment, presenter, range, open: false
261
+ update segment, presenter, range
262
+ @open = open
263
+ end
264
+
265
+ def update segment, presenter, range
266
+ return unless segment
267
+
268
+ @segment = segment
269
+ @presenter = presenter
270
+ @range = range
271
+ end
272
+
273
+ def render
274
+ `console.log('render', self)`
275
+ div([
276
+ if open?
277
+ [
278
+ button({ onclick: set { @open = false } }, '-'),
279
+ segment.map do |item|
280
+ div(serialize_value(item))
281
+ end
282
+ ]
283
+ else
284
+ button({ onclick: set { @open = true } }, @range.inspect)
285
+ end
286
+ ])
287
+ end
288
+
289
+ def open?
290
+ @open
291
+ end
292
+
293
+ def set
294
+ proc do
295
+ yield
296
+ update_self
297
+ end
298
+ end
299
+ end
238
300
  end
239
301
 
240
302
  class HashPresenter < Presenter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grand_central-dev_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-17 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.7.2
96
+ rubygems_version: 2.6.12
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Client-side developer tools for GrandCentral