site_hook 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/site_hook.rb +4 -0
- data/lib/site_hook/sender.rb +3 -2
- data/lib/site_hook/server_class.rb +2 -1
- data/lib/site_hook/version.rb +1 -1
- data/lib/site_hook/webhook.rb +21 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa8b1808f36f0c69588f9590568133fb9b2a6288a3077d9aba94d197786c3ee
|
4
|
+
data.tar.gz: 1972b2bb6b896b69b06b9967a9e21faf175e0f1dff4165859a7a71bec018098c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dce31e06943728aa637c941bedc4baac41bed34010d1bc90b5749d509605a048400e926a42dd1392577b216e2fde6cc93bb80a1b875529f8fdcbe46bde8f96e
|
7
|
+
data.tar.gz: 8b4948f0045924d7b2b802accd893d7da2c2978daa75966253e55284cbaa8584296854c12b81b1b000650761d087de1b243977750074d11ea018527fbbd7215e
|
data/lib/site_hook.rb
CHANGED
@@ -20,6 +20,10 @@ module SiteHook
|
|
20
20
|
autoload :Gem, 'site_hook/gem'
|
21
21
|
autoload :Paths, 'site_hook/paths'
|
22
22
|
# class SassHandler (inherits from Sinatra::Base)
|
23
|
+
module_function
|
24
|
+
def self.set_options(name, value)
|
25
|
+
SiteHook.const_set("#{name.upcase}", value)
|
26
|
+
end
|
23
27
|
class SassHandler < Sinatra::Base
|
24
28
|
set :views, Pathname(app_file).dirname.join('site_hook', 'static', 'sass').to_s
|
25
29
|
get '/css/*.css' do
|
data/lib/site_hook/sender.rb
CHANGED
@@ -39,7 +39,7 @@ module SiteHook
|
|
39
39
|
jekyll_source = Jekyll.instance_variable_get('@jekyll_source')
|
40
40
|
build_dest = Jekyll.instance_variable_get('@build_dest')
|
41
41
|
log = Jekyll.instance_variable_get('@log')
|
42
|
-
Open3.popen2e({'BUNDLE_GEMFILE' => Pathname(jekyll_source).join('Gemfile').to_path}, "bundle exec jekyll build --source #{Pathname(jekyll_source).realdirpath.to_path} --destination #{Pathname(build_dest).to_path}") { |in_io, outerr_io, thr|
|
42
|
+
Open3.popen2e({'BUNDLE_GEMFILE' => Pathname(jekyll_source).join('Gemfile').to_path}, "bundle exec jekyll build --source #{Pathname(jekyll_source).realdirpath.to_path} --destination #{Pathname(build_dest).to_path} --config #{Pathname(jekyll_source).join(@options[:config])}") { |in_io, outerr_io, thr|
|
43
43
|
# pid = thr.pid
|
44
44
|
|
45
45
|
outerr = outerr_io.read.lines
|
@@ -77,10 +77,11 @@ module SiteHook
|
|
77
77
|
# @param [String,Pathname] jekyll_source Jekyll Source
|
78
78
|
# @param [String,Pathname] build_dest Build Destination
|
79
79
|
# @param [BuildLog] logger Build Logger Instance
|
80
|
-
def self.build(jekyll_source, build_dest, logger)
|
80
|
+
def self.build(jekyll_source, build_dest, logger, options:)
|
81
81
|
@jekyll_source = jekyll_source
|
82
82
|
@build_dest = build_dest
|
83
83
|
@log = logger
|
84
|
+
@options = options
|
84
85
|
instance = self::Build.new
|
85
86
|
meths = [instance.do_grab_version, instance.do_pull, instance.do_build]
|
86
87
|
begin
|
@@ -17,10 +17,11 @@ module SiteHook
|
|
17
17
|
method_option(:log_levels, type: :hash, banner: 'LEVELS', default: SiteHook::Logs.log_levels)
|
18
18
|
method_option :host, type: :string, banner: 'BINDHOST', default: JPHRC.fetch('host', '127.0.0.1')
|
19
19
|
method_option :port, type: :string, banner: 'BINDPORT', default: JPHRC.fetch('port', 9090)
|
20
|
+
method_option :config, type: :string, banner: 'CONFIGFILE', default: '_config.yml'
|
20
21
|
desc 'listen', 'Start SiteHook'
|
21
22
|
def listen
|
22
23
|
SiteHook.mklogdir unless SiteHook::Paths.logs.exist?
|
23
|
-
SiteHook::Webhook.
|
24
|
+
SiteHook::Webhook.set_options(options[:host], options[:port], options[:config])
|
24
25
|
SiteHook::Webhook.run!
|
25
26
|
end
|
26
27
|
end
|
data/lib/site_hook/version.rb
CHANGED
data/lib/site_hook/webhook.rb
CHANGED
@@ -15,9 +15,15 @@ module SiteHook
|
|
15
15
|
BUILDLOG = SiteHook::HookLogger::BuildLog.new(SiteHook::Logs.log_levels['build']).log
|
16
16
|
APPLOG = SiteHook::HookLogger::AppLog.new(SiteHook::Logs.log_levels['app']).log
|
17
17
|
JPHRC = YAML.load_file(Pathname(Dir.home).join('.jph', 'config'))
|
18
|
-
def self.set_bind(host, port)
|
18
|
+
def self.set_bind(host, port, config)
|
19
19
|
self.set port: port
|
20
20
|
self.set bind: host
|
21
|
+
if config == '_config.yml'
|
22
|
+
SiteHook.set_options(:BUILD_CONFIG, '_config.yml')
|
23
|
+
else
|
24
|
+
SiteHook.set_options(:BUILD_CONFIG, config)
|
25
|
+
end
|
26
|
+
|
21
27
|
end
|
22
28
|
set server: %w[thin]
|
23
29
|
set quiet: true
|
@@ -146,17 +152,22 @@ module SiteHook
|
|
146
152
|
end
|
147
153
|
if Webhook.verified?(req_body.to_s, signature, project['hookpass'], plaintext: plaintext, service: service)
|
148
154
|
BUILDLOG.info 'Building...'
|
155
|
+
begin
|
156
|
+
jekyllbuild = SiteHook::Senders::Jekyll.build(project['src'], project['dst'], BUILDLOG, options: {config: SiteHook::BUILD_CONFIG})
|
157
|
+
jekyll_status = jekyllbuild
|
158
|
+
case jekyll_status
|
159
|
+
|
160
|
+
when 0
|
161
|
+
status 200
|
162
|
+
headers 'Content-Type' => 'application/json'
|
163
|
+
body { { 'status': 'success' }.to_json }
|
164
|
+
when -1, -2, -3
|
165
|
+
halt 400, { 'Content-Type' => 'application/json' }, { 'status': 'exception', error: jekyll_status.fetch(:message).to_s }
|
149
166
|
|
150
|
-
|
151
|
-
jekyll_status = jekyllbuild
|
152
|
-
case jekyll_status
|
167
|
+
end
|
153
168
|
|
154
|
-
|
155
|
-
status
|
156
|
-
headers 'Content-Type' => 'application/json'
|
157
|
-
body { { 'status': 'success' }.to_json }
|
158
|
-
when -1, -2, -3
|
159
|
-
halt 400, { 'Content-Type' => 'application/json' }, { 'status': 'exception', error: jekyll_status.fetch(:message).to_s }
|
169
|
+
rescue => e
|
170
|
+
halt 500, { 'Content-Type' => 'application/json' }, { 'status': 'exception', error: e.to_s}
|
160
171
|
|
161
172
|
end
|
162
173
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_hook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Spencer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01
|
11
|
+
date: 2019-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|