roger 0.12.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2JmMWYxYzdhOWI1YjhiMzU4MmI2YjJhYWYyN2JhZmNmZmMyYjZjZA==
4
+ NTVmODQzZjA1Nzg0OGZmZWIzYmEwNDA4MGVlMjgxZWUzMjI5Njg2Yw==
5
5
  data.tar.gz: !binary |-
6
- NDBkZDVmMmEzNzNhZDUyODk2Njg0MGJhYzcwZDA0NzE3YTQ0MWFlNg==
6
+ ZWM0NjJiYjYzYzNmZWFmODdmMDM0MmM5ZmQxMmY1MjgyZDBjZGNkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjZlNjYxNTU4OTA4NDdkNTM1MjJkZWQ2MmY0YTVmMjUzY2Q0M2NkZWQ3MDIw
10
- YTUxNzRlMTMyNzFmZmJmMmJiNTM4NGI0NmJjZjhmZTE5OWY4N2M0NDBhYzNk
11
- NzU2MTM4ZGJkOThhNDdiYTZkYjQ1Y2FlODQ5M2U2MmJmNmM1MzQ=
9
+ NDdmYTEzNDRlMWY3ZmQwNjU1NjcxYzY3NTJlZDk4M2QwNjUwMzE3MTE0MmJj
10
+ MzMxZTQxOTBhYTI1ZmVkNzQ4YmFlZjAyZDY0OGIzODkyMDBmYmMwZjMyMGQ3
11
+ ODQ1ZTdiYjliZjczMjEwYmQ4NTlkMTlkNzg4YTcwNWE0ZjllODE=
12
12
  data.tar.gz: !binary |-
13
- MmMxOTY1NDFlMjMzYWViOTcyYTE2ODM1M2E2MjBiZWNkMDY5N2JkY2Q2MjZj
14
- N2JmMGI5ZmI0MWVjZDg0YzVlMTk2ZTI4ZDhhMmVhZjY2Njc4ZmY1MDNiNjQ0
15
- MDM0NGZhMzBkZmI1MTJlZjQwNmJlNDI5N2ViNzI2ZTBlNzY0ODM=
13
+ YTVhYzQyMTg0MzkxM2JmNmU0ZTQ3YjlmYTBkNzUyNGJjZjk0MmVhZDExNmI4
14
+ MjRhOWJjNWRhMmY2OTg0ODIwODhjYjQyMTQyYTQ5ZDdmNWRiMDAzZGYxMzEw
15
+ ZTIzMWMzOWE5YjA4YzE1OGE3NjRmMGRkYzgzMTYxNzQ1NTZlMjA=
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.13.0
4
+ *Attention* This is the last call version before 1.0.0 (5 years in sub 1.0.0 is more than enough)
5
+
6
+ There should be no breaking changes between 0.12.5 and 0.13.0
7
+
8
+ * Added `test` command infrastructure inlcuding tests
9
+ * Remove W3C Validator, it is now available as a separate gem (`roger_w3cvalidator`)
10
+ * Minor internal refactorings and library updates (mainly Thor and Test-Unit)
11
+
3
12
  ## Version 0.12.5
4
13
  * Fix github pages finalizer to work if the Dir finalizer is loaded as well
5
14
  * Run relativizer as the last thing before you finalize as to fix resolving issues with generated files
@@ -15,7 +15,6 @@ include FileUtils
15
15
 
16
16
  require File.dirname(__FILE__) + "/template"
17
17
  require File.dirname(__FILE__) + "/project"
18
- require File.dirname(__FILE__) + "/w3c_validator"
19
18
 
20
19
 
21
20
  module Roger
@@ -26,8 +25,10 @@ require File.dirname(__FILE__) + "/cli/command"
26
25
  require File.dirname(__FILE__) + "/cli/serve"
27
26
  require File.dirname(__FILE__) + "/cli/release"
28
27
  require File.dirname(__FILE__) + "/cli/generate"
28
+ require File.dirname(__FILE__) + "/cli/test"
29
29
 
30
30
  require File.dirname(__FILE__) + "/generators"
31
+ require File.dirname(__FILE__) + "/test"
31
32
 
32
33
 
33
34
  module Roger
@@ -35,11 +36,15 @@ module Roger
35
36
 
36
37
  def initialize(*args)
37
38
  super
38
- self.class.project = initialize_project
39
+ self.class.project ||= initialize_project
39
40
  end
40
41
 
41
42
  class << self
42
43
  attr_accessor :project
44
+
45
+ def exit_on_failure?
46
+ true
47
+ end
43
48
  end
44
49
 
45
50
  class_option :path,
@@ -57,7 +62,11 @@ module Roger
57
62
  :desc => 'Defaults to [directory]/partials',
58
63
  :type => :string
59
64
 
60
- register Cli::Generate, "generate", "generate [COMMAND]", "Run a generator"
65
+ desc "test [COMMAND]", "Run one or more tests. Test can be 'all' for all defined tests or a specific test name"
66
+ subcommand "test", Cli::Test
67
+
68
+ desc "generate [COMMAND]", "Run a generator"
69
+ subcommand "generate", Cli::Generate
61
70
 
62
71
  register Cli::Serve, "serve", "serve #{Cli::Serve.arguments.map{ |arg| arg.banner }.join(" ")}", Cli::Serve.desc
63
72
  self.tasks["serve"].options = Cli::Serve.class_options
@@ -65,36 +74,6 @@ module Roger
65
74
  register Cli::Release, "release", "release #{Cli::Release.arguments.map{ |arg| arg.banner }.join(" ")}", Cli::Release.desc
66
75
  self.tasks["release"].options = Cli::Release.class_options
67
76
 
68
- desc "validate [directory/file]", "Validates the file or all HTML in directory"
69
- method_options :show_valid => :boolean, # Also print a line for each valid file
70
- :filter => :string # What files should be found, defaults to [^_]*.html
71
- def validate(path=".")
72
- filter = options["filter"] || "[^_]*.html"
73
-
74
- puts "Filtering on #{options["filter"]}" if options["filter"]
75
-
76
- if File.directory?(path)
77
- any_invalid = false
78
-
79
- if (files = Dir.glob("#{path}/**/#{filter}")).any?
80
- files.each do |file|
81
- if !self.w3cvalidate(file)
82
- any_invalid = true
83
- end
84
- end
85
- if !any_invalid
86
- puts "All files were considered valid"
87
- end
88
- else
89
- puts "No files matched \"#{filter}\""
90
- end
91
- elsif File.readable?(path)
92
- self.w3cvalidate(path)
93
- else
94
- puts "No such file/directory #{path}"
95
- end
96
- end
97
-
98
77
  protected
99
78
 
100
79
  # TODO: handle options
@@ -106,17 +85,6 @@ module Roger
106
85
 
107
86
  Project.new(options[:path], {:shell => self.shell}.update(options))
108
87
  end
109
-
110
-
111
- def w3cvalidate(file)
112
- validator = W3CValidator.new(File.read(file))
113
- validator.validate!
114
- if !options["show_valid"] && !validator.valid || options["show_valid"]
115
- print "- #{file} "
116
- print "(errors: #{validator.errors}, warnings: #{validator.warnings})\n"
117
- end
118
- validator.valid
119
- end
120
88
 
121
89
  end
122
90
 
@@ -1,13 +1,17 @@
1
1
  module Roger
2
2
 
3
3
  class Cli::Command < Thor::Group
4
-
4
+ def self.exit_on_failure?
5
+ true
6
+ end
7
+
5
8
  class_option :verbose,
6
9
  :desc => "Set's verbose output",
7
10
  :aliases => ["-v"],
8
11
  :default => false,
9
12
  :type => :boolean
10
13
 
14
+
11
15
  def initialize_project
12
16
  @project = Cli::Base.project
13
17
  end
@@ -1,5 +1,7 @@
1
1
  module Roger
2
2
  class Cli::Generate < Thor
3
-
3
+ def self.exit_on_failure?
4
+ true
5
+ end
4
6
  end
5
7
  end
@@ -0,0 +1,16 @@
1
+ module Roger
2
+ class Cli::Test < Thor
3
+ def self.exit_on_failure?
4
+ true
5
+ end
6
+
7
+ default_task :all
8
+
9
+ desc "all", "Run all tests defined in Mockupfile. (this is the default action)"
10
+ def all
11
+ unless Cli::Base.project.test.run!
12
+ raise Thor::Error, "Test failed"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ module Roger
2
+ module Helpers
3
+ module GetCallable
4
+ # Makes callable into a object that responds to call.
5
+ #
6
+ # @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)
7
+ # @param [Hash] map, Mapping to match symbol to a callable
8
+ def get_callable(callable, map)
9
+ return callable if callable.respond_to?(:call)
10
+
11
+ if callable.kind_of?(Symbol) && map.has_key?(callable)
12
+ callable = map[callable]
13
+ end
14
+
15
+ if callable.kind_of?(Class)
16
+ callable = callable.new
17
+ end
18
+
19
+ if callable.respond_to?(:call)
20
+ callable
21
+ else
22
+ 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."
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module Roger
2
+ module Helpers
3
+ module Logging
4
+ # Write out a log message
5
+ def log(part, msg, verbose = false, &block)
6
+ if !verbose || verbose && self.project.options[:verbose]
7
+ self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
8
+ end
9
+ if block_given?
10
+ begin
11
+ self.project.shell.padding = self.project.shell.padding + 1
12
+ yield
13
+ ensure
14
+ self.project.shell.padding = self.project.shell.padding - 1
15
+ end
16
+ end
17
+ end
18
+
19
+ def debug(part, msg, &block)
20
+ self.log(part, msg, true, &block)
21
+ end
22
+
23
+ # Write out a warning message
24
+ def warn(part, msg)
25
+ self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + "\033[31m#{msg.to_s}\033[0m", nil, true
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -23,9 +23,9 @@ module Roger
23
23
  # @attr :path [Pathname] The path of the Mockupfile for this project
24
24
  attr_accessor :path, :project
25
25
 
26
- def initialize(project)
26
+ def initialize(project, path = nil)
27
27
  @project = project
28
- @path = Pathname.new(project.path + "Mockupfile")
28
+ @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Mockupfile")
29
29
  end
30
30
 
31
31
  # Actually load the mockupfile
@@ -56,8 +56,15 @@ module Roger
56
56
  end
57
57
  self.project.server
58
58
  end
59
-
59
+
60
60
  alias :server :serve
61
+
62
+ def test
63
+ if block_given?
64
+ yield(self.project.test)
65
+ end
66
+ self.project.test
67
+ end
61
68
 
62
69
  end
63
70
  end
@@ -1,5 +1,7 @@
1
1
  require File.dirname(__FILE__) + "/release"
2
2
  require File.dirname(__FILE__) + "/server"
3
+ require File.dirname(__FILE__) + "/test"
4
+
3
5
  require File.dirname(__FILE__) + "/mockupfile"
4
6
 
5
7
  module Roger
@@ -10,7 +12,8 @@ module Roger
10
12
  # @attr :html_path [Pathname] The path of the HTML mockup
11
13
  # @attr :partial_path [Pathname] The path for the partials for this mockup
12
14
  # @attr :mockupfile [Mockupfile] The Mockupfile for this project
13
- attr_accessor :path, :html_path, :partial_path, :layouts_path, :mockupfile
15
+ # @attr :mockupfile_path [Pathname] The path to the Mockupfile
16
+ attr_accessor :path, :html_path, :partial_path, :layouts_path, :mockupfile, :mockupfile_path
14
17
 
15
18
  attr_accessor :shell
16
19
 
@@ -22,7 +25,8 @@ module Roger
22
25
  @options = {
23
26
  :html_path => @path + "html",
24
27
  :partial_path => @path + "partials",
25
- :layouts_path => @path + "layouts"
28
+ :layouts_path => @path + "layouts",
29
+ :mockupfile_path => @path + "Mockupfile"
26
30
  }
27
31
 
28
32
  # Clumsy string to symbol key conversion
@@ -31,9 +35,16 @@ module Roger
31
35
  self.html_path = @options[:html_path]
32
36
  self.partial_path = @options[:partials_path] || @options[:partial_path] || self.html_path + "../partials/"
33
37
  self.layouts_path = @options[:layouts_path]
38
+ self.mockupfile_path = @options[:mockupfile_path]
34
39
  self.shell = @options[:shell]
35
40
 
36
- load_mockup!
41
+ if self.mockupfile_path
42
+ @mockupfile = Mockupfile.new(self, self.mockupfile_path)
43
+ @mockupfile.load
44
+ else
45
+ @mockupfile = Mockupfile.new(self)
46
+ end
47
+
37
48
  end
38
49
 
39
50
  def shell
@@ -49,6 +60,11 @@ module Roger
49
60
  options = @options[:release] || {}
50
61
  @release ||= Release.new(self, options)
51
62
  end
63
+
64
+ def test
65
+ options = @options[:test] || {}
66
+ @test ||= Test.new(self, options)
67
+ end
52
68
 
53
69
  def html_path=(p)
54
70
  @html_path = self.realpath_or_path(p)
@@ -66,11 +82,6 @@ module Roger
66
82
 
67
83
  protected
68
84
 
69
- def load_mockup!
70
- @mockupfile = Mockupfile.new(self)
71
- @mockupfile.load
72
- end
73
-
74
85
  def single_or_multiple_paths(p)
75
86
  if p.kind_of?(Array)
76
87
  p.map{|tp| self.realpath_or_path(tp) }
@@ -1,14 +1,18 @@
1
1
  require File.dirname(__FILE__) + "/cli"
2
+ require File.dirname(__FILE__) + "/helpers/get_callable"
3
+ require File.dirname(__FILE__) + "/helpers/logging"
2
4
 
3
5
  module Roger
4
6
  class Release
7
+ include Roger::Helpers::Logging
5
8
 
6
9
  attr_reader :config, :project
7
10
 
8
11
  attr_reader :finalizers, :injections, :stack, :cleanups
9
12
 
10
13
  class << self
11
-
14
+ include Roger::Helpers::GetCallable
15
+
12
16
  def default_stack
13
17
  []
14
18
  end
@@ -17,28 +21,6 @@ module Roger
17
21
  [[self.get_callable(:dir, Roger::Release::Finalizers.map), {}]]
18
22
  end
19
23
 
20
- # Makes callable into a object that responds to call.
21
- #
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
- # @param [Hash] map, Mapping to match symbol to a callable
24
- def get_callable(callable, map)
25
- return callable if callable.respond_to?(:call)
26
-
27
- if callable.kind_of?(Symbol) && map.has_key?(callable)
28
- callable = map[callable]
29
- end
30
-
31
- if callable.kind_of?(Class)
32
- callable = callable.new
33
- end
34
-
35
- if callable.respond_to?(:call)
36
- callable
37
- else
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
- end
40
-
41
- end
42
24
  end
43
25
 
44
26
  # @option config [Symbol] :scm The SCM to use (default = :git)
@@ -204,34 +186,10 @@ module Roger
204
186
 
205
187
  # Cleanup
206
188
  cleanup! if self.config[:cleanup_build]
207
-
208
- end
209
-
210
- # Write out a log message
211
- def log(part, msg, verbose = false, &block)
212
- if !verbose || verbose && self.project.options[:verbose]
213
- self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + msg.to_s, nil, true
214
- end
215
- if block_given?
216
- begin
217
- self.project.shell.padding = self.project.shell.padding + 1
218
- yield
219
- ensure
220
- self.project.shell.padding = self.project.shell.padding - 1
221
- end
222
- end
223
- end
224
-
225
- def debug(part, msg, &block)
226
- self.log(part, msg, true, &block)
227
- end
228
-
229
- # Write out a warning message
230
- def warn(part, msg)
231
- self.project.shell.say "\033[37m#{part.class.to_s}\033[0m" + " : " + "\033[31m#{msg.to_s}\033[0m", nil, true
232
- end
233
-
234
-
189
+
190
+ end
191
+
192
+
235
193
  # @param [Array] globs an array of file path globs that will be globbed against the build_path
236
194
  # @param [Array] excludes an array of regexps that will be excluded from the result
237
195
  def get_files(globs, excludes = [])
@@ -43,9 +43,7 @@ module Roger::Release::Finalizers
43
43
 
44
44
  local_path += "/" unless local_path =~ /\/\Z/
45
45
  remote_path += "/" unless remote_path =~ /\/\Z/
46
-
47
- self.add_htaccess(release, options) if options[:htaccess]
48
-
46
+
49
47
  release.log(self, "Starting upload of #{(release.build_path + "*")} to #{options[:host]}")
50
48
 
51
49
  command = "#{options[:rsync]} -az #{Shellwords.escape(local_path)} #{Shellwords.escape(options[:username])}@#{Shellwords.escape(options[:host])}:#{Shellwords.escape(remote_path)}"
@@ -61,24 +59,6 @@ module Roger::Release::Finalizers
61
59
  end
62
60
 
63
61
  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
82
62
 
83
63
  def validate_options!(release, options)
84
64
  must_have_keys = [:remote_path, :host, :username]
@@ -96,38 +76,4 @@ module Roger::Release::Finalizers
96
76
  end
97
77
  end
98
78
 
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
-
79
+ Roger::Release::Finalizers.register(:rsync, Roger::Release::Finalizers::Rsync)