tap-server 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History +5 -0
  2. data/cmd/server.rb +36 -8
  3. data/lib/tap/controller/rest_routes.rb +77 -0
  4. data/lib/tap/controller/utils.rb +29 -0
  5. data/lib/tap/controller.rb +244 -145
  6. data/lib/tap/controllers/app.rb +97 -55
  7. data/lib/tap/controllers/data.rb +132 -0
  8. data/lib/tap/controllers/schema.rb +137 -223
  9. data/lib/tap/controllers/server.rb +70 -27
  10. data/lib/tap/server/data.rb +178 -0
  11. data/lib/tap/server/runner.rb +71 -0
  12. data/lib/tap/server/server_error.rb +35 -0
  13. data/lib/tap/server.rb +60 -275
  14. data/lib/tap/tasks/echo.rb +39 -6
  15. data/lib/tap/tasks/render.rb +65 -0
  16. data/public/stylesheets/tap.css +15 -2
  17. data/views/configurable/_config.erb +1 -0
  18. data/views/configurable/_configs.erb +28 -0
  19. data/views/configurable/_flag.erb +2 -0
  20. data/views/configurable/_list_select.erb +8 -0
  21. data/views/configurable/_select.erb +6 -0
  22. data/views/configurable/_switch.erb +2 -0
  23. data/views/layout.erb +1 -1
  24. data/views/object/obj.erb +1 -0
  25. data/views/tap/controllers/app/_action.erb +3 -0
  26. data/views/tap/controllers/app/build.erb +18 -0
  27. data/views/tap/controllers/app/enque.erb +13 -0
  28. data/views/tap/controllers/app/info.erb +20 -7
  29. data/views/tap/controllers/data/_controls.erb +21 -0
  30. data/views/tap/controllers/data/_index_entry.erb +1 -0
  31. data/views/tap/controllers/data/_upload.erb +8 -0
  32. data/views/tap/controllers/data/entry.erb +8 -0
  33. data/views/tap/controllers/data/index.erb +14 -0
  34. data/views/tap/controllers/schema/_build.erb +6 -0
  35. data/views/tap/controllers/schema/_index_entry.erb +6 -0
  36. data/views/tap/controllers/schema/entry.erb +135 -0
  37. data/views/tap/controllers/schema/join.erb +6 -4
  38. data/views/tap/controllers/schema/task.erb +6 -0
  39. data/views/tap/controllers/server/access.erb +4 -0
  40. data/views/tap/controllers/server/admin.erb +21 -0
  41. data/views/tap/controllers/server/help.erb +23 -0
  42. data/views/tap/controllers/server/index.erb +43 -3
  43. data/views/tap/task/input.erb +17 -0
  44. data/views/tap/tasks/load/input.erb +11 -0
  45. metadata +35 -17
  46. data/lib/tap/server_error.rb +0 -34
  47. data/lib/tap/support/persistence.rb +0 -71
  48. data/lib/tap/tasks/server.rb +0 -30
  49. data/views/tap/controllers/app/index.erb +0 -44
  50. data/views/tap/controllers/schema/config/default.erb +0 -4
  51. data/views/tap/controllers/schema/config/flag.erb +0 -3
  52. data/views/tap/controllers/schema/config/switch.erb +0 -6
  53. data/views/tap/controllers/schema/configurations.erb +0 -27
  54. data/views/tap/controllers/schema/node.erb +0 -47
  55. data/views/tap/controllers/schema/preview.erb +0 -3
  56. data/views/tap/controllers/schema/round.erb +0 -30
  57. data/views/tap/controllers/schema/schema.erb +0 -28
  58. data/views/tap/tasks/echo/result.html +0 -1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tap-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Chiang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-17 00:00:00 -06:00
12
+ date: 2009-05-25 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.12.3
23
+ version: 0.17.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.1
33
+ version: "1.0"
34
34
  version:
35
35
  description:
36
36
  email: simon.a.chiang@gmail.com
@@ -45,35 +45,53 @@ extra_rdoc_files:
45
45
  files:
46
46
  - cmd/server.rb
47
47
  - lib/tap/controller.rb
48
+ - lib/tap/controller/rest_routes.rb
49
+ - lib/tap/controller/utils.rb
48
50
  - lib/tap/controllers/app.rb
51
+ - lib/tap/controllers/data.rb
49
52
  - lib/tap/controllers/schema.rb
50
53
  - lib/tap/controllers/server.rb
54
+ - lib/tap/server/runner.rb
51
55
  - lib/tap/server.rb
52
- - lib/tap/server_error.rb
56
+ - lib/tap/server/data.rb
57
+ - lib/tap/server/server_error.rb
53
58
  - lib/tap/tasks/echo.rb
54
- - lib/tap/tasks/server.rb
55
- - lib/tap/support/persistence.rb
59
+ - lib/tap/tasks/render.rb
56
60
  - public/javascripts/prototype.js
57
61
  - public/javascripts/tap.js
58
62
  - public/stylesheets/tap.css
59
63
  - tap.yml
60
64
  - views/404.erb
61
65
  - views/500.erb
66
+ - views/configurable/_config.erb
67
+ - views/configurable/_configs.erb
68
+ - views/configurable/_flag.erb
69
+ - views/configurable/_list_select.erb
70
+ - views/configurable/_select.erb
71
+ - views/configurable/_switch.erb
62
72
  - views/layout.erb
63
- - views/tap/controllers/app/index.erb
73
+ - views/object/obj.erb
74
+ - views/tap/controllers/app/_action.erb
75
+ - views/tap/controllers/app/build.erb
76
+ - views/tap/controllers/app/enque.erb
64
77
  - views/tap/controllers/app/info.erb
65
78
  - views/tap/controllers/app/tail.erb
66
- - views/tap/controllers/schema/config/default.erb
67
- - views/tap/controllers/schema/config/flag.erb
68
- - views/tap/controllers/schema/config/switch.erb
69
- - views/tap/controllers/schema/configurations.erb
79
+ - views/tap/controllers/data/_controls.erb
80
+ - views/tap/controllers/data/_index_entry.erb
81
+ - views/tap/controllers/data/_upload.erb
82
+ - views/tap/controllers/data/entry.erb
83
+ - views/tap/controllers/data/index.erb
84
+ - views/tap/controllers/schema/_build.erb
85
+ - views/tap/controllers/schema/_index_entry.erb
70
86
  - views/tap/controllers/schema/join.erb
71
- - views/tap/controllers/schema/node.erb
72
- - views/tap/controllers/schema/preview.erb
73
- - views/tap/controllers/schema/round.erb
74
- - views/tap/controllers/schema/schema.erb
87
+ - views/tap/controllers/schema/entry.erb
88
+ - views/tap/controllers/schema/task.erb
89
+ - views/tap/controllers/server/access.erb
90
+ - views/tap/controllers/server/admin.erb
91
+ - views/tap/controllers/server/help.erb
75
92
  - views/tap/controllers/server/index.erb
76
- - views/tap/tasks/echo/result.html
93
+ - views/tap/task/input.erb
94
+ - views/tap/tasks/load/input.erb
77
95
  - README
78
96
  - MIT-LICENSE
79
97
  - History
@@ -1,34 +0,0 @@
1
- module Tap
2
-
3
- # A special type of error used for specifiying controller errors.
4
- class ServerError < RuntimeError
5
- class << self
6
-
7
- # A helper to format a non-ServerError into a ServerError response.
8
- def response(err)
9
- new("500 #{err.class}: #{err.message}\n#{err.backtrace.join("\n")}").response
10
- end
11
- end
12
-
13
- # The error status
14
- attr_reader :status
15
-
16
- # Headers for the error response
17
- attr_reader :headers
18
-
19
- # The error response body
20
- attr_reader :body
21
-
22
- def initialize(body="500 Server Error", status=500, headers={'Content-Type' => ['text/plain']})
23
- @body = body
24
- @status = status
25
- @headers = headers
26
- super(body)
27
- end
28
-
29
- # Formats self as a rack response array (ie [status, headers, body]).
30
- def response
31
- [status, headers, [body]]
32
- end
33
- end
34
- end
@@ -1,71 +0,0 @@
1
- module Tap
2
- module Support
3
-
4
- # A very simple wrapper for root providing a CRUD interface for reading and
5
- # writing files.
6
- class Persistence
7
-
8
- # The Tap::Root for self.
9
- attr_reader :root
10
-
11
- # Initializes a new persistence wrapper for the specified root.
12
- def initialize(root)
13
- @root = root
14
- end
15
-
16
- # Returns the filepath for the specified id. Non-string ids are allowed;
17
- # they will be converted to strings using to_s.
18
- def path(id)
19
- root.subpath(:data, id.to_s)
20
- end
21
-
22
- # Returns a list of existing ids.
23
- def index
24
- root.glob(:data).select do |path|
25
- File.file?(path)
26
- end.collect do |path|
27
- root.relative_filepath(:data, path)
28
- end
29
- end
30
-
31
- # Creates the file for the specified id. If a block is given, an io to
32
- # the file will be yielded to it; otherwise the file will be created
33
- # without content. Returns the path to the persistence file.
34
- #
35
- # Raises an error if the file already exists.
36
- def create(id)
37
- filepath = path(id)
38
- raise "already exists: #{filepath}" if File.exists?(filepath)
39
- root.prepare(filepath) {|io| yield(io) if block_given? }
40
- end
41
-
42
- # Reads and returns the data for the specified id, or an empty string if
43
- # the persistence file doesn't exist.
44
- def read(id)
45
- filepath = path(id)
46
- File.file?(filepath) ? File.read(filepath) : ''
47
- end
48
-
49
- # Overwrites the data for the specified id. A block must be given to
50
- # provide the new content; a persistence file will be created if one
51
- # does not exist already.
52
- def update(id)
53
- root.prepare(path(id)) {|io| yield(io) }
54
- end
55
-
56
- # Removes the persistence file for id, if it exists. Returns true if
57
- # the file was removed.
58
- def destroy(id)
59
- filepath = path(id)
60
-
61
- if File.file?(filepath)
62
- FileUtils.rm(filepath)
63
- true
64
- else
65
- false
66
- end
67
- end
68
-
69
- end
70
- end
71
- end
@@ -1,30 +0,0 @@
1
- require 'tap/server'
2
-
3
- module Tap
4
- module Tasks
5
-
6
- # ::manifest
7
- class Server < Tap::Task
8
-
9
- nest(:env, Tap::Env) do |config|
10
- case config
11
- when Tap::Env then config
12
- else Tap::Env.new(config)
13
- end
14
- end
15
-
16
- nest_attr(:server, Tap::Server) do |config|
17
- @server = Tap::Server.new(env, config)
18
- end
19
-
20
- def process(method='get', uri="/")
21
- uri = URI(uri[0] == ?/ ? uri : "/#{uri}")
22
- uri.host ||= server.host
23
- uri.port ||= server.port
24
-
25
- mock = Rack::MockRequest.new(server)
26
- mock.request(method, uri.to_s)
27
- end
28
- end
29
- end
30
- end
@@ -1,44 +0,0 @@
1
- <div id="branding">
2
- <h1><a href="<%= Tap::WEBSITE %>">Tap (<ins>T</ins>ask <ins>Ap</ins>plication) <%= Tap::VERSION %> </a></h1>
3
- </div>
4
-
5
- <div id="content_main">
6
- <dl id="envs" class="manifest">
7
- <% env.each do |current| %>
8
- <dt class="key"><%= env_names[current] %> (<%= current.root.root %>)</dt>
9
- <dd class="value">
10
- <% controllers = current.controllers.build %>
11
- <% unless controllers.empty? %>
12
- <dl id="controllers" class="manifest">
13
- <!-- controllers manifest -->
14
- <dt class="key">controllers</dt>
15
- <dd class="value">
16
- <ol>
17
- <% controllers.minimap.each do |(name, obj)| %>
18
- <% path = obj.kind_of?(Tap::Support::Constant) ? obj.require_path : name %>
19
- <li><a href="/<%= env_names[current] %>%3A<%= name %>"><%= name %></a> (<%= current.root.relative_filepath(:root, path) || path %>)</li>
20
- <% end %>
21
- </ol>
22
- </dd>
23
- </dl>
24
- <% end %>
25
-
26
- <% tascs = current.tasks.build %>
27
- <% unless tascs.empty? %>
28
- <dl id="tascs" class="manifest">
29
- <!-- tasks manifest -->
30
- <dt class="key">tasks</dt>
31
- <dd class="value">
32
- <ol>
33
- <% tascs.minimap.each do |(name, obj)| %>
34
- <% path = obj.kind_of?(Tap::Support::Constant) ? obj.require_path : name %>
35
- <li><a href="/schema?nodes[0][0]=<%= env_names[current] %>%3A<%= name %>"><%= name %></a> (<%= current.root.relative_filepath(:root, path) || path %>)</li>
36
- <% end %>
37
- </ol>
38
- </dd>
39
- </dl>
40
- <% end %>
41
- </dd>
42
- <% end %>
43
- </dl>
44
- </div>
@@ -1,4 +0,0 @@
1
- <input name="argv[]" type="hidden" value="<%= switch %>" />
2
- <input name="argv[]" type="text" value="<%= value %>" />
3
- <span><%= key %></span>:
4
- <span><%= config[:desc].to_s %></span>
@@ -1,3 +0,0 @@
1
- <input name="argv[]" type="checkbox" value="<%= switch %>" <%= value ? 'checked="true"' : '' %> />
2
- <span><%= key %></span>:
3
- <span><%= config[:desc].to_s %></span>
@@ -1,6 +0,0 @@
1
- <!-- note switches should be more like a radio button, hide
2
- the other when selected, so that both are allowed... or
3
- just present the opposite of the default... Currently they DO NOT WORK-->
4
- <input name="argv[]" type="checkbox" value="<%= switch %>" <%= value ? 'checked="true"' : '' %> />
5
- <span><%= key %></span>:
6
- <span><%= config[:desc].to_s %></span>
@@ -1,27 +0,0 @@
1
- <% configurations.each_pair do |key, config| %>
2
- <li class="config">
3
- <% if config.is_nest? %>
4
- <span class="name"><%= key %></span>:
5
- <span class="desc"><%= config[:desc].to_s %></span>
6
- <ul class="nested_config">
7
- <%= render("configurations.erb", :locals => {
8
- :configurations => config.default(false).delegates,
9
- :values => values[key],
10
- :nest => "#{nest}#{nest.empty? ? '' : ':'}#{key}",
11
- :index => index}) %>
12
- </ul>
13
- <% else %>
14
- <% template = case config[:type] %>
15
- <% when :switch then 'switch' %>
16
- <% when :flag then 'flag' %>
17
- <% else 'default' %>
18
- <% end %>
19
- <%= render("config/#{template}.erb", :locals => {
20
- :key => key,
21
- :config => config,
22
- :switch => "--#{nest}#{nest.empty? ? '' : ':'}#{key.to_s.gsub('_', '-')}",
23
- :value => values[key],
24
- :index => index}) %>
25
- </li>
26
- <% end %>
27
- <% end %>
@@ -1,47 +0,0 @@
1
- <% task, args = instantiate(*node.argv) %>
2
- <% tasc = task.class %>
3
- <span class="class"><%= tasc %></span>:
4
- <span class="summary"><%= tasc.manifest.subject %></span>
5
- <pre><%= tasc.manifest.wrap %></pre>
6
-
7
- <!-- tasc identifier -->
8
- <input name="argv[]" type="hidden" value="--" />
9
- <input name="argv[]" type="hidden" value="<%= node.argv[0] %>" />
10
-
11
- <ul>
12
- <!-- inputs -->
13
- <% attributes = node.input_join ? "disabled='true' ": " " %>
14
- <% tasc.args.arguments.each do |argument| %>
15
- <li class="input">
16
- <input name="argv[]" <%= attributes %>value="<%= args.shift %>" />
17
- <span><%= argument %></span>
18
- </li>
19
- <% end %>
20
- <!-- for extra args... should be limited to *arg -->
21
- <% args << '' %>
22
- <% args.each do |arg| %>
23
- <li class="input">
24
- <input name="argv[]" <%= attributes %>value="<%= arg %>" />
25
- <span>...</span>
26
- </li>
27
- <% end %>
28
-
29
- <!-- configurations -->
30
- <%= render("configurations.erb", :locals => {
31
- :configurations => tasc.configurations,
32
- :values => task.config,
33
- :nest => "",
34
- :index => index}) %>
35
-
36
- <!-- options -->
37
- <li class="options">
38
- <input name="argv[]" type="hidden" value="--name" />
39
- <input name="argv[]" value="<%= task.name %>" />
40
- <span>Name</span>
41
- </li>
42
-
43
- <!--
44
- <input class="globalize" name="nodes[<%= index %>][2]" type="checkbox" value="--*<%= index %>" />
45
- <span class="name">Globalize</span> -->
46
-
47
- </ul>
@@ -1,3 +0,0 @@
1
- # This workflow may be saved to a file and loaded
2
- # at a later time, or go back to run it now.
3
- <%= schema.dump.to_yaml %>
@@ -1,30 +0,0 @@
1
- <form id="update_<%= id %>" class="update_form" enctype="multipart/form-data" method="post" action="/schema/update/<%= id %>">
2
- <span>round <%= round %></span>
3
- <input name="round" type="hidden" value="<%= round %>">
4
- <ol>
5
- <% nodes.each do |node| %>
6
- <% index = schema.index(node) %>
7
- <li>
8
- <input name="outputs[]" value="<%= index %>" type="checkbox" />
9
- <a href="#node_<%= index %>"><%= index %></a>
10
- <input name="inputs[]" value="<%= index %>" type="checkbox" />
11
- <%= render('join.erb', :locals => {:schema => schema, :id => id, :nodes => node.parents}) %>
12
- <%= render('join.erb', :locals => {:schema => schema, :id => id, :nodes => node.children}) %>
13
- </li>
14
- <% end %>
15
- </ol>
16
- <ul>
17
- <% server.env.minimap.each do |(env_name, env)| %>
18
- <% env.tasks.build.minimap.each do |(name, const)| %>
19
- <% lookup = "#{env_name}:#{name}" %>
20
- <li>
21
- <input name="nodes[]" value="<%= lookup %>" type="checkbox"><%= lookup %></input>
22
- </li>
23
- <% end %>
24
- <% end %>
25
- </ul>
26
- <input class="update_action" type="radio" name="action" value="add" checked="true">add</input>
27
- <input class="update_action" type="radio" name="action" value="remove">remove</input>
28
- <input class="update_action" type="radio" name="action" value="echo">echo</input>
29
- <input id="update_form_submit" type="submit" value="Update" />
30
- </form>
@@ -1,28 +0,0 @@
1
- <% globals = schema.globals %>
2
- <% unless globals.empty? %>
3
- <%= render 'round.erb', :locals => {:schema => schema, :nodes => globals, :round => nil, :id => id} %>
4
- <% end %>
5
- <% index = 0 %>
6
- <% schema.natural_rounds.each do |nodes| %>
7
- <%= render 'round.erb', :locals => {:schema => schema, :nodes => nodes, :round => index, :id => id} %>
8
- <% index += 1 %>
9
- <% end %>
10
- <%= render 'round.erb', :locals => {:schema => schema, :nodes => [], :round => index, :id => id} %>
11
-
12
- <form id="submit_form_<%= id %>" class="submit_form" enctype="multipart/form-data" method="post" action="/schema/submit/<%= id %>">
13
- <ol id="schema_<%= id %>" class="schema">
14
- <% schema.nodes.each_with_index do |node, index| %>
15
- <li id="node_<%= index %>" class="node">
16
- <%= render('node.erb', :locals => {:id => id, :node => node, :index => index} ) %>
17
- </li>
18
- <% end %>
19
- </ol>
20
- <% schema.dump.select {|obj| !obj.kind_of?(Array) }.each do |str| %>
21
- <input name="argv[]" type="hidden" value="--<%= str %>" />
22
- <% end %>
23
- <input class="submit_form_action" type="radio" name="action" value="save" checked="true">save</input>
24
- <input class="submit_form_action" type="radio" name="action" value="preview">preview</input>
25
- <input class="submit_form_action" type="radio" name="action" value="echo">echo</input>
26
- <input class="submit_form_action" type="radio" name="action" value="run">run</input>
27
- <input id="submit_form_submit" type="submit" value="Submit" />
28
- </form>
@@ -1 +0,0 @@
1
- <%= _result.dump %>