archival 0.0.5 → 0.0.6

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
2
  SHA256:
3
- metadata.gz: 7c29406fcec39c52b6876b805dba5509d6f43da5805944a344b2c771214cd8ed
4
- data.tar.gz: 7319f9d6dace6b20c57e318d4df1c4dc80c1bd67673cee1b37d9a17ba35f823b
3
+ metadata.gz: 823433cd1bdae7bc4e3a6179451a875e7fbe5de17c4ceaa8a0b246cdd9fa3b61
4
+ data.tar.gz: 778ef490bf23365d6e1fa1207d0f959ead5a59edbaebebeebe16837981a6c230
5
5
  SHA512:
6
- metadata.gz: e05e6573f3e580d3a364826b7fd604559f2513e609a5436ba4170d606112d913e91d3cc0ec5498f4e0c418212b85068d7d859829030ee8b113a8909b04020e64
7
- data.tar.gz: 8c227320c6d961595b5ce545559df4cdddf42e1d27819c1e5013b1e8189932bb50b4047e47bc5f85c8af1b0109a9b582063e487fb926132248d766b19fc98498
6
+ metadata.gz: cbbbd3c0ef92fabfcc08608adc376ce1272c36e30aa6f3b6d9e12d0ce5b9dd781b1fac4663262b144a85fe42ad951df396004f08518059820f6fc0c45d8a082c
7
+ data.tar.gz: fee79490a8d086eee8779e985483f0b80e75b1ec0df657eb19ed8c74a3a2e5590a8c2e4f74f20ce529e1536e204c3f62574cc5c6ac777bc38c07ebcd1723f3b4
data/archival.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'archival'
5
- s.version = '0.0.5'
5
+ s.version = '0.0.6'
6
6
  s.summary = 'An incredibly simple CMS for durable websites'
7
7
  s.description = 'https://jesseditson.com/the-simplest-cms-part-1'
8
8
  s.authors = ['Jesse Ditson']
@@ -9,6 +9,9 @@ Liquid::Template.error_mode = :strict
9
9
  Liquid::Template.register_tag('layout', Layout)
10
10
 
11
11
  module Archival
12
+ class DuplicateKeyError < StandardError
13
+ end
14
+
12
15
  class Builder
13
16
  attr_reader :page_templates
14
17
 
@@ -110,14 +113,16 @@ module Archival
110
113
  end
111
114
 
112
115
  def sort_objects(objects)
113
- # Since objects are hashes but we'd like them to be iterable based on
114
- # arbitrary "order" keys, and in ruby hashes enumerate in insert order,
115
- # we just need to re-insert in the correct order.
116
- sorted_keys = objects.sort_by do |name, obj|
117
- obj['order'].to_s || name
116
+ # Sort by either 'order' key or object name, depending on what is
117
+ # available.
118
+ sorted_by_keys = objects.sort_by do |name, obj|
119
+ obj.key?('order') ? obj['order'].to_s : name
118
120
  end
119
- sorted_objects = {}
120
- sorted_keys.each do |d|
121
+ sorted_objects = Archival::TemplateArray.new
122
+ sorted_by_keys.each do |d|
123
+ raise DuplicateKeyError if sorted_objects.key?(d[0])
124
+
125
+ sorted_objects.push(d[1])
121
126
  sorted_objects[d[0]] = d[1]
122
127
  end
123
128
  sorted_objects
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archival
4
+ class TemplateArray < Array
5
+ alias subscript_access []
6
+ alias subscript_write []=
7
+
8
+ def initialize(*args)
9
+ super(*args)
10
+ @data = {}
11
+ end
12
+
13
+ def [](*args)
14
+ key = args[0]
15
+ return @data[key] if key.is_a? String
16
+ return @data[key] if key.is_a? Symbol
17
+
18
+ subscript_access(*args)
19
+ end
20
+
21
+ def []=(*args)
22
+ key = args[0]
23
+ if key.is_a?(String) || key.is_a?(Symbol)
24
+ @data[key] = args[1]
25
+ return
26
+ end
27
+ subscript_write(*args)
28
+ end
29
+
30
+ def key?(key)
31
+ @data.key?(key)
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Archival
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.6'
5
5
  end
data/lib/archival.rb CHANGED
@@ -5,6 +5,7 @@ module Archival
5
5
  end
6
6
 
7
7
  require 'archival/version'
8
+ require 'archival/template_array'
8
9
  require 'archival/logger'
9
10
  require 'archival/config'
10
11
  require 'archival/helper_server'
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archival",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "An incredibly simple CMS for durable websites",
5
5
  "bin": "build.rb",
6
6
  "directories": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archival
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Ditson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-07 00:00:00.000000000 Z
11
+ date: 2021-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -105,6 +105,7 @@ files:
105
105
  - lib/archival/listen.rb
106
106
  - lib/archival/logger.rb
107
107
  - lib/archival/rake_tasks.rb
108
+ - lib/archival/template_array.rb
108
109
  - lib/archival/version.rb
109
110
  - lib/tags/layout.rb
110
111
  - package.json