roger 1.0.1 → 1.1.0

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: 5e0f86b2900d47b937fc8dfb690db21c77872639
4
- data.tar.gz: 60c2e435b91fd529cf336117bdcb14150275c742
3
+ metadata.gz: 28dd28041cfcd471cf9ced59eb34fc583da7e8d7
4
+ data.tar.gz: 3728b68fa1fdbfacca3baf14fdf9ad3ccae869bf
5
5
  SHA512:
6
- metadata.gz: 23e28a30047b8822944a568d6ecf48cdf32ddc56ef8aad5316d275edce910f5cef21293d96b57bba3a535a3d518c8ecdd2427c43b2bc12e285ee8b3db6181330
7
- data.tar.gz: 0beb01fdac08535e30f380f0650ff29c8b44228bbf8f20f4635ea991c226020a4d21e8a7110157e292bcb818759622ec732df7e2de1e7887dcf1e8c5726dce2a
6
+ metadata.gz: 1b6d9a19eacc627633c8770eeeade02241f4e9ce998d8fa7e4fda1ea661edf43cff1074901d4cec45a90092a2aaea81918269bf9ae39693674b0dc33c63b4417
7
+ data.tar.gz: 871ee889484649653e5b25e297d1754668179462648b53be74fd5783128dc36e4efa40f20b7dae75fd006c501ee9a86d43404c68c13c87cdbd711ecf3906ea51
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.1.0
4
+
5
+ * Allow passing of options to release, test and server from Mockupfile
6
+ * Add option to make blank releases by passing `blank: true`; a blank release will not automatically add default processors and finalizers. This is a non-breaking change, the default is blank: false
7
+ * Add project.mode so we can infer what mode we're in (:test, :release, :server) when running processors, middleware, tests, ets.
8
+ * Release now by default takes project path as root instead of PWD. If you rely on this behaviour you may want to pass your own path definitions in mockup.release(....).
9
+
3
10
  ## Version 1.0.1
4
11
 
5
12
  * Release copy command is now configurable by passing :cp configuration option to the mockup.release command in the mockup file. By default the release now uses system cp instead of fileutils cp so we can follow symlinks (you don't want symlinks in your release). If you want the old behaviour you have to pass {cp: nil}.
@@ -43,27 +43,30 @@ module Roger
43
43
  @loaded
44
44
  end
45
45
 
46
- def release
46
+ def release(options = {})
47
+ release = self.project.release(options)
47
48
  if block_given?
48
- yield(self.project.release)
49
+ yield(release)
49
50
  end
50
- self.project.release
51
+ release
51
52
  end
52
53
 
53
- def serve
54
+ def serve(options = {})
55
+ server = self.project.server(options)
54
56
  if block_given?
55
- yield(self.project.server)
57
+ yield(server)
56
58
  end
57
- self.project.server
59
+ server
58
60
  end
59
61
 
60
62
  alias :server :serve
61
63
 
62
- def test
64
+ def test(options = {})
65
+ test = self.project.test(options)
63
66
  if block_given?
64
- yield(self.project.test)
67
+ yield(test)
65
68
  end
66
- self.project.test
69
+ test
67
70
  end
68
71
 
69
72
  end
data/lib/roger/project.rb CHANGED
@@ -13,7 +13,8 @@ module Roger
13
13
  # @attr :partial_path [Pathname] The path for the partials for this mockup
14
14
  # @attr :mockupfile [Mockupfile] The Mockupfile for this project
15
15
  # @attr :mockupfile_path [Pathname] The path to the Mockupfile
16
- attr_accessor :path, :html_path, :partial_path, :layouts_path, :mockupfile, :mockupfile_path
16
+ # @attr :mode [nil, :test, :server, :release] The mode we're currently in. If nil, we aren't doing anything.
17
+ attr_accessor :path, :html_path, :partial_path, :layouts_path, :mockupfile, :mockupfile_path, :mode
17
18
 
18
19
  attr_accessor :shell
19
20
 
@@ -26,7 +27,10 @@ module Roger
26
27
  :html_path => @path + "html",
27
28
  :partial_path => @path + "partials",
28
29
  :layouts_path => @path + "layouts",
29
- :mockupfile_path => @path + "Mockupfile"
30
+ :mockupfile_path => @path + "Mockupfile",
31
+ :server => {},
32
+ :release => {},
33
+ :test => {}
30
34
  }
31
35
 
32
36
  # Clumsy string to symbol key conversion
@@ -51,18 +55,18 @@ module Roger
51
55
  @shell ||= Thor::Base.shell.new
52
56
  end
53
57
 
54
- def server
55
- options = @options[:server] || {}
58
+ def server(options = {})
59
+ options = {}.update(@options[:server]).update(options)
56
60
  @server ||= Server.new(self, options)
57
61
  end
58
62
 
59
- def release
60
- options = @options[:release] || {}
63
+ def release(options = {})
64
+ options = {}.update(@options[:release]).update(options)
61
65
  @release ||= Release.new(self, options)
62
66
  end
63
67
 
64
- def test
65
- options = @options[:test] || {}
68
+ def test(options = {})
69
+ options = {}.update(@options[:test]).update(options)
66
70
  @test ||= Test.new(self, options)
67
71
  end
68
72
 
data/lib/roger/release.rb CHANGED
@@ -10,7 +10,7 @@ module Roger
10
10
 
11
11
  attr_reader :config, :project
12
12
 
13
- attr_reader :finalizers, :injections, :stack, :cleanups
13
+ attr_reader :finalizers, :stack
14
14
 
15
15
  class << self
16
16
  include Roger::Helpers::GetCallable
@@ -30,17 +30,20 @@ module Roger
30
30
  # @option config [String, Pathname]:build_path Temporary path used to build the release
31
31
  # @option config [Boolean] :cleanup_build Wether or not to remove the build_path after we're done (default = true)
32
32
  # @option config [Array,String, nil] :cp CP command to use; Array will be escaped with Shellwords. Pass nil to get native Ruby CP. (default = ["cp", "-RL"])
33
+ # @option config [Boolean] :blank Keeps the release clean, don't automatically add any processors or finalizers (default = false)
33
34
  def initialize(project, config = {})
34
35
  defaults = {
35
36
  :scm => :git,
36
- :source_path => Pathname.new(Dir.pwd) + "html",
37
- :target_path => Pathname.new(Dir.pwd) + "releases",
38
- :build_path => Pathname.new(Dir.pwd) + "build",
37
+ :source_path => project.path + "html",
38
+ :target_path => project.path + "releases",
39
+ :build_path => project.path + "build",
39
40
  :cp => ["cp", "-RL"],
41
+ :blank => false,
40
42
  :cleanup_build => true
41
43
  }
42
44
 
43
45
  @config = {}.update(defaults).update(config)
46
+
44
47
  @project = project
45
48
  @stack = []
46
49
  @finalizers = []
@@ -174,6 +177,8 @@ module Roger
174
177
 
175
178
  # Actually perform the release
176
179
  def run!
180
+ project.mode = :release
181
+
177
182
  # Validate paths
178
183
  validate_paths!
179
184
 
@@ -190,7 +195,8 @@ module Roger
190
195
 
191
196
  # Cleanup
192
197
  cleanup! if self.config[:cleanup_build]
193
-
198
+ ensure
199
+ project.mode = nil
194
200
  end
195
201
 
196
202
 
@@ -227,7 +233,9 @@ module Roger
227
233
 
228
234
  # Checks if deprecated extractor options have been set
229
235
  # Checks if the mockup will be runned
236
+ # If config[:blank] is true it will automatically add UrlRelativizer or Mockup processor
230
237
  def validate_stack!
238
+ return if config[:blank]
231
239
 
232
240
  mockup_options = {}
233
241
  relativizer_options = {}
@@ -252,7 +260,7 @@ module Roger
252
260
 
253
261
  if self.config[:cp]
254
262
  command = [self.config[:cp]].flatten
255
- system(Shellwords.join(command + ["#{self.source_path}/", self.build_path]))
263
+ system(Shellwords.join(command + ["#{self.source_path}/", self.build_path.to_s]))
256
264
  else
257
265
  cp_r(self.source_path.children, self.build_path)
258
266
  end
@@ -271,8 +279,12 @@ module Roger
271
279
  end
272
280
  end
273
281
 
282
+ # Will run all finalizers, if no finalizers are set it will take the
283
+ # default finalizers.
284
+ #
285
+ # If config[:blank] is true, it will not use the default finalizers
274
286
  def run_finalizers!
275
- @finalizers = self.class.default_finalizers.dup if @finalizers.empty?
287
+ @finalizers = self.class.default_finalizers.dup if @finalizers.empty? && !config[:blank]
276
288
 
277
289
  # call all objects in @finalizes
278
290
  @finalizers.each do |finalizer|
data/lib/roger/server.rb CHANGED
@@ -52,6 +52,7 @@ module Roger
52
52
  end
53
53
 
54
54
  def run!
55
+ project.mode = :server
55
56
  self.handler.run self.application, self.server_options do |server|
56
57
  trap(:INT) do
57
58
  ## Use thins' hard #stop! if available, otherwise just #stop
@@ -59,6 +60,8 @@ module Roger
59
60
  puts "Roger, out!"
60
61
  end
61
62
  end
63
+ ensure
64
+ project.mode = nil
62
65
  end
63
66
  alias :run :run!
64
67
 
data/lib/roger/test.rb CHANGED
@@ -52,24 +52,28 @@ module Roger
52
52
 
53
53
  def initialize(project, config = {})
54
54
  defaults = {}
55
-
55
+
56
56
  @config = {}.update(defaults).update(config)
57
57
  @project = project
58
58
  @stack = []
59
- end
59
+ end
60
60
 
61
- # Use a certain test, this will also register it on the CLI
61
+ # Use a certain test, this will also register it on the CLI if you supply a symbol.
62
62
  #
63
63
  # @examples
64
64
  # test.use :jshint, config
65
65
  def use(processor, options = {})
66
66
  test = self.class.get_callable(processor, Roger::Test.map)
67
- self.register_in_cli(processor, @stack.size, self.class.cli_map[processor])
67
+ if processor.is_a?(Symbol)
68
+ self.register_in_cli(processor, @stack.size, self.class.cli_map[processor])
69
+ end
68
70
  @stack << [test, options]
69
71
  end
70
72
 
71
73
  # Run all tests and return true when succeeded
72
74
  def run!
75
+ project.mode = :test
76
+
73
77
  success = true
74
78
  @stack.each do |task|
75
79
  ret = call_test(task) # Don't put this on one line, you will fail... :)
@@ -77,13 +81,15 @@ module Roger
77
81
  end
78
82
 
79
83
  success
84
+ ensure
85
+ project.mode = nil
80
86
  end
81
87
 
82
88
  # Run a specific test by stack index.
83
89
  def run_test!(index)
84
90
  test = @stack[index]
85
91
  if test
86
- call_test(test)
92
+ call_test(test)
87
93
  else
88
94
  false
89
95
  end
@@ -119,7 +125,7 @@ module Roger
119
125
  def register_in_cli(name, stack_index, klass)
120
126
  long_desc = "Run #{name} tests"
121
127
 
122
- if klass && klass.kind_of?(Class) && klass <= Roger::Test::Cli
128
+ if klass && klass.kind_of?(Class) && klass <= Roger::Test::Cli
123
129
  usage = "#{name} #{klass.arguments.map{ |arg| arg.banner }.join(" ")}"
124
130
  thor_class = klass
125
131
  else
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 = "1.0.1"
5
+ s.version = "1.1.0"
6
6
 
7
7
  s.authors = ["Flurin Egger", "Edwin van der Graaf", "Joran Kapteijns"]
8
8
  s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
@@ -5,6 +5,34 @@ require "test/unit"
5
5
  module Roger
6
6
  class ReleaseTest < ::Test::Unit::TestCase
7
7
 
8
+ def setup
9
+ @project = Project.new(File.dirname(__FILE__) + "/../project", :mockupfile_path => false)
10
+ @mockupfile = Roger::Mockupfile.new(@project)
11
+ end
12
+
13
+
14
+ def test_run_should_set_project_mode
15
+ assert_equal @project.mode, nil
16
+
17
+ # Running a blank release
18
+ @mockupfile.release(:blank => true) do |r|
19
+ r.use Proc.new{|release|
20
+ assert_equal release.project.mode, :release
21
+ }
22
+ end
23
+
24
+ @project.release.run!
25
+ assert_equal @project.mode, nil
26
+ end
27
+
28
+ def test_blank_release_should_have_no_processors_and_finalizers
29
+ @mockupfile.release(:blank => true)
30
+ @project.release.run!
31
+
32
+ assert @project.release.stack.empty?
33
+ assert @project.release.finalizers.empty?
34
+ end
35
+
8
36
  def test_get_callable
9
37
  p = lambda{}
10
38
  assert_equal Release.get_callable(p, {}), p
@@ -9,6 +9,22 @@ module Roger
9
9
  @files = ["html/javascripts/site.js",
10
10
  "html/vendor/underscore/underscore.js"]
11
11
  @globs = stub(map: @files)
12
+
13
+ @project = Project.new(File.dirname(__FILE__) + "/../project", :mockupfile_path => false)
14
+ @mockupfile = Roger::Mockupfile.new(@project)
15
+ end
16
+
17
+ def test_test_run_should_set_project_mode
18
+ assert_equal @project.mode, nil
19
+
20
+ @mockupfile.test do |t|
21
+ t.use Proc.new{|test|
22
+ assert_equal test.project.mode, :test
23
+ }
24
+ end
25
+
26
+ @project.test.run!
27
+ assert_equal @project.mode, nil
12
28
  end
13
29
 
14
30
  def test_get_files
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.0.1
4
+ version: 1.1.0
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: 2015-05-18 00:00:00.000000000 Z
13
+ date: 2015-05-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor