octopress-deploy 1.0.0.alpha.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66021404123816e4820561fd5fe7947a5d81b8a4
4
+ data.tar.gz: 5b0576fa6dfa5a337a66ff1359f130f4c94709be
5
+ SHA512:
6
+ metadata.gz: e94e8a096b77d825539c1a0b4934ee1a72d4ff22e045a396dd997bb77c6fec3fea9755d8ca818b1953266bd8b8d2ed6adcb38dd7192a44c6eb86281599d85eba
7
+ data.tar.gz: 6074f3c5f0fad12aec8f7502de2c8e09352b6e3428d646c1abeb9b30e57e1e84016cad2408ad89bfa23847d6ce4dacd2638115da573a1417c1aabf8810b504b1
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ test/.deploy
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in octopress-deploy-git.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Octopress::Deploy
2
+
3
+ This gem will contain the default deployment commands for Octopress.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'octopress-deploy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install octopress-deploy-git
18
+
19
+ ## Deploying with Git
20
+
21
+ This is a generic git deployment system, it should work for GitHub, Heroku and other similar hosts.
22
+
23
+ #### 1. Add a `_deploy.yml` configuration file to your project root.
24
+
25
+ For GitHub user pages, the url should be something like: `git@github.com:username.github.io` and the branch should be master.
26
+ For project pages, the url should be the path to the project repo and the branch should be `gh-pages`.
27
+
28
+ ```yml
29
+ site: _site
30
+ git:
31
+ url: [git url]
32
+ branch: master
33
+ ```
34
+
35
+ #### 2. From Ruby run:
36
+
37
+ ```ruby
38
+ Octopress::Deploy::Git.new().push
39
+ ```
40
+
41
+ ### Options
42
+
43
+ It is recommended that you configure using the `deploy.yml`, but you can also pass configuration as options.
44
+
45
+ | option | Description | Default
46
+ |:--------------|:-------------------------------------------------|:---------------|
47
+ | `config_file` | Path to the config file. | _config.yml |
48
+ | `site_dir` | Path to comipled site files. | _site |
49
+ | `git_url` | Url for remote git repository. | |
50
+ | `git_branch` | Deployment branch for git repository. | master |
51
+ | `deploy_dir` | Directory where deployment files are staged. | .deploy |
52
+ | `remote` | Name of git remote. | deploy |
53
+
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+ ## License
64
+
65
+ Copyright (c) 2014 Brandon Mathis
66
+
67
+ MIT License
68
+
69
+ Permission is hereby granted, free of charge, to any person obtaining
70
+ a copy of this software and associated documentation files (the
71
+ "Software"), to deal in the Software without restriction, including
72
+ without limitation the rights to use, copy, modify, merge, publish,
73
+ distribute, sublicense, and/or sell copies of the Software, and to
74
+ permit persons to whom the Software is furnished to do so, subject to
75
+ the following conditions:
76
+
77
+ The above copyright notice and this permission notice shall be
78
+ included in all copies or substantial portions of the Software.
79
+
80
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
81
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
82
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
83
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
84
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
85
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
86
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ require "octopress-deploy/version"
2
+ require "YAML"
3
+ require 'colorator'
4
+ require 'open3'
5
+
6
+ module Octopress
7
+ module Deploy
8
+ autoload :Git, 'octopress-deploy/git'
9
+ end
10
+ end
@@ -0,0 +1,129 @@
1
+ module Octopress
2
+ module Deploy
3
+ class Git
4
+ def initialize(options={})
5
+ @config_file = options[:config_file] || '_deploy.yml'
6
+ if !File.exists? @config_file
7
+ init_config if ask_bool("Deployment config file not found. Create #{@config_file}?")
8
+ else
9
+ config = YAML.load(File.open(@config_file))
10
+ @site_dir = options[:site_dir] || config['site']
11
+ @repo = options[:git_url] || config['git']['url']
12
+ @branch = options[:git_branch] || config['git']['branch']
13
+ @deploy_dir = options[:deploy_dir] || config['git']['deploy_dir'] || '.deploy'
14
+ @remote = options[:remote] || config['git']['remote'] || 'deploy'
15
+ end
16
+ end
17
+
18
+ # Create a config file
19
+ #
20
+ def init_config
21
+ config = <<-FILE
22
+ site: _site
23
+ git:
24
+ url:
25
+ branch: master
26
+ FILE
27
+ File.open(@config_file, 'w') { |f| f.write(config) }
28
+ puts "File #{@config_file} created.".green
29
+ puts "------------------"
30
+ puts config
31
+ puts "------------------"
32
+ puts "Please update it with your settings."
33
+ end
34
+
35
+ # Initialize, pull, copy and deploy.
36
+ # This is the method you're looking for.
37
+ #
38
+ def push
39
+ init_repo unless check_repo
40
+ git_pull
41
+ copy_site
42
+ git_push
43
+ end
44
+
45
+ # Check to see if local deployment dir configured to deploy
46
+ #
47
+ def check_repo
48
+ return unless Dir.exist? @deploy_dir
49
+ FileUtils.cd @deploy_dir do
50
+ return `git remote -v`.include? @repo
51
+ end
52
+ end
53
+
54
+
55
+ # If necessary create deploy directory and initialize it with deployment remote
56
+ #
57
+ def init_repo
58
+ FileUtils.mkdir_p @deploy_dir
59
+ FileUtils.cd @deploy_dir do
60
+ if Dir[@deploy_dir+'/*'].empty?
61
+
62
+ # Attempt to clone from the remote
63
+ #
64
+ cmd = "git clone #{@repo} --origin #{@remote} --branch #{@branch} ."
65
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
66
+ exit_status = wait_thr.value
67
+
68
+ # If cloning fails, initialize the directory manually
69
+ # This will occur if a remote has no commits
70
+ #
71
+ unless exit_status.success?
72
+ `git init; git remote add #{@remote} #{@repo}`
73
+ `echo "initialize deploy repo" > _`
74
+ `git add .; git commit -m 'initial commit'`
75
+ `git branch -m #{@branch}`
76
+ `git rm _; git add -u; git commit -m 'cleanup'`
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ def git_push
84
+ FileUtils.cd @deploy_dir do
85
+ `git push #{@remote} #{@branch}`
86
+ end
87
+ end
88
+
89
+ def git_pull
90
+ FileUtils.cd @deploy_dir do
91
+ output, error = Open3.capture3"git pull #{@remote} #{@branch}"
92
+ FileUtils.rm_rf(Dir.glob('*'), secure: true) if error.empty?
93
+ end
94
+ end
95
+
96
+ def copy_site
97
+ FileUtils.cp_r @site_dir + '/.', @deploy_dir
98
+ FileUtils.cd @deploy_dir do
99
+ message = "Site updated at: #{Time.now.utc}"
100
+ `git add --all :/; git commit -m '#{message}'`
101
+ end
102
+ end
103
+
104
+ def ask_bool(message)
105
+ ask(message, ['y','n']) == 'y'
106
+ end
107
+
108
+ def ask(message, valid_options)
109
+ if valid_options
110
+ options = valid_options.join '/'
111
+ answer = get_stdin("#{message} [#{options}]: ").downcase.strip
112
+ if valid_options.map{|o| o.downcase}.include?(answer)
113
+ return answer
114
+ else
115
+ return false
116
+ end
117
+ else
118
+ answer = get_stdin("#{message}: ")
119
+ end
120
+ answer
121
+ end
122
+
123
+ def get_stdin(message)
124
+ print message
125
+ STDIN.gets.chomp
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,5 @@
1
+ module Octopress
2
+ module Deploy
3
+ VERSION = "1.0.0.alpha.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'octopress-deploy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "octopress-deploy"
8
+ spec.version = Octopress::Deploy::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.description = %q{Deploy Octopress and Jekyll sites easily}
12
+ spec.summary = %q{Deploy Octopress and Jekyll sites easily}
13
+ spec.homepage = "https://github.com/octopress/deploy"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "colorator"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
data/test/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :jekyll_plugins do
4
+ gem "octopress-deploy", path: "../"
5
+ end
6
+
7
+ gem "pry-debugger"
data/test/_deploy.yml ADDED
@@ -0,0 +1,4 @@
1
+ site: _site
2
+ git:
3
+ url:
4
+ branch: master
data/test/_site/foo ADDED
@@ -0,0 +1 @@
1
+ asdfasdf
data/test/_site/test ADDED
@@ -0,0 +1 @@
1
+ fioobr
data/test/test.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'octopress-deploy'
2
+
3
+ FileUtils.mkdir 'deploy_target'
4
+ FileUtils.cd 'deploy_target' do
5
+ system 'git init --bare'
6
+ end
7
+
8
+ Octopress::Deploy::Git.new({url: File.expand_path('deploy_target')}).push
9
+ FileUtils.rm_r 'deploy_target'
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.alpha.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorator
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Deploy Octopress and Jekyll sites easily
56
+ email:
57
+ - brandon@imathis.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/octopress-deploy.rb
68
+ - lib/octopress-deploy/git.rb
69
+ - lib/octopress-deploy/version.rb
70
+ - octopress-deploy.gemspec
71
+ - test/Gemfile
72
+ - test/_deploy.yml
73
+ - test/_site/foo
74
+ - test/_site/test
75
+ - test/test.rb
76
+ homepage: https://github.com/octopress/deploy
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>'
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.1
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.1.11
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Deploy Octopress and Jekyll sites easily
100
+ test_files:
101
+ - test/Gemfile
102
+ - test/_deploy.yml
103
+ - test/_site/foo
104
+ - test/_site/test
105
+ - test/test.rb