drumknott 0.1.1 → 0.2.0
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 +4 -4
- data/README.md +4 -2
- data/drumknott.gemspec +2 -2
- data/lib/drumknott.rb +1 -0
- data/lib/drumknott/cli.rb +13 -5
- data/lib/drumknott/include_pages.rb +12 -0
- data/lib/drumknott/keys.rb +5 -4
- data/lib/drumknott/refresh.rb +26 -19
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8212f93f568255ff2ecd7e0f72b52682ad63c28
|
4
|
+
data.tar.gz: 8e3435731be5c384b1bd9c62516909e38a2f428d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e3d9bacfdee43bc3c3c17c02b4eb6eecc4f08ccd3efe7c8ab55a6ae7770fe97d10e27a79696c5a3fbabf874a48ca0886974ddddb4990f5c17e920561af1899
|
7
|
+
data.tar.gz: b838d47ff33dd8af2111c4b0db26825a2316202a68da5adb4a184d675c838d7b86acdf959900825ecf1b373cc42fd0fe733e63b3588e122c6a031fdb2099e656
|
data/README.md
CHANGED
@@ -10,11 +10,13 @@ Command line tool for the Drumknott search service. When invoked, it takes each
|
|
10
10
|
|
11
11
|
From within the local Jekyll site directory, using the credentials provided by Drumknott:
|
12
12
|
|
13
|
-
$ drumknott keys SITE_NAME SITE_KEY
|
13
|
+
$ drumknott keys SITE_NAME SITE_KEY INCLUDE_PAGES
|
14
14
|
$ drumknott refresh
|
15
15
|
|
16
16
|
The `keys` command will save your credentials to a `.drumknott` file in your site's directory. Do not commit this file to git! If you don't want to have that file saved, you can alternatively use the environment variables `DRUMKNOTT_NAME` and `DRUMKNOTT_KEY` respectively.
|
17
17
|
|
18
|
+
By default, both posts and normal pages will be uploaded to Drumknott. If you only wish to include posts, the INCLUDE_PAGES argument in the `keys` command should be `'no'`. This can also be managed via the `DRUMKNOTT_PAGES` environment variable.
|
19
|
+
|
18
20
|
## Development
|
19
21
|
|
20
22
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -31,5 +33,5 @@ Firstly, please note the Code of Conduct for all contributions to this project.
|
|
31
33
|
|
32
34
|
## Licence
|
33
35
|
|
34
|
-
Copyright (c)
|
36
|
+
Copyright (c) 2016, Drumknott is developed and maintained by Pat Allan, and is
|
35
37
|
released under the open MIT Licence.
|
data/drumknott.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "drumknott"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.2.0"
|
5
5
|
spec.authors = ["Pat Allan"]
|
6
6
|
spec.email = ["pat@freelancing-gods.com"]
|
7
7
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.add_runtime_dependency 'faraday'
|
19
19
|
spec.add_runtime_dependency 'json'
|
20
|
-
spec.add_runtime_dependency 'jekyll'
|
20
|
+
spec.add_runtime_dependency 'jekyll', '>= 3.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency 'rspec'
|
23
23
|
spec.add_development_dependency 'webmock'
|
data/lib/drumknott.rb
CHANGED
data/lib/drumknott/cli.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
class Drumknott::CLI
|
2
2
|
EMPTY_CACHE = {}.freeze
|
3
3
|
|
4
|
-
def self.call(command, arguments = [], name = nil, key = nil)
|
5
|
-
new(command, arguments, name, key).call
|
4
|
+
def self.call(command, arguments = [], name = nil, key = nil, include_pages = nil)
|
5
|
+
new(command, arguments, name, key, include_pages).call
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(command, arguments = [], name = nil, key = nil)
|
9
|
-
@command, @arguments, @name, @key
|
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
|
10
11
|
end
|
11
12
|
|
12
13
|
def call
|
13
14
|
case command
|
14
15
|
when 'refresh'
|
15
|
-
Drumknott::Refresh.call name, key
|
16
|
+
Drumknott::Refresh.call name, key, include_pages?
|
16
17
|
when 'keys'
|
17
18
|
Drumknott::Keys.call arguments
|
18
19
|
else
|
@@ -53,4 +54,11 @@ Credentials for Drumknott are expected via environment variables, or via a
|
|
53
54
|
def key
|
54
55
|
@key || cache['key'] || ENV['DRUMKNOTT_KEY']
|
55
56
|
end
|
57
|
+
|
58
|
+
def include_pages?
|
59
|
+
return @include_pages unless @include_pages.nil?
|
60
|
+
return cache['pages'] unless cache['pages'].nil?
|
61
|
+
|
62
|
+
Drumknott::IncludePages.call ENV['DRUMKNOTT_PAGES']
|
63
|
+
end
|
56
64
|
end
|
data/lib/drumknott/keys.rb
CHANGED
@@ -4,17 +4,18 @@ class Drumknott::Keys
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def initialize(arguments)
|
7
|
-
@name, @key, ignored = *arguments
|
7
|
+
@name, @key, @pages, ignored = *arguments
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
11
|
File.write '.drumknott', JSON.generate(
|
12
|
-
'name'
|
13
|
-
'key'
|
12
|
+
'name' => name,
|
13
|
+
'key' => key,
|
14
|
+
'pages' => Drumknott::IncludePages.call(pages)
|
14
15
|
)
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
|
-
attr_reader :name, :key
|
20
|
+
attr_reader :name, :key, :pages
|
20
21
|
end
|
data/lib/drumknott/refresh.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
class Drumknott::Refresh
|
2
2
|
URL = 'https://drumknottsearch.com'
|
3
3
|
|
4
|
-
def self.call(name, key)
|
5
|
-
new(name, key).call
|
4
|
+
def self.call(name, key, include_pages = true)
|
5
|
+
new(name, key, include_pages).call
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(name, key)
|
9
|
-
@name, @key = name, key
|
8
|
+
def initialize(name, key, include_pages)
|
9
|
+
@name, @key, @include_pages = name, key, include_pages
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
@@ -34,26 +34,33 @@ class Drumknott::Refresh
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def include_pages?
|
38
|
+
@include_pages
|
39
|
+
end
|
40
|
+
|
37
41
|
def site
|
38
42
|
@site ||= Jekyll::Site.new Jekyll.configuration
|
39
43
|
end
|
40
44
|
|
41
45
|
def update
|
42
|
-
site.posts.each
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
site.posts.docs.each { |document| update_document document }
|
47
|
+
site.pages.each { |page| update_document page } if include_pages?
|
48
|
+
end
|
49
|
+
|
50
|
+
def update_document(document)
|
51
|
+
connection.put do |request|
|
52
|
+
request.url "/api/v1/#{name}/pages"
|
53
|
+
|
54
|
+
request.headers['AUTHENTICATION'] = key
|
55
|
+
request.headers['Content-Type'] = 'application/json'
|
56
|
+
|
57
|
+
request.body = JSON.generate({
|
58
|
+
:page => {
|
59
|
+
:name => document.data['title'],
|
60
|
+
:path => document.url,
|
61
|
+
:content => document.output
|
62
|
+
}
|
63
|
+
})
|
57
64
|
end
|
58
65
|
end
|
59
66
|
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.2.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: 2016-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '3.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- exe/drumknott
|
102
102
|
- lib/drumknott.rb
|
103
103
|
- lib/drumknott/cli.rb
|
104
|
+
- lib/drumknott/include_pages.rb
|
104
105
|
- lib/drumknott/keys.rb
|
105
106
|
- lib/drumknott/refresh.rb
|
106
107
|
homepage: https://github.com/pat/drumknott
|
@@ -128,3 +129,4 @@ signing_key:
|
|
128
129
|
specification_version: 4
|
129
130
|
summary: Jekyll content uploader for Drumknott's search service.
|
130
131
|
test_files: []
|
132
|
+
has_rdoc:
|