jekyll-hoffnung3000 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c5a4f59df3c87b08e68a6dfb503901c8ba059546a7002caa386ef75409b5c74
4
- data.tar.gz: 9b1756b27919c814b03b6765b09352949c70006b945c09c23b63d2ead8dea52b
3
+ metadata.gz: 900de1232ed4b87553086d329796858fbae51151ddfa0de1ef09dd82c5b01800
4
+ data.tar.gz: c9d780f620b6a757c0b6aca6f601fb5d1df78432e3a1df9d977bc8d10a1ed809
5
5
  SHA512:
6
- metadata.gz: 62b94a67b662ccc94fda0b786a60dfd8402e5bbf8e01667ec15372faa366294e866ec1aa099525a0d33b6f9a484a54f0e554fde2f4a7ee26f1ed531bf4a36771
7
- data.tar.gz: 2acfc4d543a46fa75e3f5c80b2b53cc32d1835042b9bf132b18c210196641b5cbd202d07e74ee104b6d53e8fcba8ef48178687df924d3fa71826e34bfb1d5bd7
6
+ metadata.gz: 41b5fdd9d9482e2aa90083ae4356c713198821459eabd9446f7797b0ed61eb6ade20a124974702e3b1a3ceacbd4626d6dc95ccc45a31d4583dedff1168ed64f5
7
+ data.tar.gz: 4e2cc2a73606cd8a00ee281b2fcde7aab039eea1b6acfc11144efccf51d63d915d301a79d705b88971a28a4ac2d74aade58d22dfb6008c306079253c17b01694
data/Gemfile CHANGED
@@ -4,7 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in jekyll-hoffnung3000.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rubocop", "~> 1.7"
data/Gemfile.lock CHANGED
@@ -1,9 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-hoffnung3000 (0.1.3)
4
+ jekyll-hoffnung3000 (0.1.4)
5
5
  http (~> 4.4.1)
6
+ jekyll (~> 4.2)
6
7
  json (~> 2.5.1)
8
+ rake (~> 13.0)
9
+ rubocop (~> 1.7)
7
10
  ruby-jq (~> 0.2.1)
8
11
 
9
12
  GEM
@@ -12,12 +15,19 @@ GEM
12
15
  addressable (2.7.0)
13
16
  public_suffix (>= 2.0.2, < 5.0)
14
17
  ast (2.4.2)
18
+ colorator (1.1.0)
19
+ concurrent-ruby (1.1.9)
15
20
  domain_name (0.5.20190701)
16
21
  unf (>= 0.0.5, < 1.0.0)
22
+ em-websocket (0.5.2)
23
+ eventmachine (>= 0.12.9)
24
+ http_parser.rb (~> 0.6.0)
25
+ eventmachine (1.2.7)
17
26
  ffi (1.15.1)
18
27
  ffi-compiler (1.0.1)
19
28
  ffi (>= 1.0.0)
20
29
  rake
30
+ forwardable-extended (2.6.0)
21
31
  http (4.4.1)
22
32
  addressable (~> 2.3)
23
33
  http-cookie (~> 1.0)
@@ -28,17 +38,54 @@ GEM
28
38
  http-form_data (2.3.0)
29
39
  http-parser (1.2.3)
30
40
  ffi-compiler (>= 1.0, < 2.0)
41
+ http_parser.rb (0.6.0)
42
+ i18n (1.8.10)
43
+ concurrent-ruby (~> 1.0)
44
+ jekyll (4.2.0)
45
+ addressable (~> 2.4)
46
+ colorator (~> 1.0)
47
+ em-websocket (~> 0.5)
48
+ i18n (~> 1.0)
49
+ jekyll-sass-converter (~> 2.0)
50
+ jekyll-watch (~> 2.0)
51
+ kramdown (~> 2.3)
52
+ kramdown-parser-gfm (~> 1.0)
53
+ liquid (~> 4.0)
54
+ mercenary (~> 0.4.0)
55
+ pathutil (~> 0.9)
56
+ rouge (~> 3.0)
57
+ safe_yaml (~> 1.0)
58
+ terminal-table (~> 2.0)
59
+ jekyll-sass-converter (2.1.0)
60
+ sassc (> 2.0.1, < 3.0)
61
+ jekyll-watch (2.2.1)
62
+ listen (~> 3.0)
31
63
  json (2.5.1)
64
+ kramdown (2.3.1)
65
+ rexml
66
+ kramdown-parser-gfm (1.1.0)
67
+ kramdown (~> 2.0)
68
+ liquid (4.0.3)
69
+ listen (3.5.1)
70
+ rb-fsevent (~> 0.10, >= 0.10.3)
71
+ rb-inotify (~> 0.9, >= 0.9.10)
72
+ mercenary (0.4.0)
32
73
  mini_portile2 (2.6.1)
33
74
  multi_json (1.15.0)
34
75
  parallel (1.20.1)
35
76
  parser (3.0.1.1)
36
77
  ast (~> 2.4.1)
78
+ pathutil (0.16.2)
79
+ forwardable-extended (~> 2.6)
37
80
  public_suffix (4.0.6)
38
81
  rainbow (3.0.0)
39
82
  rake (13.0.3)
83
+ rb-fsevent (0.11.0)
84
+ rb-inotify (0.10.1)
85
+ ffi (~> 1.0)
40
86
  regexp_parser (2.1.1)
41
87
  rexml (3.2.5)
88
+ rouge (3.26.0)
42
89
  rubocop (1.16.1)
43
90
  parallel (~> 1.10)
44
91
  parser (>= 3.0.0.0)
@@ -54,18 +101,21 @@ GEM
54
101
  mini_portile2 (>= 2.2.0)
55
102
  multi_json
56
103
  ruby-progressbar (1.11.0)
104
+ safe_yaml (1.0.5)
105
+ sassc (2.4.0)
106
+ ffi (~> 1.9)
107
+ terminal-table (2.0.0)
108
+ unicode-display_width (~> 1.1, >= 1.1.1)
57
109
  unf (0.1.4)
58
110
  unf_ext
59
111
  unf_ext (0.0.7.7)
60
- unicode-display_width (2.0.0)
112
+ unicode-display_width (1.7.0)
61
113
 
62
114
  PLATFORMS
63
115
  x86_64-linux
64
116
 
65
117
  DEPENDENCIES
66
118
  jekyll-hoffnung3000!
67
- rake (~> 13.0)
68
- rubocop (~> 1.7)
69
119
 
70
120
  BUNDLED WITH
71
121
  2.2.19
data/README.md CHANGED
@@ -55,7 +55,7 @@ Events are formatted in the following way as array of JSON objects:
55
55
  "organiser": {
56
56
  "name": "Name of Organiser",
57
57
  },
58
- "venue": {
58
+ "place": {
59
59
  "id": 1,
60
60
  "name": "museum of neoliberalism [online location]",
61
61
  "description": "A small, free museum about how an obscure and extreme ideological cult of the 1970s rose to power and now shapes our lives in dramatic and often terrible ways......",
data/Rakefile CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rubocop/rake_task"
5
+ require "rake/testtask"
5
6
 
6
7
  RuboCop::RakeTask.new
7
8
 
9
+ Rake::TestTask.new do |t|
10
+ t.libs << "hoffnung3000"
11
+ end
12
+ desc "Run HOFFNUNG3000 tests"
13
+
8
14
  task default: :rubocop
Binary file
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "HOFFNUNG3000 archival tool"
12
12
  spec.homepage = "https://github.com/sandreae/jekyll-hoffnung3000"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.4.0"
14
+ spec.required_ruby_version = ">= 2.7.0"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
 
@@ -27,8 +27,11 @@ Gem::Specification.new do |spec|
27
27
  # Uncomment to register a new dependency of your gem
28
28
  # spec.add_dependency "example-gem", "~> 1.0"
29
29
  spec.add_dependency "http", "~> 4.4.1"
30
- spec.add_dependency "ruby-jq", "~> 0.2.1"
30
+ spec.add_dependency "jekyll", "~> 4.2"
31
31
  spec.add_dependency "json", "~> 2.5.1"
32
+ spec.add_dependency "rake", "~> 13.0"
33
+ spec.add_dependency "rubocop", "~> 1.7"
34
+ spec.add_dependency "ruby-jq", "~> 0.2.1"
32
35
 
33
36
  # For more information and examples about making a new gem, checkout our
34
37
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,62 +1,6 @@
1
- require "http"
2
- require "jq"
3
- require "json"
1
+ # frozen_string_literal: true
4
2
 
5
- FORMAT_STRING_EVENTS =
6
- ".data[] |
7
- {
8
- title: .title,
9
- description: .description,
10
- date: .slots[0].from | split(\"T\")[0],
11
- time:
12
- {
13
- from: .slots[0].from,
14
- to: .slots[-1].to
15
- },
16
- organiser:
17
- {
18
- name: .animal.userName,
19
- },
20
- place:
21
- {
22
- id: .place.id,
23
- name: .place.title,
24
- description: .place.description,
25
- area: .place.city
26
- },
27
- imageUrl:.images[0].mediumImageUrl,
28
- tags:.tags,
29
- websiteUrl: .websiteUrl
30
- }
31
- ".freeze
32
-
33
- FORMAT_STRING_PLACES =
34
- ".data[] |
35
- {
36
- id: .id,
37
- title: .title,
38
- description: .description,
39
- street: .street,
40
- cityCode: .cityCode,
41
- city: .city,
42
- country: .country,
43
- imageUrl:.images[0].mediumImageUrl
44
- }
45
- ".freeze
46
-
47
- def write_data(data, file_name)
48
- Dir.mkdir("_data") unless Dir.exist?("_data")
49
- File.write(format("_data/%s.json", file_name), JSON.generate(data))
50
- end
51
-
52
- def check_config(config)
53
- raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 block" unless config["hoffnung3000"]
54
- unless config["hoffnung3000"]["url"]
55
- raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 > url value"
56
- end
57
-
58
- config
59
- end
3
+ require_relative "../hoffnung3000/main"
60
4
 
61
5
  module Jekyll
62
6
  module Commands
@@ -70,19 +14,13 @@ module Jekyll
70
14
  c.command(:events) do |f|
71
15
  f.description "Fetch all events and write to _data folder as events.json."
72
16
  f.action do |_args, _options|
73
- config = check_config(Jekyll.configuration({}))
74
- response = HTTP.get(format("%s/api/events", config["hoffnung3000"]["url"]))
75
- jq = JQ(response.body, parse_json: true)
76
- write_data(jq.search(FORMAT_STRING_EVENTS), "events")
17
+ get_hoffnung(Jekyll.configuration({}), "events")
77
18
  end
78
19
  end
79
20
  c.command(:places) do |f|
80
21
  f.description "Fetch all places and write to _data folder as places.json."
81
22
  f.action do |_args, _options|
82
- config = check_config(Jekyll.configuration({}))
83
- response = HTTP.get(format("%s/api/places", config["hoffnung3000"]["url"]))
84
- jq = JQ(response.body, parse_json: true)
85
- write_data(jq.search(FORMAT_STRING_PLACES), "places")
23
+ get_hoffnung(Jekyll.configuration({}), "places")
86
24
  end
87
25
  end
88
26
  end
@@ -9,4 +9,4 @@ module Jekyll
9
9
  end
10
10
  end
11
11
 
12
- require "jekyll/commands/hoffnung3000.rb"
12
+ require "jekyll/commands/hoffnung3000"
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "http"
4
+ require "jq"
5
+ require "json"
6
+
7
+ RESULT_LIMIT = 200
8
+
9
+ FORMAT_STRING_EVENTS =
10
+ ".data[] |
11
+ {
12
+ title: .title,
13
+ description: .description,
14
+ date: .slots[0].from | split(\"T\")[0],
15
+ time:
16
+ {
17
+ from: .slots[0].from,
18
+ to: .slots[-1].to
19
+ },
20
+ organiser:
21
+ {
22
+ name: .animal.userName,
23
+ },
24
+ place:
25
+ {
26
+ id: .place.id,
27
+ name: .place.title,
28
+ description: .place.description,
29
+ area: .place.city
30
+ },
31
+ imageUrl:.images[0].mediumImageUrl,
32
+ tags:.tags,
33
+ websiteUrl: .websiteUrl
34
+ }
35
+ "
36
+
37
+ FORMAT_STRING_PLACES =
38
+ ".data[] |
39
+ {
40
+ id: .id,
41
+ title: .title,
42
+ description: .description,
43
+ street: .street,
44
+ cityCode: .cityCode,
45
+ city: .city,
46
+ country: .country,
47
+ imageUrl:.images[0].mediumImageUrl
48
+ }
49
+ "
50
+
51
+ SEARCH_STRINGS = {
52
+ "events" => FORMAT_STRING_EVENTS,
53
+ "places" => FORMAT_STRING_PLACES
54
+ }.freeze
55
+
56
+ def format_data(data, key)
57
+ jq = JQ(data, parse_json: true)
58
+ jq.search(SEARCH_STRINGS[key])
59
+ end
60
+
61
+ def write_data(data, file_name)
62
+ Dir.mkdir("_data") unless Dir.exist?("_data")
63
+ File.write(format("_data/%s.json", file_name), JSON.generate(data))
64
+ end
65
+
66
+ def check_config(config)
67
+ raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 block" unless config["hoffnung3000"]
68
+ unless config["hoffnung3000"]["url"]
69
+ raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 > url value"
70
+ end
71
+
72
+ config
73
+ end
74
+
75
+ def url(config)
76
+ check_config(config)["hoffnung3000"]["url"]
77
+ end
78
+
79
+ def fetch_data(url, key)
80
+ HTTP.get(format("%<url>s/api/%<key>s", { url: url, key: key }), { params: { limit: RESULT_LIMIT } }).body
81
+ end
82
+
83
+ def get_hoffnung(config, key)
84
+ url = url(config)
85
+ data = fetch_data(url, key)
86
+ formatted_data = format_data(data, key)
87
+ write_data(formatted_data, key)
88
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Hoffnung3000
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-hoffnung3000
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sandreae
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-10 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.4.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-jq
28
+ name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.1
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.1
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,48 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.5.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-jq
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.1
55
97
  description:
56
98
  email:
57
99
  - git@contact.samandreae.com
@@ -69,10 +111,11 @@ files:
69
111
  - Rakefile
70
112
  - bin/console
71
113
  - bin/setup
72
- - jekyll-hoffnung3000-0.1.2.gem
114
+ - jekyll-hoffnung3000-0.1.3.gem
73
115
  - jekyll-hoffnung3000.gemspec
74
116
  - lib/jekyll/commands/hoffnung3000.rb
75
117
  - lib/jekyll/hoffnung3000.rb
118
+ - lib/jekyll/hoffnung3000/main.rb
76
119
  - lib/jekyll/hoffnung3000/version.rb
77
120
  homepage: https://github.com/sandreae/jekyll-hoffnung3000
78
121
  licenses:
@@ -87,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
130
  requirements:
88
131
  - - ">="
89
132
  - !ruby/object:Gem::Version
90
- version: 2.4.0
133
+ version: 2.7.0
91
134
  required_rubygems_version: !ruby/object:Gem::Requirement
92
135
  requirements:
93
136
  - - ">="
Binary file