roger 0.12.4 → 0.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/lib/roger/release/finalizers/git_branch.rb +52 -39
- data/lib/roger/release/finalizers/rsync.rb +56 -2
- data/lib/roger/release.rb +66 -63
- data/roger.gemspec +2 -1
- data/test/project/Mockupfile +6 -0
- data/test/unit/release/finalizers/git_branch_test.rb +51 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2JmMWYxYzdhOWI1YjhiMzU4MmI2YjJhYWYyN2JhZmNmZmMyYjZjZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDBkZDVmMmEzNzNhZDUyODk2Njg0MGJhYzcwZDA0NzE3YTQ0MWFlNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjZlNjYxNTU4OTA4NDdkNTM1MjJkZWQ2MmY0YTVmMjUzY2Q0M2NkZWQ3MDIw
|
10
|
+
YTUxNzRlMTMyNzFmZmJmMmJiNTM4NGI0NmJjZjhmZTE5OWY4N2M0NDBhYzNk
|
11
|
+
NzU2MTM4ZGJkOThhNDdiYTZkYjQ1Y2FlODQ5M2U2MmJmNmM1MzQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmMxOTY1NDFlMjMzYWViOTcyYTE2ODM1M2E2MjBiZWNkMDY5N2JkY2Q2MjZj
|
14
|
+
N2JmMGI5ZmI0MWVjZDg0YzVlMTk2ZTI4ZDhhMmVhZjY2Njc4ZmY1MDNiNjQ0
|
15
|
+
MDM0NGZhMzBkZmI1MTJlZjQwNmJlNDI5N2ViNzI2ZTBlNzY0ODM=
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 0.12.5
|
4
|
+
* Fix github pages finalizer to work if the Dir finalizer is loaded as well
|
5
|
+
* Run relativizer as the last thing before you finalize as to fix resolving issues with generated files
|
6
|
+
* Minor coding style issues
|
7
|
+
|
3
8
|
## Version 0.12.4
|
4
9
|
* Change upload prompt to conform to the [y/N] convention
|
5
10
|
* Fix git SCM to properly shell escape arguments so it works with special chars in paths
|
@@ -1,95 +1,108 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "tmpdir"
|
2
|
+
|
3
3
|
module Roger::Release::Finalizers
|
4
|
+
# Finalizes the release into a specific branch of a repository and pushes it
|
4
5
|
class GitBranch < Roger::Release::Finalizers::Base
|
5
|
-
|
6
6
|
# @param Hash options The options
|
7
7
|
#
|
8
|
-
# @option options String :remote The remote repository (default is the
|
8
|
+
# @option options String :remote The remote repository (default is the
|
9
|
+
# origin of the current repository)
|
9
10
|
# @option options String :branch The remote branch (default is "gh-pages")
|
10
|
-
# @option options Boolean :cleanup Cleanup temp dir afterwards (default is
|
11
|
-
#
|
12
|
-
|
11
|
+
# @option options Boolean :cleanup Cleanup temp dir afterwards (default is
|
12
|
+
# true)
|
13
|
+
# @option options Boolean :push Push to remote (default is true)
|
14
|
+
def initialize
|
13
15
|
@options = {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
16
|
+
remote: nil,
|
17
|
+
branch: "gh-pages",
|
18
|
+
cleanup: true,
|
19
|
+
push: true
|
18
20
|
}
|
19
21
|
end
|
20
|
-
|
21
|
-
|
22
|
+
|
22
23
|
def call(release, options = {})
|
23
|
-
options = @options.dup.update(options)
|
24
|
-
|
25
|
-
|
24
|
+
@options = @options.dup.update(options)
|
25
|
+
remote = find_git_remote
|
26
|
+
|
26
27
|
# 0. Get remote
|
27
|
-
unless remote
|
28
|
+
unless remote
|
28
29
|
raise "No remote found for origin"
|
29
30
|
end
|
30
|
-
|
31
|
+
|
31
32
|
e_remote = Shellwords.escape(remote)
|
32
|
-
e_branch = Shellwords.escape(options[:branch])
|
33
|
+
e_branch = Shellwords.escape(@options[:branch])
|
33
34
|
|
34
|
-
tmp_dir = Pathname.new(Dir.mktmpdir)
|
35
|
+
tmp_dir = Pathname.new(::Dir.mktmpdir)
|
35
36
|
clone_dir = tmp_dir + "clone"
|
36
|
-
|
37
|
+
|
37
38
|
# Check if remote already has branch
|
38
39
|
if `git ls-remote --heads #{e_remote} refs/heads/#{e_branch}` == ""
|
39
40
|
release.log(self, "Creating empty branch")
|
40
41
|
# Branch does not exist yet
|
41
42
|
FileUtils.mkdir(clone_dir)
|
42
|
-
Dir.chdir(clone_dir) do
|
43
|
+
::Dir.chdir(clone_dir) do
|
43
44
|
`git init`
|
44
45
|
`git remote add origin #{e_remote}`
|
45
46
|
`git checkout -b #{e_branch}`
|
46
47
|
end
|
47
48
|
else
|
48
49
|
release.log(self, "Cloning existing repo")
|
49
|
-
|
50
|
-
|
50
|
+
clone_options = "--branch #{e_branch} --single-branch #{clone_dir}"
|
51
|
+
# 1. Clone into different directory
|
52
|
+
`git clone #{e_remote} #{clone_options}`
|
51
53
|
end
|
52
|
-
|
54
|
+
|
53
55
|
release.log(self, "Working git magic in #{clone_dir}")
|
54
|
-
Dir.chdir(clone_dir) do
|
56
|
+
::Dir.chdir(clone_dir) do
|
55
57
|
# 3. Copy changes
|
56
58
|
FileUtils.rm_rf("*")
|
57
59
|
FileUtils.cp_r release.build_path.to_s + "/.", clone_dir.to_s
|
58
|
-
|
60
|
+
|
59
61
|
# 4. Add all files
|
60
62
|
`git add .`
|
61
|
-
|
63
|
+
|
62
64
|
# 5. Commit
|
63
65
|
`git commit -a -m "Release #{release.scm.version}"`
|
64
66
|
|
65
67
|
# 6. Git push
|
66
|
-
if options[:push]
|
68
|
+
if @options[:push]
|
67
69
|
`git push origin #{e_branch}`
|
68
70
|
end
|
69
71
|
end
|
70
|
-
|
71
|
-
if options[:cleanup]
|
72
|
+
|
73
|
+
if @options[:cleanup]
|
72
74
|
FileUtils.rm_rf(tmp_dir)
|
75
|
+
else
|
76
|
+
tmp_dir
|
73
77
|
end
|
74
|
-
|
75
78
|
end
|
76
|
-
|
79
|
+
|
77
80
|
protected
|
78
|
-
|
81
|
+
|
79
82
|
# Find the git dir
|
80
|
-
# TODO this is just a copy from release/scm/git.rb
|
83
|
+
# TODO this is just a copy from release/scm/git.rb
|
81
84
|
def find_git_dir(path)
|
82
85
|
path = Pathname.new(path).realpath
|
83
86
|
while path.parent != path && !(path + ".git").directory?
|
84
87
|
path = path.parent
|
85
88
|
end
|
86
|
-
|
89
|
+
|
87
90
|
path = path + ".git"
|
88
|
-
|
91
|
+
|
89
92
|
raise "Could not find suitable .git dir in #{path}" if !path.directory?
|
90
93
|
|
91
94
|
path
|
92
|
-
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_git_remote
|
98
|
+
(@options[:remote] ||
|
99
|
+
`git --git-dir=#{find_git_dir} config --get remote.origin.url`
|
100
|
+
).strip
|
101
|
+
end
|
93
102
|
end
|
94
103
|
end
|
95
|
-
|
104
|
+
|
105
|
+
Roger::Release::Finalizers.register(
|
106
|
+
:git_branch,
|
107
|
+
Roger::Release::Finalizers::GitBranch
|
108
|
+
)
|
@@ -43,7 +43,9 @@ module Roger::Release::Finalizers
|
|
43
43
|
|
44
44
|
local_path += "/" unless local_path =~ /\/\Z/
|
45
45
|
remote_path += "/" unless remote_path =~ /\/\Z/
|
46
|
-
|
46
|
+
|
47
|
+
self.add_htaccess(release, options) if options[:htaccess]
|
48
|
+
|
47
49
|
release.log(self, "Starting upload of #{(release.build_path + "*")} to #{options[:host]}")
|
48
50
|
|
49
51
|
command = "#{options[:rsync]} -az #{Shellwords.escape(local_path)} #{Shellwords.escape(options[:username])}@#{Shellwords.escape(options[:host])}:#{Shellwords.escape(remote_path)}"
|
@@ -59,6 +61,24 @@ module Roger::Release::Finalizers
|
|
59
61
|
end
|
60
62
|
|
61
63
|
protected
|
64
|
+
|
65
|
+
def add_htaccess(release, options)
|
66
|
+
remote_htaccess_path = File.join(options[:remote_path], ".htaccess")
|
67
|
+
remote_htpasswd_path = File.join(options[:remote_path], ".htpasswd")
|
68
|
+
local_path = release.build_path
|
69
|
+
|
70
|
+
shell = release.project.shell
|
71
|
+
|
72
|
+
# Get the remote file
|
73
|
+
command = "#{options[:rsync]} #{Shellwords.escape(options[:username])}@#{Shellwords.escape(options[:host])}:#{Shellwords.escape(remote_htaccess_path)} :#{Shellwords.escape(remote_htpasswd_path)} #{Shellwords.escape(local_path)}"
|
74
|
+
|
75
|
+
if File.exist?(local_path + ".htaccess") && File.exist?(local_path + ".htpasswd")
|
76
|
+
release.log(self, ".htaccess and .htpasswd already exist")
|
77
|
+
else
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
62
82
|
|
63
83
|
def validate_options!(release, options)
|
64
84
|
must_have_keys = [:remote_path, :host, :username]
|
@@ -76,4 +96,38 @@ module Roger::Release::Finalizers
|
|
76
96
|
end
|
77
97
|
end
|
78
98
|
|
79
|
-
Roger::Release::Finalizers.register(:rsync, Roger::Release::Finalizers::Rsync)
|
99
|
+
Roger::Release::Finalizers.register(:rsync, Roger::Release::Finalizers::Rsync)
|
100
|
+
|
101
|
+
|
102
|
+
# 1. Check option :htaccess => true
|
103
|
+
# 2. Check if remote file exists (.htaccess)
|
104
|
+
|
105
|
+
# 3. If it doesn't
|
106
|
+
# 4. Ask what the authname should be.
|
107
|
+
# 4. Ask if you want IP restriction
|
108
|
+
# 5. Ask if you want to add your own IP
|
109
|
+
# 6. Ask for other IPs
|
110
|
+
# 7. Ask if you want PW restriction
|
111
|
+
# 8. Ask for username
|
112
|
+
# 9. Ask for password (or Enter to generate)
|
113
|
+
# 10. Upload .htaccess
|
114
|
+
# 11. Upload .htpasswd
|
115
|
+
|
116
|
+
# 3. If it does
|
117
|
+
# 4. Output available users & ip's with access?
|
118
|
+
|
119
|
+
|
120
|
+
# AuthName "DNB Referentiesite"
|
121
|
+
# AuthType Basic
|
122
|
+
# AuthUserFile /home/users/entopic/vhome/entopic.com/dnb-referentie/.htpasswd
|
123
|
+
# Require valid-user
|
124
|
+
# Order deny,allow
|
125
|
+
# Deny from all
|
126
|
+
# Allow from 31.223.173.138 # Kantoor DP
|
127
|
+
# Satisfy Any
|
128
|
+
|
129
|
+
# <FilesMatch "\.(htaccess|htpasswd)$">
|
130
|
+
# Order Allow,Deny
|
131
|
+
# Deny from all
|
132
|
+
# </FilesMatch>
|
133
|
+
|
data/lib/roger/release.rb
CHANGED
@@ -2,45 +2,45 @@ require File.dirname(__FILE__) + "/cli"
|
|
2
2
|
|
3
3
|
module Roger
|
4
4
|
class Release
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :config, :project
|
7
|
-
|
7
|
+
|
8
8
|
attr_reader :finalizers, :injections, :stack, :cleanups
|
9
|
-
|
9
|
+
|
10
10
|
class << self
|
11
|
-
|
11
|
+
|
12
12
|
def default_stack
|
13
13
|
[]
|
14
|
-
end
|
15
|
-
|
14
|
+
end
|
15
|
+
|
16
16
|
def default_finalizers
|
17
17
|
[[self.get_callable(:dir, Roger::Release::Finalizers.map), {}]]
|
18
18
|
end
|
19
|
-
|
20
|
-
# Makes callable into a object that responds to call.
|
19
|
+
|
20
|
+
# Makes callable into a object that responds to call.
|
21
21
|
#
|
22
22
|
# @param [#call, Symbol, Class] callable If callable already responds to #call will just return callable, a Symbol will be searched for in the scope parameter, a class will be instantiated (and checked if it will respond to #call)
|
23
23
|
# @param [Hash] map, Mapping to match symbol to a callable
|
24
24
|
def get_callable(callable, map)
|
25
25
|
return callable if callable.respond_to?(:call)
|
26
|
-
|
26
|
+
|
27
27
|
if callable.kind_of?(Symbol) && map.has_key?(callable)
|
28
28
|
callable = map[callable]
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
if callable.kind_of?(Class)
|
32
32
|
callable = callable.new
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
if callable.respond_to?(:call)
|
36
36
|
callable
|
37
37
|
else
|
38
38
|
raise ArgumentError, "Could not resolve #{callable.inspect}. Callable must be an object that responds to #call or a symbol that resolve to such an object or a class with a #call instance method."
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
# @option config [Symbol] :scm The SCM to use (default = :git)
|
45
45
|
# @option config [String, Pathname] :target_path The path/directory to put the release into
|
46
46
|
# @option config [String, Pathname]:build_path Temporary path used to build the release
|
@@ -53,13 +53,13 @@ module Roger
|
|
53
53
|
:build_path => Pathname.new(Dir.pwd) + "build",
|
54
54
|
:cleanup_build => true
|
55
55
|
}
|
56
|
-
|
56
|
+
|
57
57
|
@config = {}.update(defaults).update(config)
|
58
58
|
@project = project
|
59
59
|
@stack = []
|
60
60
|
@finalizers = []
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
# Accessor for target_path
|
64
64
|
# The target_path is the path where the finalizers will put the release
|
65
65
|
#
|
@@ -67,15 +67,15 @@ module Roger
|
|
67
67
|
def target_path
|
68
68
|
Pathname.new(self.config[:target_path])
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
# Accessor for build_path
|
72
72
|
# The build_path is a temporary directory where the release will be built
|
73
73
|
#
|
74
|
-
# @return Pathname the build_path
|
74
|
+
# @return Pathname the build_path
|
75
75
|
def build_path
|
76
|
-
Pathname.new(self.config[:build_path])
|
76
|
+
Pathname.new(self.config[:build_path])
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
# Accessor for source_path
|
80
80
|
# The source path is the root of the mockup
|
81
81
|
#
|
@@ -83,11 +83,11 @@ module Roger
|
|
83
83
|
def source_path
|
84
84
|
Pathname.new(self.config[:source_path])
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# Get the current SCM object
|
88
88
|
def scm(force = false)
|
89
89
|
return @_scm if @_scm && !force
|
90
|
-
|
90
|
+
|
91
91
|
case self.config[:scm]
|
92
92
|
when :git
|
93
93
|
@_scm = Release::Scm::Git.new(:path => self.source_path)
|
@@ -95,16 +95,16 @@ module Roger
|
|
95
95
|
raise "Unknown SCM #{options[:scm].inspect}"
|
96
96
|
end
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
# Inject variables into files with an optional filter
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# @examples
|
102
102
|
# release.inject({"VERSION" => release.version, "DATE" => release.date}, :into => %w{_doc/toc.html})
|
103
|
-
# release.inject({"CHANGELOG" => {:file => "", :filter => BlueCloth}}, :into => %w{_doc/changelog.html})
|
103
|
+
# release.inject({"CHANGELOG" => {:file => "", :filter => BlueCloth}}, :into => %w{_doc/changelog.html})
|
104
104
|
def inject(variables, options)
|
105
105
|
@stack << Injector.new(variables, options)
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
# Use a certain pre-processor
|
109
109
|
#
|
110
110
|
# @examples
|
@@ -112,9 +112,9 @@ module Roger
|
|
112
112
|
def use(processor, options = {})
|
113
113
|
@stack << [self.class.get_callable(processor, Roger::Release::Processors.map), options]
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
# Write out the whole release into a directory, zip file or anything you can imagine
|
117
|
-
# #finalize can be called multiple times, it just will run all of them.
|
117
|
+
# #finalize can be called multiple times, it just will run all of them.
|
118
118
|
#
|
119
119
|
# The default finalizer is :dir
|
120
120
|
#
|
@@ -125,7 +125,7 @@ module Roger
|
|
125
125
|
def finalize(finalizer, options = {})
|
126
126
|
@finalizers << [self.class.get_callable(finalizer, Roger::Release::Finalizers.map), options]
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
# Files to clean up in the build directory just before finalization happens
|
130
130
|
#
|
131
131
|
# @param [String] Pattern to glob within build directory
|
@@ -135,7 +135,7 @@ module Roger
|
|
135
135
|
def cleanup(pattern)
|
136
136
|
@stack << Cleaner.new(pattern)
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# Generates a banner if a block is given, or returns the currently set banner.
|
140
140
|
# It automatically takes care of adding comment marks around the banner.
|
141
141
|
#
|
@@ -152,7 +152,7 @@ module Roger
|
|
152
152
|
options = {
|
153
153
|
:comment => :js
|
154
154
|
}.update(options)
|
155
|
-
|
155
|
+
|
156
156
|
if block_given?
|
157
157
|
@_banner = yield.to_s
|
158
158
|
elsif !@_banner
|
@@ -167,14 +167,14 @@ module Roger
|
|
167
167
|
banner << div
|
168
168
|
@_banner = banner.join("\n")
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
if options[:comment]
|
172
172
|
self.comment(@_banner, :style => options[:comment])
|
173
173
|
else
|
174
174
|
@_banner
|
175
175
|
end
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
# Extract the mockup, this will happen anyway, and will always happen first
|
179
179
|
# This method gives you a way to pass options to the extractor.
|
180
180
|
#
|
@@ -185,28 +185,28 @@ module Roger
|
|
185
185
|
self.warn(self, "Don't use the extractor anymore, use release.use(:mockup, options) and release.use(:url_relativizer, options) processors")
|
186
186
|
@extractor_options = options
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
# Actually perform the release
|
190
190
|
def run!
|
191
191
|
# Validate paths
|
192
192
|
validate_paths!
|
193
|
-
|
193
|
+
|
194
194
|
# Extract mockup
|
195
195
|
copy_source_path_to_build_path!
|
196
|
-
|
196
|
+
|
197
197
|
validate_stack!
|
198
|
-
|
198
|
+
|
199
199
|
# Run stack
|
200
200
|
run_stack!
|
201
|
-
|
201
|
+
|
202
202
|
# Run finalizers
|
203
203
|
run_finalizers!
|
204
|
-
|
204
|
+
|
205
205
|
# Cleanup
|
206
206
|
cleanup! if self.config[:cleanup_build]
|
207
|
-
|
208
|
-
end
|
209
|
-
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
210
|
# Write out a log message
|
211
211
|
def log(part, msg, verbose = false, &block)
|
212
212
|
if !verbose || verbose && self.project.options[:verbose]
|
@@ -221,17 +221,17 @@ module Roger
|
|
221
221
|
end
|
222
222
|
end
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
def debug(part, msg, &block)
|
226
226
|
self.log(part, msg, true, &block)
|
227
227
|
end
|
228
|
-
|
228
|
+
|
229
229
|
# Write out a warning message
|
230
230
|
def warn(part, msg)
|
231
231
|
self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + "\033[31m#{msg.to_s}\033[0m", nil, true
|
232
232
|
end
|
233
|
-
|
234
|
-
|
233
|
+
|
234
|
+
|
235
235
|
# @param [Array] globs an array of file path globs that will be globbed against the build_path
|
236
236
|
# @param [Array] excludes an array of regexps that will be excluded from the result
|
237
237
|
def get_files(globs, excludes = [])
|
@@ -242,13 +242,13 @@ module Roger
|
|
242
242
|
files
|
243
243
|
end
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
protected
|
247
|
-
|
247
|
+
|
248
248
|
# ==============
|
249
249
|
# = The runway =
|
250
250
|
# ==============
|
251
|
-
|
251
|
+
|
252
252
|
# Checks if build path exists (and cleans it up)
|
253
253
|
# Checks if target path exists (if not, creates it)
|
254
254
|
def validate_paths!
|
@@ -256,17 +256,17 @@ module Roger
|
|
256
256
|
log self, "Cleaning up previous build \"#{self.build_path}\""
|
257
257
|
rm_rf(self.build_path)
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
if !self.target_path.exist?
|
261
261
|
log self, "Creating target path \"#{self.target_path}\""
|
262
262
|
mkdir self.target_path
|
263
263
|
end
|
264
264
|
end
|
265
|
-
|
265
|
+
|
266
266
|
# Checks if deprecated extractor options have been set
|
267
267
|
# Checks if the mockup will be runned
|
268
268
|
def validate_stack!
|
269
|
-
|
269
|
+
|
270
270
|
mockup_options = {}
|
271
271
|
relativizer_options = {}
|
272
272
|
run_relativizer = true
|
@@ -275,21 +275,24 @@ module Roger
|
|
275
275
|
relativizer_options = {:url_attributes => @extractor_options[:url_attributes]}
|
276
276
|
run_relativizer = @extractor_options[:url_relativize]
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
279
|
unless @stack.find{|(processor, options)| processor.class == Roger::Release::Processors::Mockup }
|
280
|
-
@stack.unshift([Roger::Release::Processors::UrlRelativizer.new, relativizer_options])
|
281
280
|
@stack.unshift([Roger::Release::Processors::Mockup.new, mockup_options])
|
282
281
|
end
|
282
|
+
|
283
|
+
unless @stack.find{|(processor, options)| processor.class == Roger::Release::Processors::UrlRelativizer }
|
284
|
+
@stack.push([Roger::Release::Processors::UrlRelativizer.new, relativizer_options])
|
285
|
+
end
|
283
286
|
end
|
284
|
-
|
287
|
+
|
285
288
|
def copy_source_path_to_build_path!
|
286
289
|
mkdir(self.build_path)
|
287
290
|
cp_r(self.source_path.children, self.build_path)
|
288
291
|
end
|
289
|
-
|
292
|
+
|
290
293
|
def run_stack!
|
291
294
|
@stack = self.class.default_stack.dup if @stack.empty?
|
292
|
-
|
295
|
+
|
293
296
|
# call all objects in @stack
|
294
297
|
@stack.each do |task|
|
295
298
|
if (task.kind_of?(Array))
|
@@ -302,19 +305,19 @@ module Roger
|
|
302
305
|
|
303
306
|
def run_finalizers!
|
304
307
|
@finalizers = self.class.default_finalizers.dup if @finalizers.empty?
|
305
|
-
|
308
|
+
|
306
309
|
# call all objects in @finalizes
|
307
310
|
@finalizers.each do |finalizer|
|
308
311
|
finalizer[0].call(self, finalizer[1])
|
309
312
|
end
|
310
313
|
|
311
314
|
end
|
312
|
-
|
315
|
+
|
313
316
|
def cleanup!
|
314
317
|
log(self, "Cleaning up build path #{self.build_path}")
|
315
318
|
rm_rf(self.build_path)
|
316
319
|
end
|
317
|
-
|
320
|
+
|
318
321
|
# @param [String] string The string to comment
|
319
322
|
#
|
320
323
|
# @option options [:html, :css, :js] :style The comment style to use (default=:js, which is the same as :css)
|
@@ -324,15 +327,15 @@ module Roger
|
|
324
327
|
:style => :css,
|
325
328
|
:per_line => true
|
326
329
|
}.update(options)
|
327
|
-
|
330
|
+
|
328
331
|
commenters = {
|
329
332
|
:html => Proc.new{|s| "<!-- #{s} -->" },
|
330
333
|
:css => Proc.new{|s| "/*! #{s} */" },
|
331
|
-
:js => Proc.new{|s| "/*! #{s} */" }
|
334
|
+
:js => Proc.new{|s| "/*! #{s} */" }
|
332
335
|
}
|
333
|
-
|
336
|
+
|
334
337
|
commenter = commenters[options[:style]] || commenters[:js]
|
335
|
-
|
338
|
+
|
336
339
|
if options[:per_line]
|
337
340
|
string = string.split(/\r?\n/)
|
338
341
|
string.map{|s| commenter.call(s) }.join("\n")
|
data/roger.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "roger"
|
5
|
-
s.version = "0.12.
|
5
|
+
s.version = "0.12.5"
|
6
6
|
|
7
7
|
s.authors = ["Flurin Egger", "Edwin van der Graaf", "Joran Kapteijns"]
|
8
8
|
s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
|
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_dependency("redcarpet", [">= 3.1.1"])
|
34
34
|
|
35
35
|
s.add_development_dependency("test-unit", "~> 2.5.5")
|
36
|
+
s.add_development_dependency("mocha", "~> 1.1.0")
|
36
37
|
end
|
data/test/project/Mockupfile
CHANGED
@@ -7,6 +7,12 @@ mockup.project.partial_path = [mockup.project.path + "partials", mockup.project.
|
|
7
7
|
mockup.serve do |s|
|
8
8
|
end
|
9
9
|
|
10
|
+
mockup.test do |t|
|
11
|
+
|
12
|
+
t.use :jshint
|
13
|
+
|
14
|
+
end
|
15
|
+
|
10
16
|
mockup.release do |r|
|
11
17
|
r.use :mockup
|
12
18
|
r.use :url_relativizer, :skip => [/non-relative.*/]
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "./lib/roger/release/finalizers/git_branch.rb"
|
2
|
+
require "test/unit"
|
3
|
+
require "mocha/test_unit"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
class GitBranchTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
# Mock git repo
|
9
|
+
@tmp_dir = Pathname.new(Dir.mktmpdir)
|
10
|
+
mock_repo_path = @tmp_dir + "mock_repo"
|
11
|
+
FileUtils.mkdir(mock_repo_path)
|
12
|
+
Dir.chdir(mock_repo_path) do
|
13
|
+
`git init`
|
14
|
+
`mkdir releases`
|
15
|
+
`touch releases/index.html`
|
16
|
+
end
|
17
|
+
|
18
|
+
# Mock release object
|
19
|
+
@release_mock = stub(project: stub(path: mock_repo_path))
|
20
|
+
|
21
|
+
@release_mock.stubs(
|
22
|
+
scm: stub(version: "0.1.999"),
|
23
|
+
log: true,
|
24
|
+
build_path: mock_repo_path.to_s + "/releases"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
# called after every single test
|
29
|
+
def teardown
|
30
|
+
FileUtils.rm_rf(@tmp_dir)
|
31
|
+
@release_mock = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_basic_functionality
|
35
|
+
git_branch_finalizers = Roger::Release::Finalizers::GitBranch.new
|
36
|
+
|
37
|
+
output_dir = git_branch_finalizers.call(
|
38
|
+
@release_mock,
|
39
|
+
remote: "http://we.aint.go/nna.push.git",
|
40
|
+
push: false,
|
41
|
+
cleanup: false
|
42
|
+
)
|
43
|
+
|
44
|
+
Dir.chdir(output_dir + "clone") do
|
45
|
+
commit_msg = `git log --pretty=oneline --abbrev-commit`
|
46
|
+
assert_match /Release 0.1.999/, commit_msg
|
47
|
+
end
|
48
|
+
|
49
|
+
FileUtils.rm_rf(output_dir)
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flurin Egger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -110,6 +110,20 @@ dependencies:
|
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 2.5.5
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: mocha
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ~>
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.1.0
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ~>
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.1.0
|
113
127
|
description:
|
114
128
|
email:
|
115
129
|
- info@digitpaint.nl
|
@@ -203,6 +217,7 @@ files:
|
|
203
217
|
- test/unit/cli_test.rb
|
204
218
|
- test/unit/generators_test.rb
|
205
219
|
- test/unit/release/cleaner_test.rb
|
220
|
+
- test/unit/release/finalizers/git_branch_test.rb
|
206
221
|
- test/unit/release/processors_test.rb
|
207
222
|
- test/unit/release_test.rb
|
208
223
|
- test/unit/resolver_test.rb
|
@@ -228,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
243
|
version: '0'
|
229
244
|
requirements: []
|
230
245
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
246
|
+
rubygems_version: 2.1.5
|
232
247
|
signing_key:
|
233
248
|
specification_version: 4
|
234
249
|
summary: Roger is a set of tools to create self-containing HTML mockups.
|
@@ -266,6 +281,7 @@ test_files:
|
|
266
281
|
- test/unit/cli_test.rb
|
267
282
|
- test/unit/generators_test.rb
|
268
283
|
- test/unit/release/cleaner_test.rb
|
284
|
+
- test/unit/release/finalizers/git_branch_test.rb
|
269
285
|
- test/unit/release/processors_test.rb
|
270
286
|
- test/unit/release_test.rb
|
271
287
|
- test/unit/resolver_test.rb
|