nanoc-git 0.0.7 → 1.0.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: 149d3ce1ac2618693cecb4012183416eecc8e75f
4
+ data.tar.gz: bb5ba8c9c5d493db2d49bec4e3b51ad0d2572d53
5
+ SHA512:
6
+ metadata.gz: a82b71839715cfd7d6a06caa7d1653971c80ebfccc9e617825d6b1d23aafc5fffe0e49091755e0b3dede7166b11a9ef14452d5b5a5d31ba34274dac9ec177178
7
+ data.tar.gz: 58147d1895ddd1fc7c15cf2c92deb23928171daf53aee256f9216dac8e9f030f989d542df15c94e95ffaae3498706ca300693882f604b29ddc28f28f33060860
data/Gemfile CHANGED
@@ -1,2 +1,7 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+
5
+ gem 'minitest'
6
+ gem 'rake'
7
+ gem 'coveralls', require: false
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nanoc-git (1.0.1)
5
+ nanoc (>= 3.7.0, < 5.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ colored (1.2)
11
+ coveralls (0.8.3)
12
+ json (~> 1.8)
13
+ rest-client (>= 1.6.8, < 2)
14
+ simplecov (~> 0.10.0)
15
+ term-ansicolor (~> 1.3)
16
+ thor (~> 0.19.1)
17
+ cri (2.7.0)
18
+ colored (~> 1.2)
19
+ docile (1.1.5)
20
+ domain_name (0.5.25)
21
+ unf (>= 0.0.5, < 1.0.0)
22
+ http-cookie (1.0.2)
23
+ domain_name (~> 0.5)
24
+ json (1.8.3)
25
+ mime-types (2.6.2)
26
+ minitest (5.8.2)
27
+ nanoc (4.0.0)
28
+ cri (~> 2.3)
29
+ netrc (0.11.0)
30
+ rake (10.4.2)
31
+ rest-client (1.8.0)
32
+ http-cookie (>= 1.0.2, < 2.0)
33
+ mime-types (>= 1.16, < 3.0)
34
+ netrc (~> 0.7)
35
+ simplecov (0.10.0)
36
+ docile (~> 1.1.0)
37
+ json (~> 1.8)
38
+ simplecov-html (~> 0.10.0)
39
+ simplecov-html (0.10.0)
40
+ term-ansicolor (1.3.2)
41
+ tins (~> 1.0)
42
+ thor (0.19.1)
43
+ tins (1.6.0)
44
+ unf (0.1.4)
45
+ unf_ext
46
+ unf_ext (0.0.7.1)
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ bundler (~> 1.5)
53
+ coveralls
54
+ minitest
55
+ nanoc-git!
56
+ rake
57
+
58
+ BUNDLED WITH
59
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 Denis Defreyne and contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/NEWS.md ADDED
@@ -0,0 +1,5 @@
1
+ # nanoc-git news
2
+
3
+ ## 1.0.0 (???)
4
+
5
+ Initial release.
@@ -0,0 +1,31 @@
1
+ [![Build Status](https://travis-ci.org/nanoc/nanoc-git.png)](https://travis-ci.org/nanoc/nanoc-git)
2
+
3
+ # nanoc-git
4
+
5
+ This provides a Git deployer for [nanoc](http://nanoc.ws).
6
+
7
+ Maintained by [lifepillar](https://github.com/lifepillar).
8
+
9
+ ## Installation
10
+
11
+ `gem install nanoc-git`
12
+
13
+ ## Usage
14
+
15
+ Example configuration for the Git deployer:
16
+
17
+ ```yaml
18
+ deploy:
19
+ default:
20
+ kind: git
21
+ remote: git@github.com:myself/myproject.git
22
+ branch: gh-pages
23
+ forced: true
24
+ ```
25
+
26
+ The following configuration options are available:
27
+
28
+ * `remote` (default `origin`): the Git remote to deploy to
29
+ * `branch` (default `master`): the Git branch to deploy
30
+ * `forced` (default `false`): Whether or not to push with `--force`
31
+
data/Rakefile CHANGED
@@ -1,15 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'bundler'
4
- Bundler::GemHelper.install_tasks
3
+ require 'rake/testtask'
5
4
 
6
- $LOAD_PATH.unshift 'lib'
5
+ Rake::TestTask.new do |t|
6
+ t.libs = %w( lib test )
7
+ t.test_files = FileList['test/**/test_*.rb', 'test/**/*_spec.rb']
8
+ end
7
9
 
8
10
  task :default => :test
9
-
10
- desc "Run tests"
11
- task :test do
12
- Dir['test/*_test.rb'].each do |f|
13
- require File.expand_path(f)
14
- end
15
- end
@@ -1,8 +1,3 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Load requirements
4
- require 'nanoc3'
5
-
6
- # Load nanoc-git
7
- require 'nanoc-git/base'
8
- require 'nanoc-git/extra'
3
+ require 'nanoc/git'
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc
4
+ module Git
5
+ end
6
+ end
7
+
8
+ require 'nanoc/git/version'
9
+ require 'nanoc/git/deployer'
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc::Git
4
+ # A deployer that deploys a site using [Git](http://git-scm.com).
5
+ #
6
+ # @example A deployment configuration for GitHub Pages:
7
+ #
8
+ # deploy:
9
+ # default:
10
+ # kind: git
11
+ # remote: git@github.com:myself/myproject.git
12
+ # branch: gh-pages
13
+ # forced: true
14
+ #
15
+ class Deployer < ::Nanoc::Extra::Deployer
16
+ identifier :git
17
+
18
+ # @see Nanoc::Extra::Deployer#run
19
+ def run
20
+ unless File.exist?(source_path)
21
+ raise "#{source_path} does not exist. Please build your site first."
22
+ end
23
+
24
+ remote = config.fetch(:remote, 'origin')
25
+ branch = config.fetch(:branch, 'master')
26
+ forced = config.fetch(:forced, false)
27
+
28
+ puts "Deploying via git to remote='#{remote}' and branch='#{branch}'"
29
+
30
+ Dir.chdir(source_path) do
31
+ unless File.exist?('.git')
32
+ puts "#{source_path} does not appear to be a Git repo. Creating one..."
33
+ run_shell_cmd(%w( git init ))
34
+ end
35
+
36
+ # If the remote is not a URL already, verify that it is defined.
37
+ # Examples of URLs:
38
+ # https://github.com/nanoc/nanoc.git
39
+ # git@github.com:lifepillar/nanoc.git
40
+ unless remote.match(/:\/\/|@.+:/)
41
+ begin
42
+ run_shell_cmd(%W( git config --get remote.#{remote}.url ))
43
+ rescue Nanoc::Extra::Piper::Error
44
+ raise "Please add a remote called '#{remote}' to the repo inside #{source_path}."
45
+ end
46
+ end
47
+
48
+ # If the branch exists then switch to it, otherwise prompt the user to create one.
49
+ begin
50
+ run_shell_cmd(%W( git checkout #{branch} ))
51
+ rescue
52
+ raise "Branch '#{branch}' does not exist inside #{source_path}. Please create one and try again."
53
+ end
54
+
55
+ unless clean_repo?
56
+ msg = "Automated commit at #{Time.now.utc} by nanoc #{Nanoc::VERSION}"
57
+ run_shell_cmd(%w( git add -A ))
58
+ run_shell_cmd(%W( git commit -am #{msg} ))
59
+ end
60
+ if forced
61
+ run_shell_cmd(%W( git push -f #{remote} #{branch} ))
62
+ else
63
+ run_shell_cmd(%W( git push #{remote} #{branch} ))
64
+ end
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def run_shell_cmd(cmd)
71
+ if dry_run
72
+ puts cmd.join(' ')
73
+ else
74
+ piper = Nanoc::Extra::Piper.new(:stdout => $stdout, :stderr => $stderr)
75
+ piper.run(cmd, nil)
76
+ end
77
+ end
78
+
79
+ def clean_repo?
80
+ if dry_run && !File.exist?('.git')
81
+ true
82
+ else
83
+ stdout = StringIO.new
84
+ piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => $stderr)
85
+ piper.run(%w( git status --porcelain ), nil)
86
+ stdout.string.empty?
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc
4
+ module Git
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
@@ -1,20 +1,29 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.expand_path('../lib/', __FILE__))
4
+ require 'nanoc/git/version'
5
+
2
6
  Gem::Specification.new do |s|
3
7
  s.name = 'nanoc-git'
4
- s.version = '0.0.7'
5
- s.authors = ["Cameron Spickert"]
6
- s.email = ["cspicker@gmail.com"]
7
- s.homepage = "https://github.com/cspicker/nanoc-git"
8
- s.summary = "A Nanoc3 deployer for git"
9
- s.description = "A Nanoc3 extension that adds a Git deployer and associated rake task."
8
+ s.version = Nanoc::Git::VERSION
9
+ s.homepage = 'http://nanoc.ws/'
10
+ s.summary = 'Git deployer for nanoc'
11
+ s.description = 'Provides a git depoyer for nanoc'
12
+
13
+ s.author = 'Lifepillar'
14
+ s.email = 'github@lifepillar.org'
15
+ s.license = 'MIT'
16
+
17
+ s.required_ruby_version = '>= 1.9.3'
10
18
 
11
- s.rubyforge_project = "nanoc-git"
19
+ s.files = Dir['[A-Z]*'] +
20
+ Dir['{lib,test}/**/*'] +
21
+ [ 'nanoc-git.gemspec' ]
22
+ s.require_paths = [ 'lib' ]
12
23
 
13
- s.files = `git ls-files`.split("\n")
14
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
- s.require_paths = ["lib"]
24
+ s.rdoc_options = [ '--main', 'README.md' ]
25
+ s.extra_rdoc_files = [ 'LICENSE', 'README.md', 'NEWS.md' ]
17
26
 
18
- s.add_runtime_dependency('nanoc', '>= 3.1.6')
19
- s.add_runtime_dependency('git', '>= 1.2.5')
27
+ s.add_runtime_dependency('nanoc', '>= 3.7.0', '< 4.0.0')
28
+ s.add_development_dependency('bundler', '~> 1.5')
20
29
  end
@@ -0,0 +1,300 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class Nanoc::Git::DeployerTest < Minitest::Test
6
+ def setup
7
+ # Go quiet
8
+ unless ENV['QUIET'] == 'false'
9
+ @orig_stdout = $stdout
10
+ @orig_stderr = $stderr
11
+
12
+ $stdout = StringIO.new
13
+ $stderr = StringIO.new
14
+ end
15
+
16
+ # Enter tmp
17
+ @tmp_dir = Dir.mktmpdir('nanoc-test')
18
+ @orig_wd = FileUtils.pwd
19
+ FileUtils.cd(@tmp_dir)
20
+ end
21
+
22
+ def teardown
23
+ # Exit tmp
24
+ FileUtils.cd(@orig_wd)
25
+ FileUtils.rm_rf(@tmp_dir)
26
+
27
+ # Go unquiet
28
+ unless ENV['QUIET'] == 'false'
29
+ $stdout = @orig_stdout
30
+ $stderr = @orig_stderr
31
+ end
32
+ end
33
+
34
+ def test_run_without_output_folder
35
+ # Create deployer
36
+ git = Nanoc::Git::Deployer.new(
37
+ 'output/',
38
+ {})
39
+
40
+ # Try running
41
+ error = assert_raises(RuntimeError) do
42
+ git.run
43
+ end
44
+
45
+ # Check error message
46
+ assert_equal 'output/ does not exist. Please build your site first.', error.message
47
+ end
48
+
49
+ def test_run_with_defaults_options
50
+ # Create deployer
51
+ git = Nanoc::Git::Deployer.new(
52
+ 'output/',
53
+ {})
54
+
55
+ # Mock run_shell_cmd
56
+ def git.run_shell_cmd(args, opts = {})
57
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
58
+ @shell_cmd_args << args.join(' ')
59
+ end
60
+
61
+ # Mock clean_repo?
62
+ def git.clean_repo?
63
+ false
64
+ end
65
+
66
+ # Create site
67
+ FileUtils.mkdir_p('output')
68
+
69
+ # Try running
70
+ git.run
71
+
72
+ commands = <<-EOS
73
+ git init
74
+ git config --get remote.origin.url
75
+ git checkout master
76
+ git add -A
77
+ git commit -am Automated commit at .+ by nanoc \\d+\\.\\d+\\.\\d+
78
+ git push origin master
79
+ EOS
80
+
81
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
82
+ end
83
+
84
+ def test_run_with_clean_repository
85
+ # Create deployer
86
+ git = Nanoc::Git::Deployer.new(
87
+ 'output/',
88
+ {})
89
+
90
+ # Mock run_shell_cmd
91
+ def git.run_shell_cmd(args, opts = {})
92
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
93
+ @shell_cmd_args << args.join(' ')
94
+ end
95
+
96
+ # Mock clean_repo?
97
+ def git.clean_repo?
98
+ true
99
+ end
100
+
101
+ # Create site
102
+ FileUtils.mkdir_p('output')
103
+
104
+ # Try running
105
+ git.run
106
+
107
+ commands = <<-EOS
108
+ git init
109
+ git config --get remote.origin.url
110
+ git checkout master
111
+ git push origin master
112
+ EOS
113
+
114
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
115
+ end
116
+
117
+ def test_run_with_custom_options
118
+ # Create deployer
119
+ git = Nanoc::Git::Deployer.new(
120
+ 'output/',
121
+ { :remote => 'github', :branch => 'gh-pages', :forced => true })
122
+
123
+ # Mock run_shell_cmd
124
+ def git.run_shell_cmd(args, opts = {})
125
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
126
+ @shell_cmd_args << args.join(' ')
127
+ end
128
+
129
+ # Mock clean_repo?
130
+ def git.clean_repo?
131
+ false
132
+ end
133
+
134
+ # Create site
135
+ FileUtils.mkdir_p('output')
136
+
137
+ # Try running
138
+ git.run
139
+
140
+ commands = <<-EOS
141
+ git init
142
+ git config --get remote.github.url
143
+ git checkout gh-pages
144
+ git add -A
145
+ git commit -am Automated commit at .+ by nanoc \\d+\\.\\d+\\.\\d+
146
+ git push -f github gh-pages
147
+ EOS
148
+
149
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
150
+ end
151
+
152
+ def test_run_without_git_init
153
+ # Create deployer
154
+ git = Nanoc::Git::Deployer.new(
155
+ 'output/',
156
+ {})
157
+
158
+ # Mock run_shell_cmd
159
+ def git.run_shell_cmd(args, opts = {})
160
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
161
+ @shell_cmd_args << args.join(' ')
162
+ end
163
+
164
+ # Mock clean_repo?
165
+ def git.clean_repo?
166
+ false
167
+ end
168
+
169
+ # Create site
170
+ FileUtils.mkdir_p('output/.git')
171
+
172
+ # Try running
173
+ git.run
174
+
175
+ commands = <<-EOS
176
+ git config --get remote.origin.url
177
+ git checkout master
178
+ git add -A
179
+ git commit -am Automated commit at .+ by nanoc \\d+\\.\\d+\\.\\d+
180
+ git push origin master
181
+ EOS
182
+
183
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
184
+ end
185
+
186
+ def test_run_with_ssh_url
187
+ # Create deployer
188
+ git = Nanoc::Git::Deployer.new(
189
+ 'output/',
190
+ { :remote => 'git@github.com:myself/myproject.git' })
191
+
192
+ # Mock run_shell_cmd
193
+ def git.run_shell_cmd(args, opts = {})
194
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
195
+ @shell_cmd_args << args.join(' ')
196
+ end
197
+
198
+ # Mock clean_repo?
199
+ def git.clean_repo?
200
+ false
201
+ end
202
+
203
+ # Create site
204
+ FileUtils.mkdir_p('output')
205
+
206
+ # Try running
207
+ git.run
208
+
209
+ commands = <<-EOS
210
+ git init
211
+ git checkout master
212
+ git add -A
213
+ git commit -am Automated commit at .+ by nanoc \\d+\\.\\d+\\.\\d+
214
+ git push git@github.com:myself/myproject.git master
215
+ EOS
216
+
217
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
218
+ end
219
+
220
+ def test_run_with_http_url
221
+ # Create deployer
222
+ git = Nanoc::Git::Deployer.new(
223
+ 'output/',
224
+ { :remote => 'https://github.com/nanoc/nanoc.git' })
225
+
226
+ # Mock run_shell_cmd
227
+ def git.run_shell_cmd(args, opts = {})
228
+ @shell_cmd_args = [] unless defined? @shell_cmd_args
229
+ @shell_cmd_args << args.join(' ')
230
+ end
231
+
232
+ # Mock clean_repo?
233
+ def git.clean_repo?
234
+ false
235
+ end
236
+
237
+ # Create site
238
+ FileUtils.mkdir_p('output')
239
+
240
+ # Try running
241
+ git.run
242
+
243
+ commands = <<-EOS
244
+ git init
245
+ git checkout master
246
+ git add -A
247
+ git commit -am Automated commit at .+ by nanoc \\d+\\.\\d+\\.\\d+
248
+ git push https://github.com/nanoc/nanoc.git master
249
+ EOS
250
+
251
+ assert_match Regexp.new(/^#{commands.chomp}$/), git.instance_eval { @shell_cmd_args.join("\n") }
252
+ end
253
+
254
+ def test_clean_repo_on_a_clean_repo
255
+ # Create deployer
256
+ git = Nanoc::Git::Deployer.new(
257
+ 'output/',
258
+ { :remote => 'https://github.com/nanoc/nanoc.git' })
259
+
260
+ FileUtils.mkdir_p('output')
261
+
262
+ piper = Nanoc::Extra::Piper.new(:stdout => $stdout, :stderr => $stderr)
263
+
264
+ Dir.chdir('output') do
265
+ piper.run('git init', nil)
266
+ assert git.send(:clean_repo?)
267
+ end
268
+ end
269
+
270
+ def test_clean_repo_on_a_dirty_repo
271
+ # Create deployer
272
+ git = Nanoc::Git::Deployer.new(
273
+ 'output/',
274
+ { :remote => 'https://github.com/nanoc/nanoc.git' })
275
+
276
+ FileUtils.mkdir_p('output')
277
+
278
+ piper = Nanoc::Extra::Piper.new(:stdout => $stdout, :stderr => $stderr)
279
+ Dir.chdir('output') do
280
+ piper.run('git init', nil)
281
+ FileUtils.touch('foobar')
282
+ refute git.send(:clean_repo?)
283
+ end
284
+ end
285
+
286
+ def test_clean_repo_not_git_repo
287
+ # Create deployer
288
+ git = Nanoc::Git::Deployer.new(
289
+ 'output/',
290
+ { :remote => 'https://github.com/nanoc/nanoc.git' })
291
+
292
+ FileUtils.mkdir_p('output')
293
+
294
+ Dir.chdir('output') do
295
+ assert_raises Nanoc::Extra::Piper::Error do
296
+ git.send(:clean_repo?)
297
+ end
298
+ end
299
+ end
300
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'minitest'
7
+ require 'minitest/autorun'
8
+ require 'nanoc'
9
+ require 'nanoc-git'
metadata CHANGED
@@ -1,80 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
- - Cameron Spickert
7
+ - Lifepillar
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-06-01 00:00:00.000000000 -04:00
13
- default_executable:
11
+ date: 2015-11-16 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: nanoc
17
- requirement: &2156089080 !ruby/object:Gem::Requirement
18
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
- - - ! '>='
17
+ - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 3.1.6
19
+ version: 3.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2156089080
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
26
33
  - !ruby/object:Gem::Dependency
27
- name: git
28
- requirement: &2156088420 !ruby/object:Gem::Requirement
29
- none: false
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ! '>='
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 1.2.5
34
- type: :runtime
39
+ version: '1.5'
40
+ type: :development
35
41
  prerelease: false
36
- version_requirements: *2156088420
37
- description: A Nanoc3 extension that adds a Git deployer and associated rake task.
38
- email:
39
- - cspicker@gmail.com
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ description: Provides a git depoyer for nanoc
48
+ email: github@lifepillar.org
40
49
  executables: []
41
50
  extensions: []
42
- extra_rdoc_files: []
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.md
54
+ - NEWS.md
43
55
  files:
44
- - .gitignore
45
56
  - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE
59
+ - NEWS.md
60
+ - README.md
46
61
  - Rakefile
47
62
  - lib/nanoc-git.rb
48
- - lib/nanoc-git/base.rb
49
- - lib/nanoc-git/extra.rb
50
- - lib/nanoc-git/extra/deployers.rb
51
- - lib/nanoc-git/extra/deployers/git.rb
52
- - lib/nanoc-git/tasks.rb
53
- - lib/nanoc-git/tasks/deploy/git.rake
63
+ - lib/nanoc/git.rb
64
+ - lib/nanoc/git/deployer.rb
65
+ - lib/nanoc/git/version.rb
54
66
  - nanoc-git.gemspec
55
- has_rdoc: true
56
- homepage: https://github.com/cspicker/nanoc-git
57
- licenses: []
67
+ - test/filters/test_external.rb
68
+ - test/helper.rb
69
+ homepage: http://nanoc.ws/
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
58
73
  post_install_message:
59
- rdoc_options: []
74
+ rdoc_options:
75
+ - "--main"
76
+ - README.md
60
77
  require_paths:
61
78
  - lib
62
79
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
80
  requirements:
65
- - - ! '>='
81
+ - - ">="
66
82
  - !ruby/object:Gem::Version
67
- version: '0'
83
+ version: 1.9.3
68
84
  required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
85
  requirements:
71
- - - ! '>='
86
+ - - ">="
72
87
  - !ruby/object:Gem::Version
73
88
  version: '0'
74
89
  requirements: []
75
- rubyforge_project: nanoc-git
76
- rubygems_version: 1.6.2
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.7
77
92
  signing_key:
78
- specification_version: 3
79
- summary: A Nanoc3 deployer for git
93
+ specification_version: 4
94
+ summary: Git deployer for nanoc
80
95
  test_files: []
96
+ has_rdoc:
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- .DS_Store
2
- .rvmrc
3
- *.gem
4
- .bundle
5
- Gemfile.lock
6
- pkg/*
7
-
@@ -1,2 +0,0 @@
1
- module NanocGit
2
- end
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc-git'
4
-
5
- module NanocGit::Extra
6
- autoload 'Deployers', 'nanoc-git/extra/deployers'
7
- end
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc-git'
4
-
5
- module NanocGit::Extra
6
- module Deployers
7
- autoload 'Git', 'nanoc-git/extra/deployers/git'
8
- end
9
- end
@@ -1,102 +0,0 @@
1
- require 'git'
2
-
3
- module NanocGit::Extra::Deployers
4
-
5
- # A class for deploying a site using git.
6
- class Git
7
-
8
- # Creates a new deployer that uses git. The deployment configurations
9
- # will be read from the configuration file of the site (which is assumed
10
- # to exist).
11
- #
12
- # The deployment configurations are stored like this in the site's
13
- # configuration file:
14
- #
15
- # deploy:
16
- # NAME:
17
- # dst_remote: origin
18
- # dst_branch: master
19
- # src_branch: source
20
- #
21
- # `NAME` is a unique name for the deployment configuration. By default,
22
- # the deployer will use the deployment configuration named `"default"`.
23
- #
24
- # `DST_REMOTE` is the remote repository to which you are deploying your
25
- # site.
26
- #
27
- # `DST_BRANCH` is the branch to which you are deploying your compiled site.
28
- #
29
- # `SRC_BRANCH` is the branch that contains the source files for your site.
30
- #
31
- def initialize
32
- error 'No site configuration found' unless File.file?('config.yaml')
33
- @site = Nanoc3::Site.new('.')
34
- end
35
-
36
- # Runs the task. Possible params:
37
- #
38
- # @option params [String] :config_name (:default) The name of the
39
- # deployment configuration to use.
40
- #
41
- # @return [void]
42
- def run(params={})
43
- config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default
44
-
45
- # Validate config
46
- error 'No deploy configuration found' if @site.config[:deploy].nil?
47
- error "No deploy configuration found for #{config_name}" if @site.config[:deploy][config_name].nil?
48
-
49
- src_branch = @site.config[:deploy][config_name][:src_branch]
50
- dst_branch = @site.config[:deploy][config_name][:dst_branch]
51
- dst_remote = @site.config[:deploy][config_name][:dst_remote]
52
-
53
- error 'No source branch found in deployment configuration' if src_branch.nil?
54
- error 'No destination branch found in deployment configuration' if dst_branch.nil?
55
- error 'No destination remote found in deployment configuration' if dst_remote.nil?
56
-
57
- git = ::Git::Base.open('.')
58
-
59
- # Compile the site from scratch
60
- Nanoc3::Tasks::Clean.new(@site).run
61
-
62
- # Check out the source branch
63
- puts "Checking out #{src_branch}."
64
- git.checkout(src_branch)
65
-
66
- # Compile the site from scratch
67
- puts "Compiling site."
68
- @site.load_data
69
- @site.compiler.run
70
-
71
- # Check out the destination branch
72
- puts "Checking out destination branch."
73
- git.checkout(dst_branch)
74
-
75
- # Copy output files recursively into the current directory
76
- puts "Copying files."
77
- FileUtils.cp_r(@site.config[:output_dir].chomp('/') + '/.', '.')
78
-
79
- # Automatically add and commit changes
80
- puts "Committing changes."
81
- git.add
82
- git.commit("updated #{Time.now.to_s}", :add_all => true)
83
-
84
- # Push changes to the destination repo/branch
85
- puts "Pushing to #{dst_remote} #{dst_branch}."
86
- git.push(dst_remote, dst_branch)
87
-
88
- # Switch back to the source branch
89
- puts "Checking out #{src_branch}."
90
- git.checkout(src_branch)
91
- end
92
-
93
- private
94
-
95
- # Prints the given message on stderr and exits.
96
- def error(msg)
97
- raise RuntimeError.new(msg)
98
- end
99
-
100
- end
101
-
102
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc-git'
4
- require 'rake'
5
-
6
- module NanocGit::Tasks
7
- end
8
-
9
- Dir[File.dirname(__FILE__) + '/tasks/**/*.rb'].each { |f| load f }
10
- Dir[File.dirname(__FILE__) + '/tasks/**/*.rake'].each { |f| Rake.application.add_import(f) }
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- namespace :deploy do
4
- desc 'Upload the compiled site using git'
5
- task :git do
6
- config_name = ENV['config'] || :default
7
-
8
- deployer = NanocGit::Extra::Deployers::Git.new
9
- deployer.run(:config_name => config_name)
10
- end
11
- end