roger 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50192701fd5bb385f0a32bbea440e6d3cdabfe04
4
- data.tar.gz: 01cc88f4484ed65082066cd8d08cf07867173c38
3
+ metadata.gz: caddf4eeab48f002fe5dd4ed88b27c280117c3dd
4
+ data.tar.gz: ed435759636d5ce8390be0d68fb681a8ab0f796a
5
5
  SHA512:
6
- metadata.gz: 60257be39ef76dcc63add66ce63b6ff87d5607defcc6fb9b6de6da6198ec4f1fa5516a7a6603f4d12bb3aa95a5e773aec022a35da70d9d276929c4eac2a7ac51
7
- data.tar.gz: 4b33e90cc66ecab64f1683465ce5e5b91f0e8920a76c4754ae0514abd7bf131837afe236f816fde78da8ef8ff25fcfbbbd43cfb5591c54abb777cf37c62c7483
6
+ metadata.gz: 0ebee35b52dbad2cfe78fb7f8a767fc7aab6388cd79e9ad734a92ce0311d7a9804b6b6abf84a04c6726d22d0170ffc4b2cdf3887e271a5089e08e3e5015d23a9
7
+ data.tar.gz: c0f4f642ac62535fa9723342ecbc8c5789279eff1533cfacfd53d4887b3f24b28779209cd5d61a1bf0d2ac99d7d0c02e00a131225e227ee2683c82fb5bce0b5b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.3.3
4
+ * Add tests for rsync finalizer and get_files
5
+ * Get files now only matches files, not directories
6
+ * Rsync finalizer works with $CHILD_STATUS
7
+
3
8
  ## Version 1.3.2
4
9
  * Fix for missing variable in zip finalizer
5
10
  * Fix passing options within Mockup
@@ -0,0 +1,27 @@
1
+ module Roger
2
+ module Helpers
3
+ # Helper to include the get_files method
4
+ module GetFiles
5
+ # Get files from a path, skipping excludes.
6
+ #
7
+ # @param [Array] globs an array of file path globs that will be globbed
8
+ # against the project path
9
+ # @param [Array] excludes an array of regexps[!] that will be excluded
10
+ # from the result.
11
+ # @param [String, Pathname] Path to search files in
12
+ def get_files(globs, excludes = [], path = nil)
13
+ path = Pathname.new(get_files_default_path)
14
+ files = globs.map { |g| Dir.glob(path + g) }.flatten
15
+ files.reject! { |file| excludes.detect { |e| file.match(e) } } if excludes.any?
16
+ files.select { |file| File.file?(file) }
17
+ end
18
+
19
+ protected
20
+
21
+ # The default path to use when calling get_files
22
+ def get_files_default_path
23
+ fail "Implement #get_files_default_path in your class"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,4 +1,5 @@
1
1
  require "shellwords"
2
+ require "english"
2
3
 
3
4
  module Roger::Release::Finalizers
4
5
  # Finalizes the release by uploading your mockup with rsync to a remote server
@@ -17,8 +18,8 @@ module Roger::Release::Finalizers
17
18
  @options = {
18
19
  rsync: "rsync",
19
20
  remote_path: "",
20
- host: "",
21
- username: "",
21
+ host: nil,
22
+ username: nil,
22
23
  ask: true
23
24
  }.update(options)
24
25
  end
@@ -52,7 +53,9 @@ module Roger::Release::Finalizers
52
53
  end
53
54
 
54
55
  def rsync(command, local_path, remote_path, options = {})
55
- target_path = "#{options[:username]}@#{options[:host]}:#{remote_path}"
56
+ target_path = remote_path
57
+ target_path = "#{options[:host]}:#{target_path}" if options[:host]
58
+ target_path = "#{options[:username]}@#{target_path}" if options[:username]
56
59
 
57
60
  command = [
58
61
  options[:rsync],
@@ -74,7 +77,7 @@ module Roger::Release::Finalizers
74
77
  end
75
78
 
76
79
  def validate_options!(release, options)
77
- must_have_keys = [:remote_path, :host, :username]
80
+ must_have_keys = [:remote_path]
78
81
  return if (options.keys & must_have_keys).size == must_have_keys.size
79
82
 
80
83
  release.log(self, "Missing options: #{(must_have_keys - options.keys).inspect}")
@@ -1,4 +1,5 @@
1
1
  require "pathname"
2
+ require "english"
2
3
 
3
4
  module Roger
4
5
  class Release
data/lib/roger/release.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + "/cli"
2
2
  require File.dirname(__FILE__) + "/helpers/get_callable"
3
+ require File.dirname(__FILE__) + "/helpers/get_files"
3
4
  require File.dirname(__FILE__) + "/helpers/logging"
4
5
 
5
6
  require "shellwords"
@@ -8,6 +9,7 @@ module Roger
8
9
  # The release runner
9
10
  class Release
10
11
  include Roger::Helpers::Logging
12
+ include Roger::Helpers::GetFiles
11
13
 
12
14
  attr_reader :config, :project
13
15
 
@@ -200,19 +202,12 @@ module Roger
200
202
  project.mode = nil
201
203
  end
202
204
 
203
- # @param [Array] globs an array of file path globs that will be globbed against the build_path
204
- # @param [Array] excludes an array of regexps that will be excluded from the result
205
- def get_files(globs, excludes = [])
206
- files = globs.map { |g| Dir.glob(build_path + g) }.flatten
207
- if excludes.any?
208
- files.reject { |c| excludes.detect { |e| e.match(c) } }
209
- else
210
- files
211
- end
212
- end
213
-
214
205
  protected
215
206
 
207
+ def get_files_default_path
208
+ build_path
209
+ end
210
+
216
211
  def default_banner
217
212
  banner = [
218
213
  "Version : #{scm.version}",
data/lib/roger/test.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "thor"
2
2
  require File.dirname(__FILE__) + "/helpers/get_callable"
3
+ require File.dirname(__FILE__) + "/helpers/get_files"
3
4
  require File.dirname(__FILE__) + "/helpers/logging"
4
5
 
5
6
  module Roger
@@ -25,6 +26,7 @@ module Roger
25
26
  end
26
27
 
27
28
  include Roger::Helpers::Logging
29
+ include Roger::Helpers::GetFiles
28
30
 
29
31
  attr_reader :config, :project
30
32
 
@@ -99,25 +101,12 @@ module Roger
99
101
  end
100
102
  end
101
103
 
102
- # Get files from the project path
103
- #
104
- # @param [Array] globs an array of file path globs that will be globbed
105
- # against the project path
106
- # @param [Array] excludes an array of regexps[!] that will be excluded
107
- # from the result. N.b. please add an exclamation mark
108
- # if you wasted more then an hour of your life because the
109
- # shell glob didn't 'work'.
110
- def get_files(globs, excludes = [])
111
- files = globs.map { |g| Dir.glob(project.path + g) }.flatten
112
- if excludes.any?
113
- files.reject { |c| excludes.detect { |e| c.match(e) } }
114
- else
115
- files
116
- end
117
- end
118
-
119
104
  protected
120
105
 
106
+ def get_files_default_path
107
+ project.path
108
+ end
109
+
121
110
  def call_test(task)
122
111
  if task.is_a?(Array)
123
112
  task[0].call(self, task[1])
data/lib/roger/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Roger main namespace
2
2
  module Roger
3
- VERSION = "1.3.2"
3
+ VERSION = "1.3.3"
4
4
  end
@@ -0,0 +1,76 @@
1
+ require "test_helper"
2
+ require "test_construct"
3
+ require "./lib/roger/helpers/get_files"
4
+
5
+ # Empty class that uses getfiles
6
+ # This is outside of the Roger namespace by design.
7
+ class MyGetFiles
8
+ include TestConstruct::Helpers
9
+ include Roger::Helpers::GetFiles
10
+
11
+ attr_accessor :construct
12
+
13
+ def initialize
14
+ @construct = setup_construct
15
+ end
16
+
17
+ def destroy
18
+ teardown_construct(construct)
19
+ end
20
+
21
+ protected
22
+
23
+ def get_files_default_path
24
+ construct
25
+ end
26
+ end
27
+
28
+ module Roger
29
+ # Test GetFiles module
30
+ class GetFilesTest < ::Test::Unit::TestCase
31
+ def setup
32
+ @object = MyGetFiles.new
33
+
34
+ files = [
35
+ "a.js",
36
+ "1.js",
37
+ "1.html",
38
+ "dir/2.js",
39
+ "dir/3.js",
40
+ "dir/subdir/4.js"
41
+ ]
42
+
43
+ @files = files.map do |file|
44
+ @object.construct.file(file).to_s
45
+ end
46
+ end
47
+
48
+ def teardown
49
+ @object.destroy
50
+ end
51
+
52
+ def test_glob
53
+ files = @object.get_files(["**/*.js"])
54
+ expect = @files.grep(/\.js\Z/)
55
+ assert_array_contains(expect, files)
56
+ end
57
+
58
+ def test_get_only_files
59
+ dir = @object.construct.directory "evil.js"
60
+ files = @object.get_files(["*.js"])
61
+ assert_not_include files, dir.to_s
62
+ end
63
+
64
+ def test_excludes
65
+ files = @object.get_files(["**/*.js"], ["\Adir"])
66
+ expect = @files.grep(/\.js\Z/).reject { |f| f =~ /\Adir/ }
67
+ assert_array_contains(expect, files)
68
+ end
69
+
70
+ protected
71
+
72
+ def assert_array_contains(expect, result)
73
+ assert expect.size == result.size && expect & result == expect
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,52 @@
1
+ require "test_helper"
2
+ require "roger/testing/mock_release"
3
+
4
+ module Roger
5
+ # Test for Roger Rsync finalizer
6
+ class RsyncTest < ::Test::Unit::TestCase
7
+ include TestConstruct::Helpers
8
+
9
+ def setup
10
+ @release = Testing::MockRelease.new
11
+
12
+ # Create a file to release in the build dir
13
+ @release.project.construct.file "build/index.html"
14
+
15
+ # Set fixed version
16
+ @release.scm.version = "1.0.0"
17
+
18
+ # A target dir
19
+ @target_path = setup_construct(chdir: false)
20
+ end
21
+
22
+ # called after every single test
23
+ def teardown
24
+ teardown_construct(@target_path)
25
+ @release.destroy
26
+ @release = nil
27
+ end
28
+
29
+ def test_basic_functionality
30
+ finalizer = Roger::Release::Finalizers::Rsync.new(
31
+ remote_path: @target_path.to_s,
32
+ ask: false
33
+ )
34
+
35
+ finalizer.call(@release)
36
+
37
+ assert File.exist?(@target_path + "index.html"), @release.target_path.inspect
38
+ end
39
+
40
+ def test_rsync_command_works
41
+ finalizer = Roger::Release::Finalizers::Rsync.new(
42
+ rsync: "rsync-0123456789", # Let's hope nobody actually has this command
43
+ remote_path: @target_path.to_s,
44
+ ask: false
45
+ )
46
+
47
+ assert_raise(RuntimeError) do
48
+ finalizer.call(@release)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require "test_helper"
3
3
  require "./lib/roger/test.rb"
4
+ require "roger/testing/mock_project"
4
5
 
5
6
  module Roger
6
7
  # Testing the Roger Test fucntionality
@@ -8,12 +9,20 @@ module Roger
8
9
  def setup
9
10
  @files = ["html/javascripts/site.js",
10
11
  "html/vendor/underscore/underscore.js"]
11
- @globs = stub(map: @files)
12
12
 
13
- @project = Project.new(File.dirname(__FILE__) + "/../project", mockupfile_path: false)
13
+ @project = Testing::MockProject.new
14
+
15
+ @files.each do |file|
16
+ @project.construct.file file
17
+ end
18
+
14
19
  @mockupfile = Roger::Mockupfile.new(@project)
15
20
  end
16
21
 
22
+ def teardown
23
+ @project.destroy
24
+ end
25
+
17
26
  def test_test_run_should_set_project_mode
18
27
  assert_equal @project.mode, nil
19
28
 
@@ -26,16 +35,5 @@ module Roger
26
35
  @project.test.run!
27
36
  assert_equal @project.mode, nil
28
37
  end
29
-
30
- def test_get_files
31
- test = Roger::Test.new({})
32
- assert_equal(test.get_files(@globs), @files)
33
- end
34
-
35
- def test_get_files_excludes
36
- test = Roger::Test.new({})
37
- assert_equal(test.get_files(@globs, ["html\/vendor\/.+.js"]),
38
- ["html/javascripts/site.js"])
39
- end
40
38
  end
41
39
  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: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flurin Egger
@@ -10,62 +10,62 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-22 00:00:00.000000000 Z
13
+ date: 2015-06-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.19.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.19.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rack
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '>='
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: 1.0.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.0.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: tilt
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.0.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: 2.0.1
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: mime-types
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '2.2'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: '2.2'
71
71
  - !ruby/object:Gem::Dependency
@@ -86,98 +86,98 @@ dependencies:
86
86
  name: redcarpet
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 3.1.1
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 3.1.1
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: test-unit
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
105
  version: 3.0.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: 3.0.0
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: mocha
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ~>
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
119
  version: 1.1.0
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ~>
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: 1.1.0
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: simplecov
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ~>
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: 0.10.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ~>
138
+ - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: 0.10.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: puma
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
147
  version: 2.10.0
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ~>
152
+ - - "~>"
153
153
  - !ruby/object:Gem::Version
154
154
  version: 2.10.0
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: rubocop
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ~>
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
161
  version: 0.31.0
162
162
  type: :development
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ~>
166
+ - - "~>"
167
167
  - !ruby/object:Gem::Version
168
168
  version: 0.31.0
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: test_construct
171
171
  requirement: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ~>
173
+ - - "~>"
174
174
  - !ruby/object:Gem::Version
175
175
  version: '2.0'
176
176
  type: :development
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ~>
180
+ - - "~>"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '2.0'
183
183
  description: See homepage for more information.
@@ -190,10 +190,10 @@ extensions: []
190
190
  extra_rdoc_files:
191
191
  - README.md
192
192
  files:
193
- - .gitignore
194
- - .hound.yml
195
- - .rubocop.yml
196
- - .travis.yml
193
+ - ".gitignore"
194
+ - ".hound.yml"
195
+ - ".rubocop.yml"
196
+ - ".travis.yml"
197
197
  - CHANGELOG.md
198
198
  - Gemfile
199
199
  - MIT_LICENSE
@@ -226,6 +226,7 @@ files:
226
226
  - lib/roger/generators/new.rb
227
227
  - lib/roger/generators/templates/generator.tt
228
228
  - lib/roger/helpers/get_callable.rb
229
+ - lib/roger/helpers/get_files.rb
229
230
  - lib/roger/helpers/logging.rb
230
231
  - lib/roger/mockupfile.rb
231
232
  - lib/roger/project.rb
@@ -295,10 +296,12 @@ files:
295
296
  - test/unit/cli/cli_test_test.rb
296
297
  - test/unit/cli/cli_version_test.rb
297
298
  - test/unit/generators_test.rb
299
+ - test/unit/helpers/get_files_test.rb
298
300
  - test/unit/helpers/logging_test.rb
299
301
  - test/unit/rack/roger_test.rb
300
302
  - test/unit/release/cleaner_test.rb
301
303
  - test/unit/release/finalizers/git_branch_test.rb
304
+ - test/unit/release/finalizers/rsync_test.rb
302
305
  - test/unit/release/finalizers/zip_test.rb
303
306
  - test/unit/release/processors/mockup_test.rb
304
307
  - test/unit/release/processors/url_relativizer_test.rb
@@ -316,22 +319,22 @@ licenses:
316
319
  metadata: {}
317
320
  post_install_message:
318
321
  rdoc_options:
319
- - --charset=UTF-8
322
+ - "--charset=UTF-8"
320
323
  require_paths:
321
324
  - lib
322
325
  required_ruby_version: !ruby/object:Gem::Requirement
323
326
  requirements:
324
- - - '>='
327
+ - - ">="
325
328
  - !ruby/object:Gem::Version
326
329
  version: '0'
327
330
  required_rubygems_version: !ruby/object:Gem::Requirement
328
331
  requirements:
329
- - - '>='
332
+ - - ">="
330
333
  - !ruby/object:Gem::Version
331
334
  version: '0'
332
335
  requirements: []
333
336
  rubyforge_project:
334
- rubygems_version: 2.2.2
337
+ rubygems_version: 2.4.5
335
338
  signing_key:
336
339
  specification_version: 4
337
340
  summary: Roger is a set of tools to create self-containing HTML mockups.
@@ -378,10 +381,12 @@ test_files:
378
381
  - test/unit/cli/cli_test_test.rb
379
382
  - test/unit/cli/cli_version_test.rb
380
383
  - test/unit/generators_test.rb
384
+ - test/unit/helpers/get_files_test.rb
381
385
  - test/unit/helpers/logging_test.rb
382
386
  - test/unit/rack/roger_test.rb
383
387
  - test/unit/release/cleaner_test.rb
384
388
  - test/unit/release/finalizers/git_branch_test.rb
389
+ - test/unit/release/finalizers/rsync_test.rb
385
390
  - test/unit/release/finalizers/zip_test.rb
386
391
  - test/unit/release/processors/mockup_test.rb
387
392
  - test/unit/release/processors/url_relativizer_test.rb