haveapi-fs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/CHANGELOG +2 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +338 -0
  7. data/Rakefile +1 -0
  8. data/assets/css/bootstrap.min.css +6 -0
  9. data/assets/css/local.css +11 -0
  10. data/bin/haveapi-fs +5 -0
  11. data/haveapi-fs.gemspec +30 -0
  12. data/lib/core_ext/string.rb +9 -0
  13. data/lib/haveapi/fs/auth/base.rb +56 -0
  14. data/lib/haveapi/fs/auth/basic.rb +29 -0
  15. data/lib/haveapi/fs/auth/noauth.rb +9 -0
  16. data/lib/haveapi/fs/auth/token.rb +39 -0
  17. data/lib/haveapi/fs/cache.rb +71 -0
  18. data/lib/haveapi/fs/cleaner.rb +56 -0
  19. data/lib/haveapi/fs/component.rb +237 -0
  20. data/lib/haveapi/fs/components/action_dir.rb +106 -0
  21. data/lib/haveapi/fs/components/action_errors.rb +49 -0
  22. data/lib/haveapi/fs/components/action_exec.rb +12 -0
  23. data/lib/haveapi/fs/components/action_exec_edit.rb +90 -0
  24. data/lib/haveapi/fs/components/action_input.rb +40 -0
  25. data/lib/haveapi/fs/components/action_message.rb +19 -0
  26. data/lib/haveapi/fs/components/action_output.rb +79 -0
  27. data/lib/haveapi/fs/components/action_status.rb +32 -0
  28. data/lib/haveapi/fs/components/cache_stats.rb +19 -0
  29. data/lib/haveapi/fs/components/component_list.rb +24 -0
  30. data/lib/haveapi/fs/components/create_action_dir.rb +15 -0
  31. data/lib/haveapi/fs/components/delete_action_dir.rb +22 -0
  32. data/lib/haveapi/fs/components/directory.rb +45 -0
  33. data/lib/haveapi/fs/components/directory_reset.rb +8 -0
  34. data/lib/haveapi/fs/components/executable.rb +75 -0
  35. data/lib/haveapi/fs/components/file.rb +43 -0
  36. data/lib/haveapi/fs/components/groff_help_file.rb +9 -0
  37. data/lib/haveapi/fs/components/help_file.rb +28 -0
  38. data/lib/haveapi/fs/components/html_help_file.rb +24 -0
  39. data/lib/haveapi/fs/components/index_filter.rb +63 -0
  40. data/lib/haveapi/fs/components/info_files.rb +19 -0
  41. data/lib/haveapi/fs/components/instance_create.rb +20 -0
  42. data/lib/haveapi/fs/components/instance_edit.rb +49 -0
  43. data/lib/haveapi/fs/components/list_item.rb +28 -0
  44. data/lib/haveapi/fs/components/md_help_file.rb +24 -0
  45. data/lib/haveapi/fs/components/meta_dir.rb +42 -0
  46. data/lib/haveapi/fs/components/meta_file.rb +21 -0
  47. data/lib/haveapi/fs/components/parameter.rb +132 -0
  48. data/lib/haveapi/fs/components/pry.rb +9 -0
  49. data/lib/haveapi/fs/components/remote_control_file.rb +92 -0
  50. data/lib/haveapi/fs/components/resource_action_dir.rb +72 -0
  51. data/lib/haveapi/fs/components/resource_dir.rb +161 -0
  52. data/lib/haveapi/fs/components/resource_id.rb +15 -0
  53. data/lib/haveapi/fs/components/resource_instance_dir.rb +146 -0
  54. data/lib/haveapi/fs/components/rfuse_check.rb +3 -0
  55. data/lib/haveapi/fs/components/root.rb +75 -0
  56. data/lib/haveapi/fs/components/save_instance.rb +11 -0
  57. data/lib/haveapi/fs/components/unsaved_list.rb +24 -0
  58. data/lib/haveapi/fs/components/update_action_dir.rb +31 -0
  59. data/lib/haveapi/fs/context.rb +43 -0
  60. data/lib/haveapi/fs/exceptions.rb +0 -0
  61. data/lib/haveapi/fs/factory.rb +59 -0
  62. data/lib/haveapi/fs/fs.rb +198 -0
  63. data/lib/haveapi/fs/help.rb +91 -0
  64. data/lib/haveapi/fs/main.rb +134 -0
  65. data/lib/haveapi/fs/remote_control.rb +29 -0
  66. data/lib/haveapi/fs/version.rb +5 -0
  67. data/lib/haveapi/fs/worker.rb +77 -0
  68. data/lib/haveapi/fs.rb +65 -0
  69. data/templates/help/html/action_dir.erb +33 -0
  70. data/templates/help/html/action_errors.erb +4 -0
  71. data/templates/help/html/action_input.erb +40 -0
  72. data/templates/help/html/action_output.erb +21 -0
  73. data/templates/help/html/index_filter.erb +16 -0
  74. data/templates/help/html/layout.erb +45 -0
  75. data/templates/help/html/resource_action_dir.erb +18 -0
  76. data/templates/help/html/resource_dir.erb +18 -0
  77. data/templates/help/html/resource_instance_dir.erb +64 -0
  78. data/templates/help/html/root.erb +42 -0
  79. data/templates/help/md/action_dir.erb +29 -0
  80. data/templates/help/md/action_errors.erb +2 -0
  81. data/templates/help/md/action_input.erb +23 -0
  82. data/templates/help/md/action_output.erb +11 -0
  83. data/templates/help/md/index_filter.erb +11 -0
  84. data/templates/help/md/layout.erb +14 -0
  85. data/templates/help/md/resource_action_dir.erb +10 -0
  86. data/templates/help/md/resource_dir.erb +15 -0
  87. data/templates/help/md/resource_instance_dir.erb +42 -0
  88. data/templates/help/md/root.erb +34 -0
  89. metadata +231 -0
@@ -0,0 +1,40 @@
1
+ <h2>Contents</h2>
2
+ <p>
3
+ Every input parameter is represented by a file that can be written to. If a file
4
+ is not changed, the parameter it represents will not be sent to the API -- it is
5
+ possible to send only a subset of input parameters.
6
+ </p>
7
+ <table class="table table-striped table-bordered table-hover">
8
+ <tr>
9
+ <th>Name</th>
10
+ <th>Label</th>
11
+ <th>Required?</th>
12
+ <th>Data type</th>
13
+ <th>Validators</th>
14
+ <th>Default value</th>
15
+ <th>Description</th>
16
+ </tr>
17
+ <% @c.action_dir.action.input_params.each do |name, desc| %>
18
+ <tr>
19
+ <td><%= name %></td>
20
+ <td><%= desc[:label] %></td>
21
+ <td><%= desc[:required] ? 'yes' : 'no' %></td>
22
+ <td><%= desc[:type] %></td>
23
+ <td>
24
+ <% if desc[:validators] -%>
25
+ <% desc[:validators].each do |name, desc| %>
26
+ <%= name.capitalize %>
27
+ <dl>
28
+ <% desc.each do |k, v| %>
29
+ <dt><%= k %></dt>
30
+ <dd><%= v %></dd>
31
+ <% end -%>
32
+ </dl>
33
+ <% end -%>
34
+ <% end -%>
35
+ </td>
36
+ <td><%= desc[:default] %></td>
37
+ <td><%= desc[:description] %></td>
38
+ </tr>
39
+ <% end -%>
40
+ </table>
@@ -0,0 +1,21 @@
1
+ <h2>Contents</h2>
2
+ <p>
3
+ Every output parameter is represented by a read-only file. The directory is empty
4
+ until the action has been executed.
5
+ </p>
6
+ <table class="table table-striped table-bordered table-hover">
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Label</th>
10
+ <th>Data type</th>
11
+ <th>Description</th>
12
+ </tr>
13
+ <% @c.action_dir.action.params.each do |name, desc| %>
14
+ <tr>
15
+ <td><%= name %></td>
16
+ <td><%= desc[:label] %></td>
17
+ <td><%= desc[:type] %></td>
18
+ <td><%= desc[:description] %></td>
19
+ </tr>
20
+ <% end -%>
21
+ </table>
@@ -0,0 +1,16 @@
1
+ <h2>Contents</h2>
2
+ <p>
3
+ Although this directory is empty, any given path will serve as a value for
4
+ filtering output of <code>Index</code> action of this resource using the
5
+ following parameters:
6
+ </p>
7
+
8
+ <dl>
9
+ <% @c.filters.each do |k, v| %>
10
+ <dt><%= k %></dt>
11
+ <dd><%= v %></dd>
12
+ <% end -%>
13
+
14
+ <dt><%= @c.param %></dt>
15
+ <dd><em>remains to be set</em></dd>
16
+ </dl>
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= @c.title %></title>
6
+ <link rel="stylesheet" href="<%= asset('css/bootstrap.min.css') %>">
7
+ <link rel="stylesheet" href="<%= asset('css/local.css') %>">
8
+ </head>
9
+ <body>
10
+ <div class="container-fluid">
11
+ <div class="row">
12
+ <div class="col-md-8 col-md-offset-2">
13
+ <div class="page-header">
14
+ <h1><%= @c.title %> <small>[<a href=".">browse</a>]</small></h1>
15
+ </div>
16
+ <ol class="breadcrumb">
17
+ <% @c.context.object_path[1..-1].each do |k, v| %>
18
+ <li><a href="<%= v.abspath %>/help.html"><%= v.title %></a></li>
19
+ <% end -%>
20
+ </ol>
21
+ <div class="panel panel-default">
22
+ <div class="panel-body">
23
+ <%= yield %>
24
+ </div>
25
+
26
+ <div class="panel-footer">
27
+ <div class="row">
28
+ <div class="col-md-6">
29
+ Connected to API at <a href="<%= @context.url %>"><%= @context.url %></a>
30
+ </div>
31
+ <div class="col-md-6 text-right">
32
+ Generated by
33
+ <a href="https://github.com/vpsfreecz/haveapi-fs">
34
+ haveapi-fs
35
+ </a>
36
+ v<%= HaveAPI::Fs::VERSION %>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </body>
45
+ </html>
@@ -0,0 +1,18 @@
1
+ <h2>Contents</h2>
2
+ <p>
3
+ This directory contains a list of actions that are operating on
4
+ <%= @c.instance? ? 'instance-level' : 'resource-level' %>.
5
+ </p>
6
+ <table class="table table-striped table-bordered table-hover">
7
+ <tr>
8
+ <th>Action</th>
9
+ <th>Description</th>
10
+ </tr>
11
+ <% @c.relevant_actions.each do |name| %>
12
+ <% a = @c.resource.actions[name] -%>
13
+ <tr>
14
+ <th><a href="<%= name %>/help.html"><%= name %></a></th>
15
+ <td><%= a.description %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
@@ -0,0 +1,18 @@
1
+ <p><%= @c.resource._description[:description] %></p>
2
+ <h2>Contents</h2>
3
+ <p>
4
+ This directory contains a list of objects as it is returned by the API server
5
+ using action <code>Index</code>.
6
+
7
+ <dl>
8
+ <dt><code>by-&lt;input_parameter&gt;/&lt;value&gt;</code></dt>
9
+ <dd>Filter objects by input parameters of action <code>Index</code>.</dd>
10
+
11
+ <dt>actions/</dt>
12
+ <dd>Actions that are operating on resource-level, i.e. they are not taking object
13
+ id as an argument.</dd>
14
+
15
+ <dt>create.yml</dt>
16
+ <dd>Editable YAML file with input parameters of action <code>Create</code>. The action is
17
+ executed when the file is saved and closed.</dd>
18
+ </dl>
@@ -0,0 +1,64 @@
1
+ <h2>Contents</h2>
2
+ <p>
3
+ This directory contains output parameters of action
4
+ <a href="actions/show/help.html">show</a>, instance-level actions
5
+ and subresources. Associated resources are represented by a directory.
6
+ </p>
7
+ <dl>
8
+ <dt><code>&lt;parameter&gt;</code></dt>
9
+ <dd>
10
+ Output parameters from action <a href="actions/show/help.html">show</a>.
11
+ Parameters that are also input parameters of action
12
+ <a href="actions/update/help.html">update</a> are writable.
13
+ </dd>
14
+
15
+ <dt><code>&lt;association&gt;/</code></dt>
16
+ <dd>Associated resource is accessible as a nested resource instance.</dd>
17
+
18
+ <dt><code>&lt;association_id&gt;</code></dt>
19
+ <dd>To change the associated resource, write its id to this file.</dd>
20
+
21
+ <dt>save</dt>
22
+ <dd>Trigger the update action. The same as using <code>actions/update/exec</code>.</dd>
23
+
24
+ <dt>edit.yml</dt>
25
+ <dd>Editable YAML file with input parameters of action <code>Update</code>. The action is
26
+ executed when the file is saved and closed.</dd>
27
+
28
+ <dt><code>&lt;subresource&gt;/</code></dt>
29
+ <dd>Access to subresources.</dd>
30
+ </dl>
31
+
32
+ <h3>Attributes</h3>
33
+ <table class="table table-striped table-bordered table-hover">
34
+ <tr>
35
+ <th>Name</th>
36
+ <th>Label</th>
37
+ <th>Data type</th>
38
+ <th>Description</th>
39
+ </tr>
40
+ <% @c.resource.attributes.each_key do |name| %>
41
+ <% next if name == :_meta %>
42
+ <% desc = @c.resource.actions[:show].params[name] %>
43
+ <tr>
44
+ <td><%= name %></td>
45
+ <td><%= desc[:label] %></td>
46
+ <td><%= desc[:type] %></td>
47
+ <td><%= desc[:description] %></td>
48
+ </tr>
49
+ <% end -%>
50
+ </table>
51
+
52
+ <h3>Subresources</h3>
53
+ <table class="table table-striped table-bordered table-hover">
54
+ <tr>
55
+ <th>Resource</th>
56
+ <th>Description</th>
57
+ </tr>
58
+ <% @c.subresources.each do |name| %>
59
+ <tr>
60
+ <th><a href="<%= name %>/help.html"><%= name %></a></th>
61
+ <td><%= @c.resource.resources[name]._description[:description] %></td>
62
+ </tr>
63
+ <% end -%>
64
+ </table>
@@ -0,0 +1,42 @@
1
+ <h2>Special files</h2>
2
+ <p>Every directory can contain the following special files:</p>
3
+
4
+ <dl>
5
+ <dt>help.{html,txt,md,man}</dt>
6
+ <dd>Auto-generated files containing information about the current directory.</dd>
7
+
8
+ <dt>.unsaved</dt>
9
+ <dd>Contains a list of subdirectories and files that have been modified and not saved.</dd>
10
+
11
+ <dt>.reset</dt>
12
+ <dd>An executable that resets the current directory upon invocation, i.e. all
13
+ descendant directories and files are dropped from memory and will have to
14
+ be loaded again.</dd>
15
+ </dl>
16
+
17
+ <h2>Information files</h2>
18
+ <dl>
19
+ <dt>.client_version</dt>
20
+ <dd>Version of <code>haveapi-client</code>.</dd>
21
+
22
+ <dt>.fs_version</dt>
23
+ <dd>Version of this filesystem.</dd>
24
+
25
+ <dt>.protocol_version</dt>
26
+ <dd>Version of HaveAPI protocol that <code>haveapi-client</code> supports.
27
+ This filesystem works only with APIs using compatible protocol.</dd>
28
+ </dl>
29
+
30
+ <h2>Resources</h2>
31
+ <table class="table table-striped table-bordered table-hover">
32
+ <tr>
33
+ <th>Resource</th>
34
+ <th>Description</th>
35
+ </tr>
36
+ <% @c.resources.each do |name, r| %>
37
+ <tr>
38
+ <td><a href="<%= name %>/help.html"><%= name %></a></td>
39
+ <td><%= r._description[:description] %></td>
40
+ </tr>
41
+ <% end -%>
42
+ </table>
@@ -0,0 +1,29 @@
1
+ CONTENTS
2
+ --------
3
+ This directory is used to prepare input parameters, execute the action and retrieve
4
+ output parameters.
5
+
6
+ `input/`
7
+ Stage area for input parameters.
8
+
9
+ `output/`
10
+ Contains output parameters after the action was executed.
11
+
12
+ `exec`
13
+ Write `1` to this file to execute the action.
14
+
15
+ `exec.yml`
16
+ Editable YAML file with input parameters. The action is executed when the
17
+ file is saved and closed.
18
+
19
+ `status`
20
+ Read action status. `1` if successful, `0` if not, empty if not yet run.
21
+
22
+ `message`
23
+ Error message returned from the API.
24
+
25
+ `errors/`
26
+ List of parameter errors.
27
+
28
+ `reset`
29
+ Reset input parameters.
@@ -0,0 +1,2 @@
1
+ This directory contains a list of errors for every parameter, where a parameter
2
+ is represented by a file, one error per line.
@@ -0,0 +1,23 @@
1
+ CONTENTS
2
+ --------
3
+ Every input parameter is represented by a file that can be written to. If a file
4
+ is not changed, the parameter it represents will not be sent to the API -- it is
5
+ possible to send only a subset of input parameters.
6
+
7
+ <% @c.action_dir.action.input_params.each do |name, desc| %>
8
+ *<%= safe_print(name) %>*
9
+ Label: <%= desc[:label] %>
10
+ Required: <%= desc[:required] ? 'yes' : 'no' %>
11
+ Data type: <%= desc[:type] %>
12
+ <% if desc[:validators] -%>
13
+ Validators:
14
+ <% desc[:validators].each do |name, desc| -%>
15
+ <%= name.capitalize %>
16
+ <% desc.each do |k, v| -%>
17
+ - *<%= safe_print(k) %>* <%= v ? "`#{v}`" : '' %>
18
+ <% end -%>
19
+ <% end -%>
20
+ <% end -%>
21
+ Default: <%= desc[:default] %>
22
+ Description: <%= desc[:description] %>
23
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ CONTENTS
2
+ --------
3
+ Every output parameter is represented by a read-only file. The directory is empty
4
+ until the action has been executed.
5
+
6
+ <% @c.action_dir.action.params.each do |name, desc| %>
7
+ *<%= safe_print(name) %>*
8
+ Label: <%= desc[:label] %>
9
+ Data type: <%= desc[:type] %>
10
+ Description: <%= desc[:description] %>
11
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ CONTENTS
2
+ --------
3
+ Although this directory is empty, any given path will serve as a value for
4
+ filtering output of `Index` action of this resource using the following
5
+ parameters:
6
+
7
+ <% @c.filters.each do |k, v| %>
8
+ *<%= k %>* = `<%= v %>`
9
+ <% end -%>
10
+
11
+ *<%= @c.param %>* remains to be set
@@ -0,0 +1,14 @@
1
+ HAVEAPI-FS 7 "Apr 2016" <%= @context.url %> "<%= @c.title %>"
2
+ ========================<%= '=' * (@c.title.length + @context.url.length) %>===
3
+
4
+ LOCATION
5
+ --------
6
+ Connected to API at <%= @context.url %>
7
+
8
+ <% i = 0 -%>
9
+ <% @c.context.object_path[1..-1].each do |_, v| -%>
10
+ <%= ' ' * i %>- <%= v.title %>
11
+ <% i += 1 -%>
12
+ <% end -%>
13
+
14
+ <%= yield %>
@@ -0,0 +1,10 @@
1
+ CONTENTS
2
+ --------
3
+ This directory contains a list of actions that are operating on
4
+ <%= @c.instance? ? 'instance-level' : 'resource-level' %>.
5
+
6
+ <% @c.relevant_actions.each do |name| %>
7
+ <% a = @c.resource.actions[name] -%>
8
+ `<%= safe_print(name) %>`
9
+ <%= a.description %>
10
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ CONTENTS
2
+ --------
3
+ This directory contains a list of objects as it is returned by the API server
4
+ using action `Index`.
5
+
6
+ `by-<input_parameter>/<value>`
7
+ Filter objects by input parameters of action `Index`.
8
+
9
+ `actions/`
10
+ Actions that are operating on resource-level, i.e. they are not taking object
11
+ id as an argument.
12
+
13
+ `create.yml`
14
+ Editable YAML file with input parameters of action `Create`. The action is
15
+ executed when the file is saved and closed.
@@ -0,0 +1,42 @@
1
+ CONTENTS
2
+ --------
3
+ This directory contains output parameters of action `show`, instance-level
4
+ actions and subresources. Associated resources are represented by a directory.
5
+
6
+ `<parameter>`
7
+ Output parameters from action `show`. Parameters that are also input
8
+ parameters of action `update` are writable.
9
+
10
+ `<association>/`
11
+ Associated resource is accessible as a nested resource instance.
12
+
13
+ `<association_id>`
14
+ To change the associated resource, write its id to this file.
15
+
16
+ `save`
17
+ Trigger the update action. The same as using `actions/update/exec`.
18
+
19
+ `edit.yml`
20
+ Editable YAML file with input parameters of action `Update`. The action is
21
+ executed when the file is saved and closed.
22
+
23
+ `<subresource>/`
24
+ Access to subresources.
25
+
26
+ ATTRIBUTES
27
+ ----------
28
+ <% @c.resource.attributes.each_key do |name| %>
29
+ <% next if name == :_meta -%>
30
+ <% desc = @c.resource.actions[:show].params[name] -%>
31
+ *<%= safe_print(name) %>*
32
+ Label: <%= desc[:label] %>
33
+ Type: <%= desc[:type] %>
34
+ Description: <%= desc[:description] %>
35
+ <% end -%>
36
+
37
+ SUBRESOURCES
38
+ ------------
39
+ <% @c.subresources.each do |name| %>
40
+ *<%= safe_print(name) %>*
41
+ <%= @c.resource.resources[name]._description[:description] %>
42
+ <% end -%>
@@ -0,0 +1,34 @@
1
+ SPECIAL FILES
2
+ -------------
3
+ Every directory can contain the following special files:
4
+
5
+ `help.{html,txt,md,man}`
6
+ Auto-generated files containing information about the current directory.
7
+
8
+ `.unsaved`
9
+ Contains a list of subdirectories and files that have been modified and not
10
+ saved.
11
+
12
+ `.reset`
13
+ An executable that resets the current directory upon invocation, i.e. all
14
+ descendant directories and files are dropped from memory and will have to
15
+ be loaded again.
16
+
17
+ INFORMATION FILES
18
+ -----------------
19
+ `.client_version`
20
+ Version of `haveapi-client`.
21
+
22
+ `.fs_version`
23
+ Version of this filesystem.
24
+
25
+ `.protocol_version`
26
+ Version of HaveAPI protocol that `haveapi-client` supports.
27
+ This filesystem works only with APIs using compatible protocol.
28
+
29
+ RESOURCES
30
+ ---------
31
+ <% @c.resources.each do |name, r| %>
32
+ *<%= safe_print(name) %>*
33
+ <%= r._description[:description] %>
34
+ <% end -%>