ghpages_deploy 1.2.0 → 1.3.0.pre.beta1
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/ghpages_deploy.gemspec +0 -2
- data/lib/ghpages_deploy/deployer.rb +3 -1
- data/lib/ghpages_deploy/git_manager.rb +10 -9
- data/lib/ghpages_deploy/handler.rb +26 -0
- data/lib/ghpages_deploy/rake/jekyll.rb +17 -0
- data/lib/ghpages_deploy/rake/json.rb +64 -0
- data/lib/ghpages_deploy/rake/task.rb +44 -0
- data/lib/ghpages_deploy/rake_task.rb +3 -39
- data/lib/ghpages_deploy/version.rb +1 -1
- metadata +8 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2f243b6938f96d439dd81b4c1b5905984b77172
|
4
|
+
data.tar.gz: 17d7063cdc3dbd38bc96c75220f27636a7df6a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6231675491a4079cc4487d60681efcceb237963d1b01dcaf072560b29d7953814a016ab055b078d37f5d5446c79173018f38a1e9b081b00927257da9d14231ec
|
7
|
+
data.tar.gz: 416d44a2ea9a809fab181a1e2c7b29b365dd7e28bc321421f286ff85314ac2dd9076c296bb43240dd2346e0fec03f9c0c4cea4d5e8b09645871bb81be3b99d1a
|
data/ghpages_deploy.gemspec
CHANGED
@@ -6,10 +6,11 @@ require 'ghpages_deploy/git_manager'
|
|
6
6
|
|
7
7
|
module GithubPages
|
8
8
|
class Deployer
|
9
|
-
def initialize(git, source, destinations)
|
9
|
+
def initialize(git, source, destinations, handler)
|
10
10
|
@git = git
|
11
11
|
@source = source
|
12
12
|
@destinations = destinations
|
13
|
+
@handler = handler
|
13
14
|
end
|
14
15
|
|
15
16
|
def deploy
|
@@ -36,6 +37,7 @@ module GithubPages
|
|
36
37
|
FileUtils.cp_r("#{@source}/.", dest)
|
37
38
|
|
38
39
|
stage_destination_files(dest)
|
40
|
+
@git.stage @handler.on_deploy if @handler
|
39
41
|
|
40
42
|
# check if any changes were made to the destination
|
41
43
|
!@git.staged_modifications(dest).empty?
|
@@ -32,7 +32,7 @@ module GithubPages
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def stage(files)
|
35
|
-
@git.add files
|
35
|
+
@git.add files unless files.empty?
|
36
36
|
end
|
37
37
|
|
38
38
|
def staged_modifications(dir)
|
@@ -80,21 +80,22 @@ module GithubPages
|
|
80
80
|
@git.config('user.email', ENV['GIT_EMAIL']) if ENV['GIT_EMAIL']
|
81
81
|
end
|
82
82
|
|
83
|
+
def remove_staged
|
84
|
+
to_remove = staged_modifications('.')
|
85
|
+
@git.remove(to_remove) unless to_remove.empty?
|
86
|
+
end
|
87
|
+
|
83
88
|
def setup_branch
|
84
89
|
if @git.is_local_branch?(branch)
|
85
90
|
@git.branch(branch).checkout
|
91
|
+
remove_staged
|
86
92
|
elsif @git.is_remote_branch?(branch)
|
87
93
|
git "checkout #{remote}/#{branch} -b #{branch}"
|
94
|
+
remove_staged
|
95
|
+
@git.pull(remote, branch)
|
88
96
|
else
|
89
97
|
git "checkout --orphan #{branch}"
|
90
|
-
|
91
|
-
|
92
|
-
# remove files already staged by checkout
|
93
|
-
to_remove = staged_modifications('.')
|
94
|
-
@git.remove(to_remove) unless to_remove.empty?
|
95
|
-
|
96
|
-
if @git.is_remote_branch?(branch)
|
97
|
-
@git.pull(remote, branch)
|
98
|
+
remove_staged
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) 2016 Nathan Currier
|
3
|
+
|
4
|
+
module GithubPages
|
5
|
+
class Handler
|
6
|
+
def self.def_handler(sym)
|
7
|
+
define_method(:"on_#{sym}") do |*args, &block|
|
8
|
+
handlers[method].each { |handle| handle.call(*args, &block) }
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
|
12
|
+
define_method(:"handle_#{sym}") do |&block|
|
13
|
+
handlers[method] << block
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def_handler :deploy
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def handlers
|
23
|
+
@handlers ||= Hash.new { |h, k| h[k] = [] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) 2016 Nathan Currier
|
3
|
+
|
4
|
+
require 'ghpages_deploy/rake/task'
|
5
|
+
|
6
|
+
module GithubPages
|
7
|
+
module JekyllRakeExt
|
8
|
+
def init_jekyll
|
9
|
+
@handler.handle_deploy do
|
10
|
+
FileUtils.touch('.nojekyll') unless File.exist?('.nojekyll')
|
11
|
+
['.nojekyll']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
DeployTask.include JekyllRakeExt
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) 2016 Nathan Currier
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'ghpages_deploy/rake/task'
|
7
|
+
|
8
|
+
module GithubPages
|
9
|
+
module JsonRakeExt
|
10
|
+
# designed for a documentation sitemap
|
11
|
+
# best used with a format similar to the following:
|
12
|
+
#
|
13
|
+
# tag/
|
14
|
+
# v1.0.0/
|
15
|
+
# _index.html
|
16
|
+
# ...
|
17
|
+
# v1.1.0/
|
18
|
+
# index.html
|
19
|
+
# _index.html
|
20
|
+
# ...
|
21
|
+
# ...
|
22
|
+
# branch/
|
23
|
+
# master/
|
24
|
+
# index.html
|
25
|
+
# ...
|
26
|
+
# ...
|
27
|
+
#
|
28
|
+
|
29
|
+
def self.update_sitemap
|
30
|
+
File.open('sitemap.json', 'w+') do |file|
|
31
|
+
file.write directory_sitemap('.').to_json
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.directory_sitemap(dir)
|
36
|
+
puts dir
|
37
|
+
index =
|
38
|
+
%w(index.html _index.html).find do |html|
|
39
|
+
File.exist?(File.join(dir, html))
|
40
|
+
end
|
41
|
+
|
42
|
+
return {File.basename(dir) => index} if index
|
43
|
+
|
44
|
+
Hash[Dir.foreach(dir).flat_map do |file|
|
45
|
+
file_dir = File.join(dir, file)
|
46
|
+
next [] if %w(.git . ..).include?(file)
|
47
|
+
next [] unless Dir.exist?(file_dir)
|
48
|
+
|
49
|
+
map = directory_sitemap(file_dir)
|
50
|
+
next [] if map.empty?
|
51
|
+
[file, map]
|
52
|
+
end]
|
53
|
+
end
|
54
|
+
|
55
|
+
def json_sitemap
|
56
|
+
@handler.handle_deploy do
|
57
|
+
JsonRakeExt.update_sitemap
|
58
|
+
['sitemap.json']
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
DeployTask.include JsonRakeExt
|
64
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) 2016 Nathan Currier
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/tasklib'
|
6
|
+
|
7
|
+
require 'ghpages_deploy/deployer'
|
8
|
+
require 'ghpages_deploy/git_manager'
|
9
|
+
|
10
|
+
module GithubPages
|
11
|
+
class DeployTask < ::Rake::TaskLib
|
12
|
+
def initialize(*args)
|
13
|
+
@args = args
|
14
|
+
@destinations = []
|
15
|
+
|
16
|
+
yield self if block_given?
|
17
|
+
|
18
|
+
@source ||= '.'
|
19
|
+
@remote ||= 'origin'
|
20
|
+
|
21
|
+
@destinations << '.' if @destinations.empty?
|
22
|
+
|
23
|
+
@handler = Handler.new
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :remote, :source
|
27
|
+
attr_reader :handler
|
28
|
+
|
29
|
+
def register(destination)
|
30
|
+
@destinations << destination
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def define
|
36
|
+
task(*@args) do
|
37
|
+
GitManager.open(@remote) do |git|
|
38
|
+
deployer = Deployer.new(git, @source, @destinations)
|
39
|
+
deployer.deploy(@handler)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,43 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# Copyright (c) 2016 Nathan Currier
|
3
3
|
|
4
|
-
require 'rake'
|
5
|
-
require 'rake/tasklib'
|
4
|
+
require 'ghpages_deploy/rake/task'
|
6
5
|
|
7
|
-
require 'ghpages_deploy/
|
8
|
-
require 'ghpages_deploy/
|
9
|
-
|
10
|
-
module GithubPages
|
11
|
-
class DeployTask < ::Rake::TaskLib
|
12
|
-
def initialize(*args)
|
13
|
-
@args = args
|
14
|
-
@destinations = []
|
15
|
-
|
16
|
-
yield self if block_given?
|
17
|
-
|
18
|
-
@source ||= '.'
|
19
|
-
@remote ||= 'origin'
|
20
|
-
|
21
|
-
@destinations << '.' if @destinations.empty?
|
22
|
-
|
23
|
-
define
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_accessor :remote, :source
|
27
|
-
|
28
|
-
def register(destination)
|
29
|
-
@destinations << destination
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def define
|
35
|
-
task(*@args) do
|
36
|
-
GitManager.open(@remote) do |git|
|
37
|
-
deployer = Deployer.new(git, @source, @destinations)
|
38
|
-
deployer.deploy
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
6
|
+
require 'ghpages_deploy/rake/json'
|
7
|
+
require 'ghpages_deploy/rake/jekyll'
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghpages_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.pre.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Currier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
type: :runtime
|
15
|
-
name: bundler
|
16
|
-
prerelease: false
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - ">="
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.11.2
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.11.2
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
type: :runtime
|
29
15
|
name: git
|
@@ -53,6 +39,10 @@ files:
|
|
53
39
|
- lib/ghpages_deploy/compress.rb
|
54
40
|
- lib/ghpages_deploy/deployer.rb
|
55
41
|
- lib/ghpages_deploy/git_manager.rb
|
42
|
+
- lib/ghpages_deploy/handler.rb
|
43
|
+
- lib/ghpages_deploy/rake/jekyll.rb
|
44
|
+
- lib/ghpages_deploy/rake/json.rb
|
45
|
+
- lib/ghpages_deploy/rake/task.rb
|
56
46
|
- lib/ghpages_deploy/rake_task.rb
|
57
47
|
- lib/ghpages_deploy/util.rb
|
58
48
|
- lib/ghpages_deploy/version.rb
|
@@ -71,9 +61,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
61
|
version: '0'
|
72
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
63
|
requirements:
|
74
|
-
- - "
|
64
|
+
- - ">"
|
75
65
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
66
|
+
version: 1.3.1
|
77
67
|
requirements: []
|
78
68
|
rubyforge_project:
|
79
69
|
rubygems_version: 2.4.8
|