ruote-kit 2.1.4.1 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +1 -2
  2. data/Gemfile +10 -1
  3. data/README.rdoc +53 -10
  4. data/Rakefile +17 -5
  5. data/config.ru +15 -1
  6. data/lib/ruote-kit/application.rb +10 -5
  7. data/lib/ruote-kit/configuration.rb +34 -3
  8. data/lib/ruote-kit/helpers/engine_helpers.rb +3 -3
  9. data/lib/ruote-kit/helpers/render_helpers.rb +10 -1
  10. data/lib/ruote-kit/resources/processes.rb +10 -4
  11. data/lib/ruote-kit/resources/workitems.rb +6 -4
  12. data/lib/ruote-kit/spec/ruote_helpers.rb +3 -3
  13. data/lib/ruote-kit/version.rb +11 -0
  14. data/lib/ruote-kit/views/expression.html.haml +1 -1
  15. data/lib/ruote-kit/views/expressions.html.haml +1 -1
  16. data/lib/ruote-kit/views/process.html.haml +1 -1
  17. data/lib/ruote-kit/views/process_failed_to_launch.html.haml +7 -0
  18. data/lib/ruote-kit/views/process_launched.html.haml +6 -0
  19. data/lib/ruote-kit.rb +21 -9
  20. data/ruote-kit.gemspec +32 -27
  21. data/spec/helpers/render_helpers_spec.rb +5 -2
  22. data/spec/resources/expressions_spec.rb +8 -4
  23. data/spec/resources/index_spec.rb +4 -2
  24. data/spec/resources/processes_spec.rb +37 -11
  25. data/spec/resources/workitems_spec.rb +12 -5
  26. data/spec/ruote-kit_configure_spec.rb +100 -0
  27. data/spec/spec_helper.rb +15 -9
  28. data/spec/views/expressions.html.haml_spec.rb +31 -0
  29. data/spec/views/launch_process.html.haml_spec.rb +2 -1
  30. data/spec/views/process.html.haml_spec.rb +2 -1
  31. data/spec/views/process_launched.html.haml_spec.rb +16 -0
  32. data/spec/views/processes.html.haml_spec.rb +2 -1
  33. data/spec/views/workitems.html.haml_spec.rb +3 -2
  34. metadata +58 -25
  35. data/lib/ruote-kit/vendor/sinatra-respond_to/LICENSE +0 -21
  36. data/lib/ruote-kit/vendor/sinatra-respond_to/README.markdown +0 -102
  37. data/lib/ruote-kit/vendor/sinatra-respond_to/Rakefile +0 -30
  38. data/lib/ruote-kit/vendor/sinatra-respond_to/VERSION.yml +0 -4
  39. data/lib/ruote-kit/vendor/sinatra-respond_to/lib/sinatra/respond_to.rb +0 -206
  40. data/lib/ruote-kit/vendor/sinatra-respond_to/sinatra-respond_to.gemspec +0 -56
  41. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static folder/.keep +0 -0
  42. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static.txt +0 -1
  43. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/test_app.rb +0 -53
  44. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/unreachable_static.txt +0 -1
  45. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/layout.html.haml +0 -2
  46. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.html.haml +0 -1
  47. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.js.erb +0 -3
  48. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.xml.builder +0 -3
  49. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/extension_spec.rb +0 -403
  50. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/spec_helper.rb +0 -18
@@ -1,102 +0,0 @@
1
- ## About
2
-
3
-
4
- ## Examples
5
-
6
- require 'sinatra'
7
- require 'sinatra/respond_to'
8
-
9
- get '/posts' do
10
- @posts = Post.recent
11
-
12
- respond_to do |wants|
13
- wants.html { haml :posts } # => views/posts.html.haml, also sets content_type to text/html
14
- wants.rss { haml :posts } # => views/posts.rss.haml, also sets content_type to application/rss+xml
15
- wants.atom { haml :posts } # => views/posts.atom.haml, also sets content_type to appliation/atom+xml
16
- end
17
- end
18
-
19
- get '/post/:id' do
20
- @post = Post.find(params[:id])
21
-
22
- respond_to do |wants|
23
- wants.html { haml :post } # => views/post.html.haml, also sets content_type to text/html
24
- wants.xhtml { haml :post } # => views/post.xhtml.haml, also sets content_type to application/xhtml+xml
25
- wants.xml { @post.to_xml } # => sets content_type to application/xml
26
- wants.js { erb :post } # => views/post.js.erb, also sets content_type to application/javascript
27
- end
28
- end
29
-
30
- get '/comments/:id' do
31
- @comment = Comment.find(params[:id])
32
-
33
- respond_to do |wants|
34
- wants.html { haml :comment } # => views/comment.html.haml, also sets content_type to text/html
35
- wants.json { @comment.to_json } # => sets content_type to application/json
36
- wants.js { erb :comment } # => views/comment.js.erb, also sets content_type to application/javascript
37
- end
38
- end
39
-
40
- To change the character set of the response, there is a <tt>charset</tt> helper. For example
41
-
42
- get '/iso-8859-1' do
43
- charset 'iso-8859-1'
44
- "This is now sent using iso-8859-1 character set"
45
- end
46
-
47
- get '/respond_to-mixed' do
48
- respond_to do |wants|
49
- wants.html { charset 'iso-8859-1'; "Some html in iso-8859-1" }
50
- wants.xml { builder :utf-8-xml } # => this is returned in the default character set
51
- end
52
- end
53
-
54
- ## Configuration
55
-
56
- There a few options available for configuring the default behavior of respond_to using Sinatra's
57
- <tt>set</tt> utility.
58
-
59
- * <tt>default\_charset - utf-8</tt><br />
60
- Assumes all text documents are encoded using this character set.
61
- This can be overridden within the respond_to block for the appropriate format
62
- * <tt>default\_content - :html</tt><br />
63
- When a user vists a url without an extension, for example /post this will be
64
- the assumed content to serve first. Expects a symbol as used in setting content_type.
65
- * <tt>assume\_xhr\_is\_js - true</tt><br />
66
- To avoid headaches with accept headers, and appending .js to urls, this will
67
- cause the default format for all XmlHttpRequests to be classified as wanting Javascript
68
- in the response.
69
-
70
- ## Installing
71
- sudo gem install cehoffman-sinatra-respond_to --source=http://gems.github.com
72
-
73
- ## Cavaets
74
- Due to the way respond\_to works, all incoming requests have the extension striped from the request.path\_info.
75
- This causes routes like the following to fail.
76
-
77
- get '/style.css' do
78
- content_type :css, :charset => 'utf-8'
79
- sass :style # => renders views/style.sass
80
- end
81
-
82
- They need to be changed to the following. Note that you no longer have to set the content\_type or charset.
83
-
84
- get '/style' do
85
- sass :style # => renders views/style.css.sass
86
- end
87
-
88
- If you want to ensure the route only gets called for css requests try this. This will use sinatra's built in accept header matching.
89
-
90
- get '/style', :provides => :css do
91
- sass :style
92
- end
93
-
94
- ## Issues
95
-
96
- Sinatra has a bug that affects Classic style applications and extensions see [#215][215] and [#180][180].
97
- I have worked around this by explicitly registering RespondTo with the top level Sinatra::Application when
98
- requiring sinatra/respond\_to.
99
-
100
- [215]: https://sinatra.lighthouseapp.com/projects/9779/tickets/215-extensions-cannot-define-before-filters-for-classic-apps "Extensions cannot define before filters for classic apps"
101
- [180]: https://sinatra.lighthouseapp.com/projects/9779/tickets/180-better-route-inheritence "Better route inheritence"
102
-
@@ -1,30 +0,0 @@
1
- begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |spec|
4
- spec.name = 'sinatra-respond_to'
5
- spec.summary = 'A respond_to style Rails block for baked-in web service support in Sinatra'
6
- spec.email = 'cehoffman@gmail.com'
7
- spec.homepage = 'http://github.com/cehoffman/sinatra-respond_to'
8
- spec.description = spec.summary
9
- spec.authors = ["Chris Hoffman"]
10
- spec.add_dependency('sinatra-sinatra', '>= 0.9.1.3')
11
- end
12
- rescue LoadError
13
- puts "Jewler not available. Install it with sugo gem install technicalpickles-jeweler -s http://gems.github.com"
14
- end
15
-
16
- begin
17
- require 'spec/rake/spectask'
18
- desc "Run specs"
19
- Spec::Rake::SpecTask.new do |t|
20
- t.spec_files = FileList['spec/*_spec.rb']
21
- t.spec_opts = %w(-fp --color)
22
-
23
- t.rcov = true
24
- t.rcov_opts << '--text-summary'
25
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
26
- t.rcov_opts << '--exclude' << '.gem,pkg,spec'
27
- end
28
- rescue LoadError
29
- puts "RSpec not available. Install it with sudo gem install rspec."
30
- end
@@ -1,4 +0,0 @@
1
- ---
2
- :patch: 6
3
- :major: 0
4
- :minor: 3
@@ -1,206 +0,0 @@
1
- require 'sinatra/base'
2
-
3
- # Accept header parsing was looked at but deemed
4
- # too much of an irregularity to deal with. Problems with the header
5
- # differences from IE, Firefox, Safari, and every other UA causes
6
- # problems with the expected output. The general expected behavior
7
- # would be serve html when no extension provided, but most UAs say
8
- # they will accept application/xml with out a quality indicator, meaning
9
- # you'd get the xml block served insead. Just plain retarded, use the
10
- # extension and you'll never be suprised.
11
-
12
- module Sinatra
13
- module RespondTo
14
- class UnhandledFormat < Sinatra::NotFound; end
15
- class MissingTemplate < Sinatra::NotFound
16
- def code; 500 end
17
- end
18
-
19
- TEXT_MIME_TYPES = [:txt, :html, :js, :json, :xml, :rss, :atom, :css, :asm, :c, :cc, :conf,
20
- :csv, :cxx, :diff, :dtd, :f, :f77, :f90, :for, :gemspec, :h, :hh, :htm,
21
- :log, :mathml, :mml, :p, :pas, :pl, :pm, :py, :rake, :rb, :rdf, :rtf, :ru,
22
- :s, :sgm, :sgml, :sh, :svg, :svgz, :text, :wsdl, :xhtml, :xsl, :xslt, :yaml,
23
- :yml, :ics]
24
-
25
- def self.registered(app)
26
- app.helpers RespondTo::Helpers
27
-
28
- app.set :default_charset, 'utf-8'
29
- app.set :default_content, :html
30
- app.set :assume_xhr_is_js, true
31
-
32
- # We remove the trailing extension so routes
33
- # don't have to be of the style
34
- #
35
- # get '/resouce.:format'
36
- #
37
- # They can instead be of the style
38
- #
39
- # get '/resource'
40
- #
41
- # and the format will automatically be available in <tt>format</tt>
42
- app.before do
43
- unless options.static? && options.public? && (request.get? || request.head?) && static_file?(request.path_info)
44
- request.path_info.sub! %r{\.([^\./]+)$}, ''
45
-
46
- format request.xhr? && options.assume_xhr_is_js? ? :js : $1 || options.default_content
47
-
48
- charset options.default_charset if Sinatra::RespondTo::TEXT_MIME_TYPES.include? format
49
- end
50
- end
51
-
52
- app.configure :development do |dev|
53
- # Very, very, very hackish but only for development at least
54
- # Modifies the regex matching /__sinatra__/:image.png to not have the extension
55
- ["GET", "HEAD"].each do |verb|
56
- dev.routes[verb][1][0] = Regexp.new(dev.routes[verb][1][0].source.gsub(/\\\.[^\.\/]+\$$/, '$'))
57
- end
58
-
59
- dev.error UnhandledFormat do
60
- content_type :html, :charset => 'utf-8'
61
-
62
- (<<-HTML).gsub(/^ {10}/, '')
63
- <!DOCTYPE html>
64
- <html>
65
- <head>
66
- <style type="text/css">
67
- body { text-align:center;font-family:helvetica,arial;font-size:22px;
68
- color:#888;margin:20px}
69
- #c {margin:0 auto;width:500px;text-align:left}
70
- </style>
71
- </head>
72
- <body>
73
- <h2>Sinatra doesn't know this ditty.</h2>
74
- <img src='/__sinatra__/404.png'>
75
- <div id="c">
76
- Try this:
77
- <pre>#{request.request_method.downcase} '#{request.path_info}' do\n respond_to do |wants|\n wants.#{format} { "Hello World" }\n end\nend</pre>
78
- </div>
79
- </body>
80
- </html>
81
- HTML
82
- end
83
-
84
- dev.error MissingTemplate do
85
- content_type :html, :charset => 'utf-8'
86
- response.status = request.env['sinatra.error'].code
87
-
88
- engine = request.env['sinatra.error'].message.split('.').last
89
- engine = 'haml' unless ['haml', 'builder', 'erb'].include? engine
90
-
91
- path = File.basename(request.path_info)
92
- path = "root" if path.nil? || path.empty?
93
-
94
- format = engine == 'builder' ? 'xml' : 'html'
95
-
96
- layout = case engine
97
- when 'haml' then "!!!\n%html\n %body= yield"
98
- when 'erb' then "<html>\n <body>\n <%= yield %>\n </body>\n</html>"
99
- when 'builder' then "builder do |xml|\n xml << yield\nend"
100
- end
101
-
102
- layout = "<small>app.#{format}.#{engine}</small>\n<pre>#{escape_html(layout)}</pre>"
103
-
104
- (<<-HTML).gsub(/^ {10}/, '')
105
- <!DOCTYPE html>
106
- <html>
107
- <head>
108
- <style type="text/css">
109
- body { text-align:center;font-family:helvetica,arial;font-size:22px;
110
- color:#888;margin:20px}
111
- #c {margin:0 auto;width:500px;text-align:left;}
112
- small {float:right;clear:both;}
113
- pre {clear:both;}
114
- </style>
115
- </head>
116
- <body>
117
- <h2>Sinatra can't find #{request.env['sinatra.error'].message}</h2>
118
- <img src='/__sinatra__/500.png'>
119
- <div id="c">
120
- Try this:<br />
121
- #{layout}
122
- <small>#{path}.#{format}.#{engine}</small>
123
- <pre>Hello World!</pre>
124
- <small>application.rb</small>
125
- <pre>#{request.request_method.downcase} '#{request.path_info}' do\n respond_to do |wants|\n wants.#{engine == 'builder' ? 'xml' : 'html'} { #{engine} :#{path}#{",\n#{' '*32}layout => :app" if layout} }\n end\nend</pre>
126
- </div>
127
- </body>
128
- </html>
129
- HTML
130
- end
131
-
132
- end
133
-
134
- app.class_eval do
135
- private
136
- def render_with_format(*args)
137
- args[1] = "#{args[1]}.#{format}".to_sym if args[1].is_a?(::Symbol)
138
- render_without_format *args
139
- rescue Errno::ENOENT
140
- raise MissingTemplate, "#{args[1]}.#{args[0]}"
141
- end
142
- alias_method :render_without_format, :render
143
- alias_method :render, :render_with_format
144
-
145
- def lookup_layout_with_format(*args)
146
- args[1] = "#{args[1]}.#{format}".to_sym if args[1].is_a?(::Symbol)
147
- lookup_layout_without_format *args
148
- end
149
- alias_method :lookup_layout_without_format, :lookup_layout
150
- alias_method :lookup_layout, :lookup_layout_with_format
151
- end
152
- end
153
-
154
- module Helpers
155
- def format(val=nil)
156
- unless val.nil?
157
- mime_type = media_type(val)
158
- fail "Unknown media type #{val}\nTry registering the extension with a mime type" if mime_type.nil?
159
-
160
- @format = val.to_sym
161
- response['Content-Type'].sub!(/^[^;]+/, mime_type)
162
- end
163
-
164
- @format
165
- end
166
-
167
- # This is mostly just a helper so request.path_info isn't changed when
168
- # serving files from the public directory
169
- def static_file?(path)
170
- public_dir = File.expand_path(options.public)
171
- path = File.expand_path(File.join(public_dir, unescape(path)))
172
-
173
- path[0, public_dir.length] == public_dir && File.file?(path)
174
- end
175
-
176
- def charset(val=nil)
177
- fail "Content-Type must be set in order to specify a charset" if response['Content-Type'].nil?
178
-
179
- if response['Content-Type'] =~ /charset=[^;]+/
180
- response['Content-Type'].sub!(/charset=[^;]+/, (val == '' && '') || "charset=#{val}")
181
- else
182
- response['Content-Type'] += ";charset=#{val}"
183
- end unless val.nil?
184
-
185
- response['Content-Type'][/charset=([^;]+)/, 1]
186
- end
187
-
188
- def respond_to(&block)
189
- wants = {}
190
- def wants.method_missing(type, *args, &handler)
191
- Sinatra::Base.send(:fail, "Unknown media type for respond_to: #{type}\nTry registering the extension with a mime type") if Sinatra::Base.media_type(type).nil?
192
- self[type] = handler
193
- end
194
-
195
- yield wants
196
-
197
- raise UnhandledFormat if wants[format].nil?
198
- wants[format].call
199
- end
200
- end
201
- end
202
-
203
- # Get around before filter problem for classic applications by registering
204
- # with the context they are run in explicitly instead of Sinatra::Default
205
- Sinatra::Base.register RespondTo
206
- end
@@ -1,56 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{sinatra-respond_to}
5
- s.version = "0.3.6"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Chris Hoffman"]
9
- s.date = %q{2009-08-02}
10
- s.description = %q{A respond_to style Rails block for baked-in web service support in Sinatra}
11
- s.email = %q{cehoffman@gmail.com}
12
- s.extra_rdoc_files = [
13
- "LICENSE",
14
- "README.markdown"
15
- ]
16
- s.files = [
17
- "LICENSE",
18
- "README.markdown",
19
- "Rakefile",
20
- "VERSION.yml",
21
- "lib/sinatra/respond_to.rb",
22
- "spec/app/public/static.txt",
23
- "spec/app/test_app.rb",
24
- "spec/app/unreachable_static.txt",
25
- "spec/app/views/layout.html.haml",
26
- "spec/app/views/resource.html.haml",
27
- "spec/app/views/resource.js.erb",
28
- "spec/app/views/resource.xml.builder",
29
- "spec/extension_spec.rb",
30
- "spec/spec_helper.rb"
31
- ]
32
- s.has_rdoc = true
33
- s.homepage = %q{http://github.com/cehoffman/sinatra-respond_to}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.1}
37
- s.summary = %q{A respond_to style Rails block for baked-in web service support in Sinatra}
38
- s.test_files = [
39
- "spec/app/test_app.rb",
40
- "spec/extension_spec.rb",
41
- "spec/spec_helper.rb"
42
- ]
43
-
44
- if s.respond_to? :specification_version then
45
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
- s.specification_version = 2
47
-
48
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<sinatra-sinatra>, [">= 0.9.1.3"])
50
- else
51
- s.add_dependency(%q<sinatra-sinatra>, [">= 0.9.1.3"])
52
- end
53
- else
54
- s.add_dependency(%q<sinatra-sinatra>, [">= 0.9.1.3"])
55
- end
56
- end
@@ -1,53 +0,0 @@
1
- require 'sinatra/base'
2
- require 'erb'
3
- require 'haml'
4
- require 'builder'
5
-
6
- class TestApp < Sinatra::Base
7
- register Sinatra::RespondTo
8
-
9
- set :views, File.join(File.dirname(__FILE__), 'views')
10
- set :public, File.join(File.dirname(__FILE__), 'public')
11
-
12
- get '/resource' do
13
- respond_to do |wants|
14
- wants.html { haml :resource }
15
- wants.json { "We got some json" }
16
- wants.xml { builder :resource }
17
- wants.js { erb :resource }
18
- wants.png { }
19
- end
20
- end
21
-
22
- get '/default_charset' do
23
- respond_to do |wants|
24
- wants.html { "Should set charcter set to default_charset" }
25
- end
26
- end
27
-
28
- get '/iso-8859-1' do
29
- respond_to do |wants|
30
- wants.html { charset 'iso-8859-1'; "Should have character set of iso-8859-1" }
31
- end
32
- end
33
-
34
- get '/normal-no-respond_to' do
35
- "Just some plain old text"
36
- end
37
-
38
- get '/style.css' do
39
- "This route should fail"
40
- end
41
-
42
- get '/style-no-extension', :provides => :css do
43
- "Should succeed only when browser accepts text/css"
44
- end
45
-
46
- get '/missing-template' do
47
- respond_to do |wants|
48
- wants.html { haml :missing }
49
- wants.xml { builder :missing }
50
- wants.js { erb :missing }
51
- end
52
- end
53
- end
@@ -1 +0,0 @@
1
- Unreachable static file
@@ -1,3 +0,0 @@
1
- $(function () {
2
- return '<%= "Hiya from javascript" %>'
3
- });
@@ -1,3 +0,0 @@
1
- builder do |xml|
2
- xml.root "Some XML"
3
- end