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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9339ecbc7b7de3bd690f0dea5bbe9d8121c16356
4
- data.tar.gz: 0c960ae61a94806b72be20e57a73a95b9e820f7b
2
+ SHA256:
3
+ metadata.gz: 975e98965c58ecfe46625a7c4f3a4fd95db412264699ecff9d2265a113ff78f5
4
+ data.tar.gz: d0a93ee4dca7922870640460d9432745eb045dbcd4deb209aedf1942a630dfbe
5
5
  SHA512:
6
- metadata.gz: 1e275414f772076a8c6fb694992fd87ab9f01768175ab30eb078d4ca44f1246effb1e063eb187a6e86eae0bf7c1c06caed9e1636beaae53b96c8726f4369ee61
7
- data.tar.gz: 1b44931fc983e83dcb0ce25220ea7d79022a1cff341b42a0e3284711dfd24ad0157c90d506b16773cfc9a014e87b7c57de292368d4c9d016094f5a2ade068df5
6
+ metadata.gz: 6d3414215d62b5f12a9a0d1add3a9a7d50a1d5d237f24d3a626ab3bc88738f4f1854af4dd8a1b9424d51dc33bf93c92003dedaf4d525010577dd88dc528e0e62
7
+ data.tar.gz: ed4477254c76c42ae3afc35bfb0dbdd623de4ce471308e44c28d8f50bb63e3c2caab6c413b324cc5692554f25bc7ce09136096957bb96cdd3f029585235de1c1
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .rubocop-*-yml
@@ -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
@@ -1,5 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- script: bundle exec rspec
3
+ - 2.3.8
4
+ - 2.4.9
5
+ - 2.5.7
6
+ - 2.6.5
7
+ - 2.7.0
8
+ script: bundle exec rake
5
9
  sudo: false
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  gemspec
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 ]
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "drumknott"
data/bin/setup CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #!/bin/bash
2
4
  set -euo pipefail
3
5
  IFS=$'\n\t'
@@ -1,24 +1,30 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  Gem::Specification.new do |spec|
3
4
  spec.name = "drumknott"
4
- spec.version = "0.3.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 = %q{Jekyll content uploader for Drumknott's search service.}
9
- spec.description = %q{Takes each of your compiled Jekyll pages and uploads them to Drumknott.}
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 { |f| f.match(%r{^(test|spec|features)/}) }
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/}) { |f| File.basename(f) }
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 'faraday'
19
- spec.add_runtime_dependency 'json'
20
- spec.add_runtime_dependency 'jekyll', '>= 3.0'
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 'rspec'
23
- spec.add_development_dependency 'webmock'
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
@@ -1,6 +1,8 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # -*- mode: ruby -*-
3
5
 
4
- require 'drumknott'
6
+ require "drumknott"
5
7
 
6
8
  Drumknott::CLI.call ARGV[0], ARGV[1..-1]
@@ -1,13 +1,14 @@
1
- require 'faraday'
2
- require 'json'
3
- require 'jekyll'
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 'drumknott/cli'
10
- require 'drumknott/include_pages'
11
- require 'drumknott/keys'
12
- require 'drumknott/outputs'
13
- require 'drumknott/refresh'
10
+ require "drumknott/cli"
11
+ require "drumknott/include_pages"
12
+ require "drumknott/keys"
13
+ require "drumknott/outputs"
14
+ require "drumknott/refresh"
@@ -1,24 +1,8 @@
1
- class Drumknott::CLI
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
- def call
14
- case command
15
- when 'refresh'
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 via a
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
- MESSAGE
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.exists? '.drumknott'
55
+ return EMPTY_CACHE unless File.exist? ".drumknott"
46
56
 
47
- @cache ||= JSON.parse File.read('.drumknott')
57
+ @cache ||= JSON.parse File.read(".drumknott")
48
58
  end
49
59
 
50
60
  def name
51
- @name || cache['name'] || ENV['DRUMKNOTT_NAME']
61
+ @name || cache["name"] || ENV["DRUMKNOTT_NAME"]
52
62
  end
53
63
 
54
64
  def key
55
- @key || cache['key'] || ENV['DRUMKNOTT_KEY']
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['pages'] unless cache['pages'].nil?
70
+ return cache["pages"] unless cache["pages"].nil?
61
71
 
62
- Drumknott::IncludePages.call ENV['DRUMKNOTT_PAGES']
72
+ Drumknott::IncludePages.call ENV["DRUMKNOTT_PAGES"]
63
73
  end
64
74
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Drumknott::IncludePages
2
- TRUE_OPTIONS = ['true', 'yes', 'y'].freeze
4
+ TRUE_OPTIONS = %w[ true yes y ].freeze
3
5
 
4
6
  def self.call(value)
5
7
  case value
@@ -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, ignored = *arguments
9
+ @name, @key, @pages, _ignored = *arguments
8
10
  end
9
11
 
10
12
  def call
11
- File.write '.drumknott', JSON.generate(
12
- 'name' => name,
13
- 'key' => key,
14
- 'pages' => Drumknott::IncludePages.call(pages)
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
 
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Drumknott::Outputs
2
- #
3
4
  end
4
5
 
5
- require 'drumknott/outputs/silent'
6
- require 'drumknott/outputs/progress_bar'
6
+ require "drumknott/outputs/silent"
7
+ require "drumknott/outputs/progress_bar"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Drumknott::Outputs::ProgressBar < Drumknott::Outputs::Silent
2
4
  def call(label, collection)
3
5
  bar = ::ProgressBar.create :title => label, :total => collection.length
@@ -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(label, collection)
12
+ def call(_label, collection)
11
13
  collection.each { |item| block.call item }
12
14
  end
13
15
 
@@ -1,12 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Drumknott::Refresh
2
- URL = 'https://drumknottsearch.com'
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, @key, @include_pages = name, key, include_pages
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['AUTHENTICATION'] = key
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['DRUMKNOTT_SILENT']
50
+ return Drumknott::Outputs::Silent if ENV["DRUMKNOTT_SILENT"]
47
51
 
48
- require 'ruby-progressbar'
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
- output.call "Pages", site.pages if include_pages?
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['AUTHENTICATION'] = key
68
- request.headers['Content-Type'] = 'application/json'
86
+ request.headers["AUTHENTICATION"] = key
87
+ request.headers["Content-Type"] = "application/json"
69
88
 
70
- request.body = JSON.generate({
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.3.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: 2016-09-19 00:00:00.000000000 Z
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: jekyll
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :runtime
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: '3.0'
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
- rubyforge_project:
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: