jekyll-hoffnung3000 0.1.1 → 0.1.6

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: d6630aa726ab2e6ad28944ed5780e56ba5b4f9e979289f979fa58b2aed0dc8a6
4
- data.tar.gz: 74944851ec91b1ee14977e767535c1326192264a34e9838a56bfdb26a6a39836
3
+ metadata.gz: f2a5409fe15d67faa1f7524ad40c9b61f6c001f03560f1be84091894c49a43b2
4
+ data.tar.gz: c8cd79f795e4e1b6139249a29800c243df4b8009b7b990c6472e66704ab84c68
5
5
  SHA512:
6
- metadata.gz: 976f514d2dd55c88ee1143b4242ab224c499ade3e31b8071f86a0b135254d9280671abfdc882de919c257367ea8a6935471be29f94bd7147b6c2441755aefbcd
7
- data.tar.gz: 9cacd945628470e8cb4e154e5be3ceec4f60d8d061899ff1f67428ee1007b13f89124ab2a96fbde0ee198aaa33ff31ec504924a1352de9f46b37a5001ef2d797
6
+ metadata.gz: a0ca3f2cc8c25214e843b8633fc93ee83b3e5a0bab1367f6c732524a559cb1189be4af2000692011825c990c72a8fd3846baf9373b3afc60c30a093d15df5af9
7
+ data.tar.gz: a2ced895c8318d0c9c17105e4bdf7795b9b28810a66d161186b884025f0c58b749abe9e35837090d8d1a1daebacb48e80246c522ce0da5ce96da08172a543bd3
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.1)
4
+ jekyll-hoffnung3000 (0.1.6)
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
@@ -40,6 +40,58 @@ With this config set you can use the command line to fetch event data which will
40
40
  $ bundle exec jekyll hoffnung3000 events
41
41
  ```
42
42
 
43
+ Events are formatted in the following way as array of JSON objects:
44
+
45
+ ```json
46
+ [
47
+ {
48
+ "title": "Anti-Capitalist Knitting",
49
+ "description": "Anti-Capitalist Knitting is an experimental knitting workshop with an emphasis on sustainability, focusing on exploring materials and using simple techniques to create artwork........",
50
+ "date": "2020-06-06",
51
+ "time": {
52
+ "from": "2020-06-06T10:00:00.000Z",
53
+ "to": "2020-06-06T12:00:00.000Z"
54
+ },
55
+ "organiser": {
56
+ "name": "Name of Organiser",
57
+ },
58
+ "place": {
59
+ "id": 1,
60
+ "name": "museum of neoliberalism [online location]",
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......",
62
+ "area": "London"
63
+ },
64
+ "imageUrl": "https://image-url/medium.jpg",
65
+ "tags": [
66
+ "Workshop",
67
+ "Art",
68
+ "Anticapitalism",
69
+ "Mental-health",
70
+ "Gender",
71
+ "Feminism"
72
+ ],
73
+ "websiteUrl": "https://event-website.org"
74
+ }
75
+ ]
76
+ ```
77
+
78
+ Places are formatted in the following way as array of JSON objects:
79
+
80
+ ```json
81
+ [
82
+ {
83
+ "id": 1,
84
+ "title": "Place name",
85
+ "description": "Description of this place",
86
+ "street": "1 Street",
87
+ "cityCode": "XXX123",
88
+ "city": "City",
89
+ "country": "Country",
90
+ "imageUrl": "https://image-url/medium.jpg"
91
+ }
92
+ ]
93
+ ```
94
+
43
95
  ## Development
44
96
 
45
97
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
@@ -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,48 +1,6 @@
1
- require "http"
2
- require "jq"
3
- require "json"
1
+ # frozen_string_literal: true
4
2
 
5
- FORMAT_STRING =
6
- ".data[] |
7
- {
8
- title: .title,
9
- description: .description,
10
- date: .date, time:
11
- {
12
- from: .slots[0].from,
13
- to: .slots[-1].to
14
- },
15
- organiser:
16
- {
17
- name: .animal.userName,
18
- about: .organiser_biog
19
- },
20
- venue:
21
- {
22
- id: null,
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
- def write_data(data, file_name)
34
- Dir.mkdir("_data") unless Dir.exist?("_data")
35
- File.write(format("_data/%s.json", file_name), JSON.generate(data))
36
- end
37
-
38
- def check_config(config)
39
- raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 block" unless config["hoffnung3000"]
40
- unless config["hoffnung3000"]["url"]
41
- raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 > url value"
42
- end
43
-
44
- config
45
- end
3
+ require_relative "../hoffnung3000/main"
46
4
 
47
5
  module Jekyll
48
6
  module Commands
@@ -56,10 +14,19 @@ module Jekyll
56
14
  c.command(:events) do |f|
57
15
  f.description "Fetch all events and write to _data folder as events.json."
58
16
  f.action do |_args, _options|
59
- config = check_config(Jekyll.configuration({}))
60
- response = HTTP.get(format("%s/api/events", config["hoffnung3000"]["url"]))
61
- jq = JQ(response.body, parse_json: true)
62
- write_data(jq.search(FORMAT_STRING), "events")
17
+ get_hoffnung(Jekyll.configuration({}), "events")
18
+ end
19
+ end
20
+ c.command(:places) do |f|
21
+ f.description "Fetch all places and write to _data folder as places.json."
22
+ f.action do |_args, _options|
23
+ get_hoffnung(Jekyll.configuration({}), "places")
24
+ end
25
+ end
26
+ c.command(:places) do |f|
27
+ f.description "Fetch festival meta data and write to _data folder as meta.json."
28
+ f.action do |_args, _options|
29
+ get_hoffnung(Jekyll.configuration({}), "meta")
63
30
  end
64
31
  end
65
32
  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,97 @@
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
+ FORMAT_STRING_META =
52
+ ".config |
53
+ {
54
+ title: .title,
55
+ description: .description,
56
+ }
57
+ "
58
+
59
+ SEARCH_STRINGS = {
60
+ "events" => FORMAT_STRING_EVENTS,
61
+ "places" => FORMAT_STRING_PLACES,
62
+ "meta" => FORMAT_STRING_META
63
+ }.freeze
64
+
65
+ def format_data(data, key)
66
+ jq = JQ(data, parse_json: true)
67
+ jq.search(SEARCH_STRINGS[key])
68
+ end
69
+
70
+ def write_data(data, file_name)
71
+ Dir.mkdir("_data") unless Dir.exist?("_data")
72
+ File.write(format("_data/%s.json", file_name), JSON.generate(data))
73
+ end
74
+
75
+ def check_config(config)
76
+ raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 block" unless config["hoffnung3000"]
77
+ unless config["hoffnung3000"]["url"]
78
+ raise "HOFFNUNG3000 Error: Jekyl _config.yml file must contain a hoffnung3000 > url value"
79
+ end
80
+
81
+ config
82
+ end
83
+
84
+ def url(config)
85
+ check_config(config)["hoffnung3000"]["url"]
86
+ end
87
+
88
+ def fetch_data(url, key)
89
+ HTTP.get(format("%<url>s/api/%<key>s", { url: url, key: key }), { params: { limit: RESULT_LIMIT } }).body
90
+ end
91
+
92
+ def get_hoffnung(config, key)
93
+ url = url(config)
94
+ data = fetch_data(url, key)
95
+ formatted_data = format_data(data, key)
96
+ write_data(formatted_data, key)
97
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Hoffnung3000
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.6"
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.1
4
+ version: 0.1.6
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,10 @@ files:
69
111
  - Rakefile
70
112
  - bin/console
71
113
  - bin/setup
72
- - jekyll-hoffnung3000-0.1.0.gem
73
114
  - jekyll-hoffnung3000.gemspec
74
115
  - lib/jekyll/commands/hoffnung3000.rb
75
116
  - lib/jekyll/hoffnung3000.rb
117
+ - lib/jekyll/hoffnung3000/main.rb
76
118
  - lib/jekyll/hoffnung3000/version.rb
77
119
  homepage: https://github.com/sandreae/jekyll-hoffnung3000
78
120
  licenses:
@@ -87,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
129
  requirements:
88
130
  - - ">="
89
131
  - !ruby/object:Gem::Version
90
- version: 2.4.0
132
+ version: 2.7.0
91
133
  required_rubygems_version: !ruby/object:Gem::Requirement
92
134
  requirements:
93
135
  - - ">="
Binary file