jekyll-ghdeploy 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 58fd420a3c7d45e031f1a41a2d2866067fc58505126fda6e4c7ab27fc000ffea
4
+ data.tar.gz: 0b9b8c17e4060b7d60a9781d4d459c880e8838e9023e9ac0356a6279b30835ef
5
+ SHA512:
6
+ metadata.gz: c89293b420f26bf26ceb839e31be73e64eeb26bc2fa4588ea4ed79c0caa06fd2a10b8ee4f0e725ef6e7e59b9d0a3e2063f0538c132052e74a52b0f17af5d745b
7
+ data.tar.gz: e47b2cf1631fb1fe957c1146318b3809ac001841b7cb00a017826855fc218de4e5651a751b65fef6bf85ef54f9aea2ba505465285ff9c3832a1cf1994430d906
@@ -0,0 +1,130 @@
1
+ require "rubygems"
2
+ require "jekyll"
3
+ require "jekyll/commands/ghdeploy"
4
+
5
+ module JekyllGhDeploy
6
+ class Site
7
+
8
+ def initialize (repo, message)
9
+ system("clear")
10
+ puts "\n\e[1m\e[33mWelcome to Jekyll GhDeploy\e[39m\e[0m"
11
+
12
+ @repo = "https://github.com/" + repo
13
+ @message = message
14
+ end
15
+
16
+ def deploy
17
+ clone
18
+
19
+ Dir.chdir("clone/") do
20
+ prepare
21
+
22
+ if !system("cd _site; git log>/dev/null")
23
+ initial_commits
24
+ else
25
+ build
26
+ commit
27
+ end
28
+
29
+ push
30
+ end
31
+ end
32
+
33
+ def clone
34
+ puts "\n\e[1mCloning repository\e[0m\n\n"
35
+
36
+ FileUtils.rm_rf("clone")
37
+
38
+ exit unless system("git clone '.git/' 'clone/'")
39
+ end
40
+
41
+ def initial_commits
42
+ puts "\n\e[1mBuilding and commiting for every commit in master branch\e[0m\n\n"
43
+
44
+ n = -1 + `git rev-list --count master`.to_i
45
+ #n = n-1
46
+ commit_hash=Array.new()
47
+ message=Array.new()
48
+
49
+ #This is an iteration through every commit inside of master branch
50
+ #To get the ith commit message we need to skip n-i commits starting from HEAD
51
+
52
+ for i in 0..n do
53
+ commit_hash[i]=`git log --skip=#{n-i} --max-count=1 --pretty=%H`
54
+ message[i] =`git log --skip=#{n-i} --max-count=1 --pretty=%s`
55
+ end
56
+
57
+ for i in 0..n do
58
+ @message = message[i]
59
+ system("
60
+ git reset --hard #{commit_hash[i]}
61
+ echo -e '\n'
62
+ ")
63
+ build
64
+ commit
65
+ end
66
+ end
67
+
68
+ def prepare
69
+ puts "\n\e[1mPreparing _site\e[0m\n\n"
70
+
71
+ FileUtils.rm_rf("_site")
72
+ Dir.mkdir "_site"
73
+
74
+ Dir.chdir("_site/") do
75
+ exit unless system("
76
+ git init
77
+ echo -e '\n'
78
+ git remote add origin #{@repo}
79
+ git checkout -b gh-pages
80
+ echo -e '\n'
81
+ ")
82
+
83
+ remote_branch = `git ls-remote --heads origin gh-pages`
84
+
85
+ if remote_branch.empty?
86
+ system("touch .nojekyll")
87
+ else
88
+ exit unless system("git pull --rebase origin gh-pages")
89
+ end
90
+ end
91
+ end
92
+
93
+ def build
94
+ puts "\n\e[1mBuilding\e[0m\n\n"
95
+
96
+ Jekyll::Commands::Build.process(options = {})
97
+ end
98
+
99
+ def commit
100
+ puts "\n\e[1mCommiting changes\e[0m\n\n"
101
+
102
+ Dir.chdir("_site/") do
103
+ exit unless system("
104
+ git status
105
+ echo -e '\n'
106
+ git add -A
107
+ echo -e '\n'
108
+ git status
109
+ echo -e '\n'
110
+ git commit -m '#{@message}'
111
+ ")
112
+ end
113
+ end
114
+
115
+ def push
116
+ puts "\n\e[1mPushing to #{@repo} gh-pages branch\e[0m\n\n"
117
+
118
+ Dir.chdir("_site/") do
119
+ exit unless system("git push origin gh-pages")
120
+ end
121
+ end
122
+
123
+ def clean
124
+ puts "\n\n\e[1mQuiting...\e[0m\n\n"
125
+
126
+ FileUtils.rm_rf("clone")
127
+ end
128
+ end
129
+ end
130
+
@@ -0,0 +1,3 @@
1
+ module JekyllGhDeploy
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,45 @@
1
+ require 'jekyll-ghdeploy'
2
+ module Jekyll
3
+ module Commands
4
+ class GhDeploy < Command
5
+ class << self
6
+ def init_with_program(prog)
7
+ prog.command(:ghdeploy) do |c|
8
+
9
+ c.syntax "deploy REPOSITORY"
10
+
11
+ c.description "Deploys your site to your gh-pages branch"
12
+
13
+ c.action do |args, options|
14
+ Jekyll::Commands::GhDeploy.process(args, options)
15
+ end
16
+ end
17
+ end
18
+
19
+ def process(args, options = {})
20
+
21
+ config = YAML.load_file('_config.yml')
22
+ message = `git log -1 --pretty=%s`
23
+
24
+ if args.empty? && config['repository'].blank?
25
+ raise ArgumentError, "You must specify a repository."
26
+ elsif args.empty?
27
+ repo = config['repository']
28
+ else
29
+ repo = args[0]
30
+ end
31
+
32
+ site = JekyllGhDeploy::Site.new(repo, message)
33
+
34
+ at_exit do
35
+ site.clean
36
+ end
37
+
38
+ site.deploy
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-ghdeploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Garlis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Provides ghdeploy subcommand
56
+ email:
57
+ - nickgarlis@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/jekyll-ghdeploy.rb
63
+ - lib/jekyll-ghdeploy/version.rb
64
+ - lib/jekyll/commands/ghdeploy.rb
65
+ homepage: https://github.com/nickgarlis/jekyll-ghdeploy
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.9.3
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.7.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Jekyll GhDeploy is a gem that helps you push your jekyll site to Github.
89
+ test_files: []