drumknott 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b9a3287a90e955a0a99b2ee042283414dabf63b
4
+ data.tar.gz: 032e15ac177edf51e3477f8bcd1de4d1cda8509b
5
+ SHA512:
6
+ metadata.gz: 976320b85bc64b2dc102f04030abf5d27b283a4a02a62dd073633489578c6ab03bf6979b9963224900aac24142d6590f379a75e6cc0b480b0d3c0db061abccd7
7
+ data.tar.gz: 5c8096e1154126c5788cbdc02fa5ce77247feaf6af50ee773a4c04f6a8f486ba0d418b3a30be9969d9caa091e03219f8ca7a272a7a43a868e3bdafce5f115b2f
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Pat Allan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Drumknott CLI
2
+
3
+ Command line tool for the Drumknott search service. When invoked, it takes each of your compiled Jekyll pages and uploads them to Drumknott.
4
+
5
+ ## Installation
6
+
7
+ $ gem install drumknott
8
+
9
+ ## Usage
10
+
11
+ From within the local Jekyll site directory, using the credentials provided by Drumknott:
12
+
13
+ $ drumknott keys SITE_NAME SITE_KEY
14
+ $ drumknott refresh
15
+
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
+
18
+ ## Development
19
+
20
+ 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.
21
+
22
+ ## Contributing
23
+
24
+ Firstly, please note the Code of Conduct for all contributions to this project. If you accept that, then the steps for contributing are probably something along the lines of:
25
+
26
+ 1. Fork it ( https://github.com/pat/drumknott/fork )
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create a new Pull Request
31
+
32
+ ## Licence
33
+
34
+ Copyright (c) 2015, Drumknott is developed and maintained by Pat Allan, and is
35
+ released under the open MIT Licence.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "drumknott"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "drumknott"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["Pat Allan"]
6
+ spec.email = ["pat@freelancing-gods.com"]
7
+
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.}
10
+ spec.homepage = "https://github.com/pat/drumknott"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
+ spec.bindir = "exe"
15
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_runtime_dependency 'faraday'
19
+ spec.add_runtime_dependency 'json'
20
+ spec.add_runtime_dependency 'jekyll'
21
+
22
+ spec.add_development_dependency 'rspec'
23
+ spec.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+
4
+ require 'drumknott'
5
+
6
+ Drumknott::CLI.call ARGV[0], ARGV[1..-1]
@@ -0,0 +1,11 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'jekyll'
4
+
5
+ module Drumknott
6
+ #
7
+ end
8
+
9
+ require 'drumknott/cli'
10
+ require 'drumknott/keys'
11
+ require 'drumknott/refresh'
@@ -0,0 +1,56 @@
1
+ class Drumknott::CLI
2
+ EMPTY_CACHE = {}.freeze
3
+
4
+ def self.call(command, arguments = [], name = nil, key = nil)
5
+ new(command, arguments, name, key).call
6
+ end
7
+
8
+ def initialize(command, arguments = [], name = nil, key = nil)
9
+ @command, @arguments, @name, @key = command, arguments, name, key
10
+ end
11
+
12
+ def call
13
+ case command
14
+ when 'refresh'
15
+ Drumknott::Refresh.call name, key
16
+ when 'keys'
17
+ Drumknott::Keys.call arguments
18
+ else
19
+ puts "Unknown command #{command}." unless command == 'help'
20
+ puts <<-MESSAGE
21
+ Commands are:
22
+ refresh: Update your site's content on Drumknott.
23
+ keys: Create local file with your Drumknott credentials.
24
+ help: Display this message.
25
+
26
+ Example Usage:
27
+ $ drumknott refresh
28
+ $ drumknott keys my-site-name my-site-key
29
+
30
+ Credentials for Drumknott are expected via environment variables, or via a
31
+ .drumknott file created using the `keys` command.
32
+
33
+ DRUMKNOTT_NAME: Your site name, as registered with Drumknott.
34
+ DRUMKNOTT_KEY: Your API key, as provided by Drumknott.
35
+ MESSAGE
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :command, :arguments
42
+
43
+ def cache
44
+ return EMPTY_CACHE unless File.exists? '.drumknott'
45
+
46
+ @cache ||= JSON.parse File.read('.drumknott')
47
+ end
48
+
49
+ def name
50
+ @name || cache['name'] || ENV['DRUMKNOTT_NAME']
51
+ end
52
+
53
+ def key
54
+ @key || cache['key'] || ENV['DRUMKNOTT_KEY']
55
+ end
56
+ end
@@ -0,0 +1,20 @@
1
+ class Drumknott::Keys
2
+ def self.call(arguments)
3
+ new(arguments).call
4
+ end
5
+
6
+ def initialize(arguments)
7
+ @name, @key, ignored = *arguments
8
+ end
9
+
10
+ def call
11
+ File.write '.drumknott', JSON.generate(
12
+ 'name' => name,
13
+ 'key' => key
14
+ )
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :name, :key
20
+ end
@@ -0,0 +1,59 @@
1
+ class Drumknott::Refresh
2
+ URL = 'http://drumknottsearch.com'
3
+
4
+ def self.call(name, key)
5
+ new(name, key).call
6
+ end
7
+
8
+ def initialize(name, key)
9
+ @name, @key = name, key
10
+ end
11
+
12
+ def call
13
+ site.process
14
+
15
+ clear
16
+ update
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :name, :key
22
+
23
+ def clear
24
+ connection.post do |request|
25
+ request.url "/api/v1/#{name}/pages/clear"
26
+ request.headers['AUTHENTICATION'] = key
27
+ end
28
+ end
29
+
30
+ def connection
31
+ @connection ||= Faraday.new(:url => URL) do |faraday|
32
+ faraday.request :url_encoded
33
+ faraday.adapter Faraday.default_adapter
34
+ end
35
+ end
36
+
37
+ def site
38
+ @site ||= Jekyll::Site.new Jekyll.configuration
39
+ end
40
+
41
+ def update
42
+ site.posts.each do |page|
43
+ connection.put do |request|
44
+ request.url "/api/v1/#{name}/pages"
45
+
46
+ request.headers['AUTHENTICATION'] = key
47
+ request.headers['Content-Type'] = 'application/json'
48
+
49
+ request.body = JSON.generate({
50
+ :page => {
51
+ :name => page.title,
52
+ :path => page.url,
53
+ :content => page.output
54
+ }
55
+ })
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drumknott
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pat Allan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Takes each of your compiled Jekyll pages and uploads them to Drumknott.
84
+ email:
85
+ - pat@freelancing-gods.com
86
+ executables:
87
+ - drumknott
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - drumknott.gemspec
101
+ - exe/drumknott
102
+ - lib/drumknott.rb
103
+ - lib/drumknott/cli.rb
104
+ - lib/drumknott/keys.rb
105
+ - lib/drumknott/refresh.rb
106
+ homepage: https://github.com/pat/drumknott
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.8
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Jekyll content uploader for Drumknott's search service.
130
+ test_files: []