drumknott 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +6 -2
- data/Gemfile +3 -1
- data/README.md +1 -2
- data/Rakefile +10 -0
- data/bin/console +2 -1
- data/bin/setup +2 -0
- data/drumknott.gemspec +17 -11
- data/exe/drumknott +4 -2
- data/lib/drumknott.rb +10 -9
- data/lib/drumknott/cli.rb +39 -29
- data/lib/drumknott/include_pages.rb +3 -1
- data/lib/drumknott/keys.rb +7 -5
- data/lib/drumknott/outputs.rb +4 -3
- data/lib/drumknott/outputs/progress_bar.rb +2 -0
- data/lib/drumknott/outputs/silent.rb +3 -1
- data/lib/drumknott/refresh.rb +28 -15
- metadata +36 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 975e98965c58ecfe46625a7c4f3a4fd95db412264699ecff9d2265a113ff78f5
|
4
|
+
data.tar.gz: d0a93ee4dca7922870640460d9432745eb045dbcd4deb209aedf1942a630dfbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3414215d62b5f12a9a0d1add3a9a7d50a1d5d237f24d3a626ab3bc88738f4f1854af4dd8a1b9424d51dc33bf93c92003dedaf4d525010577dd88dc528e0e62
|
7
|
+
data.tar.gz: ed4477254c76c42ae3afc35bfb0dbdd623de4ce471308e44c28d8f50bb63e3c2caab6c413b324cc5692554f25bc7ce09136096957bb96cdd3f029585235de1c1
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/.rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.6
|
6
|
+
|
7
|
+
Layout/HeredocIndentation:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/ClassAndModuleChildren:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -35,5 +35,4 @@ Firstly, please note the Code of Conduct for all contributions to this project.
|
|
35
35
|
|
36
36
|
## Licence
|
37
37
|
|
38
|
-
Copyright (c) 2016, Drumknott is developed and maintained by Pat Allan, and is
|
39
|
-
released under the open MIT Licence.
|
38
|
+
Copyright (c) 2016-2020, Drumknott is developed and maintained by Pat Allan, and is released under the open MIT Licence.
|
data/Rakefile
CHANGED
@@ -1 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
RuboCop::RakeTask.new(:rubocop)
|
9
|
+
|
10
|
+
Rake::Task["default"].clear if Rake::Task.task_defined?("default")
|
11
|
+
task :default => %i[ rubocop spec ]
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/drumknott.gemspec
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Gem::Specification.new do |spec|
|
3
4
|
spec.name = "drumknott"
|
4
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.4.0"
|
5
6
|
spec.authors = ["Pat Allan"]
|
6
7
|
spec.email = ["pat@freelancing-gods.com"]
|
7
8
|
|
8
|
-
spec.summary =
|
9
|
-
spec.description =
|
9
|
+
spec.summary = "Jekyll content uploader for Drumknott's search service."
|
10
|
+
spec.description = "Takes each of your compiled Jekyll pages and uploads " \
|
11
|
+
"them to Drumknott."
|
10
12
|
spec.homepage = "https://github.com/pat/drumknott"
|
11
13
|
spec.license = "MIT"
|
12
14
|
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |file|
|
16
|
+
file.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
14
18
|
spec.bindir = "exe"
|
15
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |file| File.basename(file) }
|
16
20
|
spec.require_paths = ["lib"]
|
17
21
|
|
18
|
-
spec.add_runtime_dependency
|
19
|
-
spec.add_runtime_dependency
|
20
|
-
spec.add_runtime_dependency
|
22
|
+
spec.add_runtime_dependency "faraday"
|
23
|
+
spec.add_runtime_dependency "jekyll", ">= 3.0"
|
24
|
+
spec.add_runtime_dependency "json"
|
21
25
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.79.0"
|
29
|
+
spec.add_development_dependency "webmock"
|
24
30
|
end
|
data/exe/drumknott
CHANGED
data/lib/drumknott.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "json"
|
5
|
+
require "jekyll"
|
4
6
|
|
5
7
|
module Drumknott
|
6
|
-
#
|
7
8
|
end
|
8
9
|
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
10
|
+
require "drumknott/cli"
|
11
|
+
require "drumknott/include_pages"
|
12
|
+
require "drumknott/keys"
|
13
|
+
require "drumknott/outputs"
|
14
|
+
require "drumknott/refresh"
|
data/lib/drumknott/cli.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
|
-
|
2
|
-
EMPTY_CACHE = {}.freeze
|
3
|
-
|
4
|
-
def self.call(command, arguments = [], name = nil, key = nil, include_pages = nil)
|
5
|
-
new(command, arguments, name, key, include_pages).call
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(command, arguments = [], name = nil, key = nil, include_pages = nil)
|
9
|
-
@command, @arguments, @name, @key, @include_pages =
|
10
|
-
command, arguments, name, key, include_pages
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
12
2
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Drumknott::Refresh.call name, key, include_pages?
|
17
|
-
when 'keys'
|
18
|
-
Drumknott::Keys.call arguments
|
19
|
-
else
|
20
|
-
puts "Unknown command #{command}." unless command == 'help'
|
21
|
-
puts <<-MESSAGE
|
3
|
+
class Drumknott::CLI
|
4
|
+
EMPTY_CACHE = {}.freeze
|
5
|
+
HELP_MESSAGE = <<-MESSAGE
|
22
6
|
Commands are:
|
23
7
|
refresh: Update your site's content on Drumknott.
|
24
8
|
keys: Create local file with your Drumknott credentials.
|
@@ -28,12 +12,38 @@ Example Usage:
|
|
28
12
|
$ drumknott refresh
|
29
13
|
$ drumknott keys my-site-name my-site-key
|
30
14
|
|
31
|
-
Credentials for Drumknott are expected via environment variables, or
|
32
|
-
.drumknott file created using the `keys` command.
|
15
|
+
Credentials for Drumknott are expected via environment variables, or
|
16
|
+
via a .drumknott file created using the `keys` command.
|
33
17
|
|
34
18
|
DRUMKNOTT_NAME: Your site name, as registered with Drumknott.
|
35
19
|
DRUMKNOTT_KEY: Your API key, as provided by Drumknott.
|
36
|
-
|
20
|
+
MESSAGE
|
21
|
+
|
22
|
+
def self.call(
|
23
|
+
command, arguments = [], name = nil, key = nil, include_pages = nil
|
24
|
+
)
|
25
|
+
new(command, arguments, name, key, include_pages).call
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(
|
29
|
+
command, arguments = [], name = nil, key = nil, include_pages = nil
|
30
|
+
)
|
31
|
+
@command = command
|
32
|
+
@arguments = arguments
|
33
|
+
@name = name
|
34
|
+
@key = key
|
35
|
+
@include_pages = include_pages
|
36
|
+
end
|
37
|
+
|
38
|
+
def call
|
39
|
+
case command
|
40
|
+
when "refresh"
|
41
|
+
Drumknott::Refresh.call name, key, include_pages?
|
42
|
+
when "keys"
|
43
|
+
Drumknott::Keys.call arguments
|
44
|
+
else
|
45
|
+
puts "Unknown command #{command}." unless command == "help"
|
46
|
+
puts HELP_MESSAGE
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
@@ -42,23 +52,23 @@ Credentials for Drumknott are expected via environment variables, or via a
|
|
42
52
|
attr_reader :command, :arguments
|
43
53
|
|
44
54
|
def cache
|
45
|
-
return EMPTY_CACHE unless File.
|
55
|
+
return EMPTY_CACHE unless File.exist? ".drumknott"
|
46
56
|
|
47
|
-
@cache ||= JSON.parse File.read(
|
57
|
+
@cache ||= JSON.parse File.read(".drumknott")
|
48
58
|
end
|
49
59
|
|
50
60
|
def name
|
51
|
-
@name || cache[
|
61
|
+
@name || cache["name"] || ENV["DRUMKNOTT_NAME"]
|
52
62
|
end
|
53
63
|
|
54
64
|
def key
|
55
|
-
@key || cache[
|
65
|
+
@key || cache["key"] || ENV["DRUMKNOTT_KEY"]
|
56
66
|
end
|
57
67
|
|
58
68
|
def include_pages?
|
59
69
|
return @include_pages unless @include_pages.nil?
|
60
|
-
return cache[
|
70
|
+
return cache["pages"] unless cache["pages"].nil?
|
61
71
|
|
62
|
-
Drumknott::IncludePages.call ENV[
|
72
|
+
Drumknott::IncludePages.call ENV["DRUMKNOTT_PAGES"]
|
63
73
|
end
|
64
74
|
end
|
data/lib/drumknott/keys.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Drumknott::Keys
|
2
4
|
def self.call(arguments)
|
3
5
|
new(arguments).call
|
4
6
|
end
|
5
7
|
|
6
8
|
def initialize(arguments)
|
7
|
-
@name, @key, @pages,
|
9
|
+
@name, @key, @pages, _ignored = *arguments
|
8
10
|
end
|
9
11
|
|
10
12
|
def call
|
11
|
-
File.write
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
File.write ".drumknott", JSON.generate(
|
14
|
+
"name" => name,
|
15
|
+
"key" => key,
|
16
|
+
"pages" => Drumknott::IncludePages.call(pages)
|
15
17
|
)
|
16
18
|
end
|
17
19
|
|
data/lib/drumknott/outputs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Drumknott::Outputs::Silent
|
2
4
|
def self.call(&block)
|
3
5
|
new(&block).call
|
@@ -7,7 +9,7 @@ class Drumknott::Outputs::Silent
|
|
7
9
|
@block = block
|
8
10
|
end
|
9
11
|
|
10
|
-
def call(
|
12
|
+
def call(_label, collection)
|
11
13
|
collection.each { |item| block.call item }
|
12
14
|
end
|
13
15
|
|
data/lib/drumknott/refresh.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Drumknott::Refresh
|
2
|
-
URL =
|
4
|
+
URL = "https://drumknottsearch.com"
|
3
5
|
|
4
6
|
def self.call(name, key, include_pages = true)
|
5
7
|
new(name, key, include_pages).call
|
6
8
|
end
|
7
9
|
|
8
10
|
def initialize(name, key, include_pages)
|
9
|
-
@name
|
11
|
+
@name = name
|
12
|
+
@key = key
|
13
|
+
@include_pages = include_pages
|
10
14
|
end
|
11
15
|
|
12
16
|
def call
|
@@ -23,7 +27,7 @@ class Drumknott::Refresh
|
|
23
27
|
def clear
|
24
28
|
connection.post do |request|
|
25
29
|
request.url "/api/v1/#{name}/pages/clear"
|
26
|
-
request.headers[
|
30
|
+
request.headers["AUTHENTICATION"] = key
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
@@ -43,37 +47,46 @@ class Drumknott::Refresh
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def output_class
|
46
|
-
return Drumknott::Outputs::Silent if ENV[
|
50
|
+
return Drumknott::Outputs::Silent if ENV["DRUMKNOTT_SILENT"]
|
47
51
|
|
48
|
-
require
|
52
|
+
require "ruby-progressbar"
|
49
53
|
Drumknott::Outputs::ProgressBar
|
50
54
|
rescue LoadError
|
51
55
|
Drumknott::Outputs::Silent
|
52
56
|
end
|
53
57
|
|
58
|
+
def page_json_for(document)
|
59
|
+
JSON.generate(
|
60
|
+
:page => {
|
61
|
+
:name => document.data["title"],
|
62
|
+
:path => document.url,
|
63
|
+
:content => document.output
|
64
|
+
}
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
54
68
|
def site
|
55
69
|
@site ||= Jekyll::Site.new Jekyll.configuration
|
56
70
|
end
|
57
71
|
|
58
72
|
def update
|
59
73
|
output.call "Posts", site.posts.docs
|
60
|
-
|
74
|
+
return unless include_pages?
|
75
|
+
|
76
|
+
output.call(
|
77
|
+
"Pages",
|
78
|
+
site.pages.select { |page| page.html? || page.url.end_with?("/") }
|
79
|
+
)
|
61
80
|
end
|
62
81
|
|
63
82
|
def update_document(document)
|
64
83
|
connection.put do |request|
|
65
84
|
request.url "/api/v1/#{name}/pages"
|
66
85
|
|
67
|
-
request.headers[
|
68
|
-
request.headers[
|
86
|
+
request.headers["AUTHENTICATION"] = key
|
87
|
+
request.headers["Content-Type"] = "application/json"
|
69
88
|
|
70
|
-
request.body =
|
71
|
-
:page => {
|
72
|
-
:name => document.data['title'],
|
73
|
-
:path => document.url,
|
74
|
-
:content => document.output
|
75
|
-
}
|
76
|
-
})
|
89
|
+
request.body = page_json_for document
|
77
90
|
end
|
78
91
|
end
|
79
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drumknott
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jekyll
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: json
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +53,19 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.79.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.79.0
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: webmock
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +117,7 @@ extensions: []
|
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
91
119
|
- ".gitignore"
|
120
|
+
- ".rubocop.yml"
|
92
121
|
- ".travis.yml"
|
93
122
|
- CODE_OF_CONDUCT.md
|
94
123
|
- Gemfile
|
@@ -126,10 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
155
|
- !ruby/object:Gem::Version
|
127
156
|
version: '0'
|
128
157
|
requirements: []
|
129
|
-
|
130
|
-
rubygems_version: 2.5.1
|
158
|
+
rubygems_version: 3.0.3
|
131
159
|
signing_key:
|
132
160
|
specification_version: 4
|
133
161
|
summary: Jekyll content uploader for Drumknott's search service.
|
134
162
|
test_files: []
|
135
|
-
has_rdoc:
|