ood_appkit 0.2.6 → 0.2.7

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: 8eb6d20b4747f2021e1f88650dbccf1128a3783c
4
- data.tar.gz: c04296d552fb068865ee30feaee0addba8a6bd76
3
+ metadata.gz: 3357fbdca016e8208120c92b174b7dbfc9ab40b9
4
+ data.tar.gz: 06b2d516f3028be6f12531cd7a167caaf7ad6088
5
5
  SHA512:
6
- metadata.gz: 6ed370c8a4107a89f89ef3cbe0354f39cf762854d064a7d9a7a2177632a77cef1a3be94ad452d2da4ea7be3260506d8602f2b9a0813d185b0bc5f28a5d0eec5b
7
- data.tar.gz: 905ca68526ade3d6299a1bcaedf32035c73f9476ea28dcf181203e3820b1423916730c661401f1bccb3381a178b4abfc84841c5a2c0d5bb9d3fb87c28507c96a
6
+ metadata.gz: 506a025230543001aa94ef4dd3f8f6d58a35025abcb69ccd2b7dc823339a2c7e89e73433c9dd784ac8ed580a7af9ee94414206ec89a8f01d002acab2b71d9e6b
7
+ data.tar.gz: f1df95d9da1e843a62d2cc49f371f2640efdb90c8baea602e9aca679dd587f27b706d5ff957c20bb27dd55f1912db6f03da745d0fdea50f467f231c1c1afd477
data/README.md CHANGED
@@ -76,7 +76,7 @@ Or by modifying the configuration in an initializer:
76
76
 
77
77
  OodAppkit.configure do |config|
78
78
  # Defaults
79
- config.dashboard = OodAppkit::DashboardUrl.new title: 'Dashboard', base_url: '/pun/sys/dashboard'
79
+ config.dashboard = OodAppkit::Urls::Dashboard.new title: 'Dashboard', base_url: '/pun/sys/dashboard'
80
80
  end
81
81
  ```
82
82
 
@@ -108,7 +108,7 @@ Or by modifying the configuration in an initializer:
108
108
 
109
109
  OodAppkit.configure do |config|
110
110
  # Defaults
111
- config.files = OodAppkit::FilesUrl.new title: 'Files', base_url: '/pun/sys/files'
111
+ config.files = OodAppkit::Urls::Files.new title: 'Files', base_url: '/pun/sys/files'
112
112
  end
113
113
  ```
114
114
 
@@ -137,7 +137,7 @@ Or by modifying the configuration in an initializer:
137
137
 
138
138
  OodAppkit.configure do |config|
139
139
  # Defaults
140
- config.editor = OodAppkit::EditorUrl.new title: 'Editor', base_url: '/pun/sys/file-editor'
140
+ config.editor = OodAppkit::Urls::Editor.new title: 'Editor', base_url: '/pun/sys/file-editor'
141
141
  end
142
142
  ```
143
143
 
@@ -171,7 +171,7 @@ Or by modifying the configuration in an initializer:
171
171
 
172
172
  OodAppkit.configure do |config|
173
173
  # Defaults
174
- config.shell = OodAppkit::ShellUrl.new title: 'Shell', base_url: '/pun/sys/shell'
174
+ config.shell = OodAppkit::Urls::Shell.new title: 'Shell', base_url: '/pun/sys/shell'
175
175
  end
176
176
  ```
177
177
 
@@ -559,7 +559,7 @@ or by modifying the configuration in an initializer
559
559
  # config/initializers/ood_appkit.rb
560
560
 
561
561
  OodAppkit.configure do |config|
562
- config.clusters.all = OodAppkit::Cluster.all(file: "/path/to/my/config.yml")
562
+ config.clusters.cache = OodAppkit::Cluster.all(file: "/path/to/my/config.yml")
563
563
  end
564
564
  ```
565
565
 
data/config/clusters.yml CHANGED
@@ -23,7 +23,7 @@ v1:
23
23
  segments:
24
24
  - 'gweb'
25
25
  - 'graph.php'
26
- query:
26
+ req_query:
27
27
  c: 'Oakley nodes'
28
28
  opt_query:
29
29
  h: '%{h}.ten.osc.edu'
@@ -57,11 +57,42 @@ v1:
57
57
  segments:
58
58
  - 'gweb'
59
59
  - 'graph.php'
60
- query:
60
+ req_query:
61
61
  c: 'Ruby'
62
62
  opt_query:
63
63
  h: '%{h}.ten.osc.edu'
64
64
  version: '3'
65
+ owens:
66
+ title: 'Owens'
67
+ validators:
68
+ in_valid_groups:
69
+ type: 'OodAppkit::Validators::Groups'
70
+ groups:
71
+ - 'owens'
72
+ - 'oscsys'
73
+ - 'hpcsys'
74
+ - 'sysp'
75
+ - 'appl'
76
+ - 'cons'
77
+ - 'oscgen'
78
+ - 'hpcsoft'
79
+ - 'oscadm'
80
+ servers:
81
+ login:
82
+ type: 'OodAppkit::Server'
83
+ host: 'owens.hpc.osc.edu'
84
+ ganglia:
85
+ type: 'OodAppkit::Servers::Ganglia'
86
+ host: 'cts05.osc.edu'
87
+ scheme: 'https://'
88
+ segments:
89
+ - 'gweb'
90
+ - 'graph.php'
91
+ req_query:
92
+ c: 'Owens'
93
+ opt_query:
94
+ h: '%{h}.ten.osc.edu'
95
+ version: '3'
65
96
  quick:
66
97
  title: 'Quick'
67
98
  hpc_cluster: false
@@ -65,9 +65,16 @@ module OodAppkit
65
65
  self.dataroot = ENV['OOD_DATAROOT'] || ENV['RAILS_DATAROOT']
66
66
 
67
67
  # Initialize list of available clusters
68
- c_conf = ENV['OOD_CLUSTERS'] || ( OOD_CONFIG.join('clusters.yml') if OOD_CONFIG.join('clusters.yml').file? )
69
- self.clusters = OpenStruct.new
70
- clusters.all = OodAppkit::Cluster.all( c_conf ? {file: c_conf} : {} )
68
+ # FIXME: use "/etc/ood/config/..." in the future
69
+ # FIXME: use `ood_cluster` gem instead in the future
70
+ self.clusters = OpenStruct.new(
71
+ cache: OodAppkit::Cluster.all(
72
+ file: ENV['OOD_CLUSTERS'] || File.expand_path('../../../config/clusters.yml', __FILE__)
73
+ )
74
+ )
75
+ def clusters.all
76
+ cache
77
+ end
71
78
  def clusters.hpc
72
79
  all.select {|k,v| v.hpc_cluster?}
73
80
  end
@@ -86,23 +93,23 @@ module OodAppkit
86
93
  )
87
94
 
88
95
  # Initialize URL handlers for system apps
89
- self.public = PublicUrl.new(
96
+ self.public = Urls::Public.new(
90
97
  title: ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
91
98
  base_url: ENV['OOD_PUBLIC_URL'] || '/public'
92
99
  )
93
- self.dashboard = DashboardUrl.new(
100
+ self.dashboard = Urls::Dashboard.new(
94
101
  title: ENV['OOD_DASHBOARD_TITLE'] || 'Dashboard',
95
102
  base_url: ENV['OOD_DASHBOARD_URL'] || '/pun/sys/dashboard'
96
103
  )
97
- self.shell = ShellUrl.new(
104
+ self.shell = Urls::Shell.new(
98
105
  title: ENV['OOD_SHELL_TITLE'] || 'Shell',
99
106
  base_url: ENV['OOD_SHELL_URL'] || '/pun/sys/shell'
100
107
  )
101
- self.files = FilesUrl.new(
108
+ self.files = Urls::Files.new(
102
109
  title: ENV['OOD_FILES_TITLE'] || 'Files',
103
110
  base_url: ENV['OOD_FILES_URL'] || '/pun/sys/files'
104
111
  )
105
- self.editor = EditorUrl.new(
112
+ self.editor = Urls::Editor.new(
106
113
  title: ENV['OOD_EDITOR_TITLE'] || 'Editor',
107
114
  base_url: ENV['OOD_EDITOR_URL'] || '/pun/sys/file-editor'
108
115
  )
@@ -21,13 +21,17 @@ module OodAppkit
21
21
 
22
22
  # The required query values of the URI
23
23
  # @example Required cluster query value
24
- # "my_ganglia.query"
24
+ # "my_ganglia.req_query"
25
25
  # #=> {c: "MyCluster"}
26
26
  # @return [Hash] required query values of uri
27
- attr_reader :query
27
+ attr_reader :req_query
28
28
 
29
29
  # Optional query values of the URI, these query values are
30
30
  # only defined if specified
31
+ # NB: All optional values will be evaluated for string interpolations
32
+ # @example Optional host query value
33
+ # "my_ganglia.opt_query"
34
+ # #=> {h: "%{h}.ten.osc.edu"}
31
35
  # @return [Hash] optional query values of uri
32
36
  attr_reader :opt_query
33
37
 
@@ -36,48 +40,44 @@ module OodAppkit
36
40
  attr_reader :version
37
41
 
38
42
  # @param scheme [String] the scheme used for URI
39
- # @param segments [Array<String>] the segments used to
40
- # construct path of URI
41
- # @param query [Hash] hash of query values used for
42
- # URI
43
- # @param opt_query [Hash] hash of optional query
44
- # values if they exist
43
+ # @param segments [Array<String>] the segments used to construct path of URI
44
+ # @param req_query [Hash] hash of required query values used for URI
45
+ # @param opt_query [Hash] hash of optional query values if they exist
45
46
  # @param version [String] version of server software
46
- def initialize(scheme:, segments: [], query: {}, opt_query: {}, version:, **kwargs)
47
+ def initialize(scheme:, segments: [], req_query: {}, opt_query: {}, version:, **kwargs)
47
48
  super(kwargs)
48
49
 
49
50
  # uri
50
51
  @scheme = scheme
51
52
  @segments = segments
52
- @query = query
53
+ @req_query = req_query
53
54
  @opt_query = opt_query
54
55
 
55
56
  # version
56
57
  @version = version
57
58
  end
58
59
 
59
- # The full hash of query values used to construct URI
60
- # @param other_query [Hash] user specified query hash
61
- # @return [Hash] full hash of query values
62
- def query_values(other_query)
63
- query.merge(
64
- other_query.each_with_object({}) do |(k, v), h|
65
- h[k] = opt_query.has_key?(k) ? (opt_query[k] % query.merge(other_query)) : v
66
- end
67
- )
68
- end
69
-
70
60
  # The URI used to access information about given cluster
71
- # @param query_values [Hash] user specified query hash
61
+ # @param query [Hash] user specified query hash
72
62
  # @return [Addressable] the uri for ganglia server
73
- def uri(query_values: {})
63
+ def uri(query: {})
74
64
  Addressable::Template.new(TEMPLATE).expand({
75
65
  scheme: scheme,
76
66
  host: host,
77
67
  segments: segments,
78
- query: query_values(query_values)
68
+ query: query_hash(query)
79
69
  })
80
70
  end
71
+
72
+ private
73
+ # The full hash of query values used to construct URI
74
+ def query_hash(query)
75
+ req_query.merge(
76
+ query.each_with_object({}) do |(k, v), h|
77
+ h[k] = opt_query.has_key?(k) ? (opt_query[k] % req_query.merge(query)) : v
78
+ end
79
+ )
80
+ end
81
81
  end
82
82
  end
83
83
  end
@@ -0,0 +1,32 @@
1
+ require 'addressable'
2
+
3
+ module OodAppkit
4
+ # A generic class used to handle URLs for an app
5
+ class Url
6
+ # The title for this URL
7
+ # @return [String] the title of the URL
8
+ attr_reader :title
9
+
10
+ # @param title [#to_s] the title of the URL
11
+ # @param base_url [#to_s] the base URL used to access this app
12
+ # @param template [#to_s] the template used to generate URLs for this app
13
+ # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
14
+ def initialize(title: '', base_url: '/', template: '{/url*}/')
15
+ @title = title.to_s
16
+ @template = Addressable::Template.new template.to_s
17
+ @base_url = parse_url_segments(base_url.to_s)
18
+ end
19
+
20
+ # URL to access this app
21
+ # @return [Addressable::URI] the url used to access the app
22
+ def url
23
+ @template.expand url: @base_url
24
+ end
25
+
26
+ private
27
+ # Parse URL segments into an array
28
+ def parse_url_segments(url)
29
+ url.split('/').reject(&:empty?)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ module OodAppkit
2
+ module Urls
3
+ # A class used to handle URLs for the system Dashboard app.
4
+ class Dashboard < Url
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module OodAppkit
2
+ module Urls
3
+ # A class used to handle URLs for the system file Editor app.
4
+ class Editor < Url
5
+ # @param (see Url#initialize)
6
+ # @param edit_url [#to_s] the URL used to request the file editor api
7
+ def initialize(edit_url: '/edit', template: '{/url*}{+path}', **kwargs)
8
+ super(template: template, **kwargs)
9
+ @edit_url = parse_url_segments(edit_url.to_s)
10
+ end
11
+
12
+ # URL to access this app's file editor API for a given absolute file path
13
+ # @param path [#to_s] the absolute path to the file on the filesystem
14
+ # @return [Addressable::URI] absolute url to access path in file editor api
15
+ def edit(path: '')
16
+ @template.expand url: @base_url + @edit_url, path: path.to_s
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ module OodAppkit
2
+ module Urls
3
+ # A class used to handle URLs for the system Files app.
4
+ class Files < Url
5
+ # @param (see Url#initialize)
6
+ # @param fs_url [#to_s] the URL used to request a filesystem view in the app
7
+ # @param api_url [#to_s] the URL used to request the app's api
8
+ def initialize(fs_url: '/fs', api_url: '/api/v1/fs', template: '{/url*}{+path}', **kwargs)
9
+ super(template: template, **kwargs)
10
+ @fs_url = parse_url_segments(fs_url.to_s)
11
+ @api_url = parse_url_segments(api_url.to_s)
12
+ end
13
+
14
+ # URL to access this app for a given absolute file path
15
+ # @param path [#to_s] the absolute path to the file on the filesystem
16
+ # @return [Addressable::URI] absolute url to access path in files app
17
+ def url(path: '')
18
+ @template.expand url: @base_url + @fs_url, path: path.to_s
19
+ end
20
+
21
+ # URL to access this app's API for a given absolute file path
22
+ # @param path [#to_s] the absolute path to the file on the filesystem
23
+ # @return [Addressable::URI] absolute url to access path in files app api
24
+ def api(path: '')
25
+ @template.expand url: @base_url + @api_url, path: path.to_s
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ module OodAppkit
2
+ module Urls
3
+ # A class used to handle URLs for the publicly available assets.
4
+ class Public < Url
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ module OodAppkit
2
+ module Urls
3
+ # A class used to handle URLs for the system Shell app.
4
+ class Shell < Url
5
+ # @param (see Url#initialize)
6
+ # @param ssh_url [#to_s] the ssh URL used to access the terminal
7
+ def initialize(ssh_url: '/ssh', template: '{/url*}/{host}{+path}', **kwargs)
8
+ super(template: template, **kwargs)
9
+ @ssh_url = parse_url_segments(ssh_url.to_s)
10
+ end
11
+
12
+ # URL to access this app for a given host and absolute file path
13
+ # @param host [#to_s] the host the app will make an ssh connection with
14
+ # @param path [#to_s] the absolute path to the directory ssh app opens up in
15
+ # @return [Addressable::URI] the url used to access the app
16
+ def url(host: 'default', path: '')
17
+ @template.expand url: @base_url + @ssh_url, host: host.to_s, path: path.to_s
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
1
  module OodAppkit
2
2
  # The current version of OodAppkit
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
data/lib/ood_appkit.rb CHANGED
@@ -2,11 +2,7 @@ require 'addressable'
2
2
 
3
3
  require 'ood_appkit/version'
4
4
  require 'ood_appkit/configuration'
5
- require 'ood_appkit/public_url'
6
- require 'ood_appkit/dashboard_url'
7
- require 'ood_appkit/shell_url'
8
- require 'ood_appkit/files_url'
9
- require 'ood_appkit/editor_url'
5
+ require 'ood_appkit/url'
10
6
  require 'ood_appkit/files_rack_app'
11
7
  require 'ood_appkit/markdown_template_handler'
12
8
  require 'ood_appkit/log_formatter'
@@ -15,12 +11,18 @@ require 'ood_appkit/server'
15
11
 
16
12
  # The main namespace for OodAppkit. Provides a global configuration.
17
13
  module OodAppkit
18
- # Global OOD config location
19
- OOD_CONFIG = Pathname.new '/etc/ood/config'
20
-
21
14
  extend Configuration
22
15
  require 'ood_appkit/engine' if defined?(Rails)
23
16
 
17
+ # A namespace to hold all subclasses of {Url}
18
+ module Urls
19
+ require 'ood_appkit/urls/public'
20
+ require 'ood_appkit/urls/dashboard'
21
+ require 'ood_appkit/urls/shell'
22
+ require 'ood_appkit/urls/files'
23
+ require 'ood_appkit/urls/editor'
24
+ end
25
+
24
26
  # A namespace to hold all subclasses of {Server}
25
27
  module Servers
26
28
  require 'ood_appkit/servers/torque'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ood_appkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Franz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-15 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -119,19 +119,20 @@ files:
119
119
  - lib/ood_appkit.rb
120
120
  - lib/ood_appkit/cluster.rb
121
121
  - lib/ood_appkit/configuration.rb
122
- - lib/ood_appkit/dashboard_url.rb
123
- - lib/ood_appkit/editor_url.rb
124
122
  - lib/ood_appkit/engine.rb
125
123
  - lib/ood_appkit/files_rack_app.rb
126
- - lib/ood_appkit/files_url.rb
127
124
  - lib/ood_appkit/log_formatter.rb
128
125
  - lib/ood_appkit/markdown_template_handler.rb
129
- - lib/ood_appkit/public_url.rb
130
126
  - lib/ood_appkit/server.rb
131
127
  - lib/ood_appkit/servers/ganglia.rb
132
128
  - lib/ood_appkit/servers/moab.rb
133
129
  - lib/ood_appkit/servers/torque.rb
134
- - lib/ood_appkit/shell_url.rb
130
+ - lib/ood_appkit/url.rb
131
+ - lib/ood_appkit/urls/dashboard.rb
132
+ - lib/ood_appkit/urls/editor.rb
133
+ - lib/ood_appkit/urls/files.rb
134
+ - lib/ood_appkit/urls/public.rb
135
+ - lib/ood_appkit/urls/shell.rb
135
136
  - lib/ood_appkit/validators/groups.rb
136
137
  - lib/ood_appkit/version.rb
137
138
  - lib/tasks/ood_appkit_tasks.rake
@@ -1,26 +0,0 @@
1
- module OodAppkit
2
- # A class used to handle URLs for the system Dashboard app.
3
- class DashboardUrl
4
- # The title for this URL
5
- # @return [String] the title of the URL
6
- attr_reader :title
7
-
8
- # @param title [String] the title of the URL
9
- # @param base_url [String] the base URL used to access this app
10
- # @param template [String] the template used to generate URLs for this app
11
- # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
12
- def initialize(title: '', base_url: '/', template: '{/url*}/')
13
- @title = title
14
- @template = Addressable::Template.new template
15
-
16
- # Break up into arrays of strings
17
- @base_url = base_url.split('/').reject(&:empty?)
18
- end
19
-
20
- # URL to access this app
21
- # @return [Addressable::URI] the url used to access the app
22
- def url
23
- @template.expand url: @base_url
24
- end
25
- end
26
- end
@@ -1,35 +0,0 @@
1
- module OodAppkit
2
- # A class used to handle URLs for the system file Editor app.
3
- class EditorUrl
4
- # The title for this URL
5
- # @return [String] the title of the URL
6
- attr_reader :title
7
-
8
- # @param title [String] the title of the URL
9
- # @param base_url [String] the base URL used to access this app
10
- # @param edit_url [String] the URL used to request the file editor api
11
- # @param template [String] the template used to generate URLs for this app
12
- # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
13
- def initialize(title: '', base_url: '/', edit_url: '/edit', template: '{/url*}{+path}')
14
- @title = title
15
- @template = Addressable::Template.new template
16
-
17
- # Break up into arrays of strings
18
- @base_url = base_url.split('/').reject(&:empty?)
19
- @edit_url = edit_url.split('/').reject(&:empty?)
20
- end
21
-
22
- # URL to access this app
23
- # @return [Addressable::URI] absolute url to access app
24
- def url
25
- @template.expand url: @base_url
26
- end
27
-
28
- # URL to access this app's file editor API for a given absolute file path
29
- # @param path [String, #to_s] the absolute path to the file on the filesystem
30
- # @return [Addressable::URI] absolute url to access path in file editor api
31
- def edit(path: '')
32
- @template.expand url: @base_url + @edit_url, path: path.to_s
33
- end
34
- end
35
- end
@@ -1,38 +0,0 @@
1
- module OodAppkit
2
- # A class used to handle URLs for the system Files app.
3
- class FilesUrl
4
- # The title for this URL
5
- # @return [String] the title of the URL
6
- attr_reader :title
7
-
8
- # @param title [String] the title of the URL
9
- # @param base_url [String] the base URL used to access this app
10
- # @param fs_url [String] the URL used to request a filesystem view in the app
11
- # @param api_url [String] the URL used to request the app's api
12
- # @param template [String] the template used to generate URLs for this app
13
- # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
14
- def initialize(title: '', base_url: '/', fs_url: '/fs', api_url: '/api/v1/fs', template: '{/url*}{+path}')
15
- @title = title
16
- @template = Addressable::Template.new template
17
-
18
- # Break up into arrays of strings
19
- @base_url = base_url.split('/').reject(&:empty?)
20
- @fs_url = fs_url.split('/').reject(&:empty?)
21
- @api_url = api_url.split('/').reject(&:empty?)
22
- end
23
-
24
- # URL to access this app for a given absolute file path
25
- # @param path [String, #to_s] the absolute path to the file on the filesystem
26
- # @return [Addressable::URI] absolute url to access path in files app
27
- def url(path: '')
28
- @template.expand url: @base_url + @fs_url, path: path.to_s
29
- end
30
-
31
- # URL to access this app's API for a given absolute file path
32
- # @param path [String, #to_s] the absolute path to the file on the filesystem
33
- # @return [Addressable::URI] absolute url to access path in files app api
34
- def api(path: '')
35
- @template.expand url: @base_url + @api_url, path: path.to_s
36
- end
37
- end
38
- end
@@ -1,26 +0,0 @@
1
- module OodAppkit
2
- # A class used to handle URLs for the publicly available assets.
3
- class PublicUrl
4
- # The title for this URL
5
- # @return [String] the title of the URL
6
- attr_reader :title
7
-
8
- # @param title [String] the title of the URL
9
- # @param base_url [String] the base URL used to access this app
10
- # @param template [String] the template used to generate URLs for this app
11
- # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
12
- def initialize(title: '', base_url: '/', template: '{/url*}/')
13
- @title = title
14
- @template = Addressable::Template.new template
15
-
16
- # Break up into arrays of strings
17
- @base_url = base_url.split('/').reject(&:empty?)
18
- end
19
-
20
- # URL to access this app
21
- # @return [Addressable::URI] the url used to access the app
22
- def url
23
- @template.expand url: @base_url
24
- end
25
- end
26
- end
@@ -1,29 +0,0 @@
1
- module OodAppkit
2
- # A class used to handle URLs for the system Shell app.
3
- class ShellUrl
4
- # The title for this URL
5
- # @return [String] the title of the URL
6
- attr_reader :title
7
-
8
- # @param title [String] the title of the URL
9
- # @param base_url [String] the base URL used to access this app
10
- # @param template [String] the template used to generate URLs for this app
11
- # @see https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format
12
- def initialize(title: '', base_url: '/', ssh_url: '/ssh', template: '{/url*}/{host}{+path}')
13
- @title = title
14
- @template = Addressable::Template.new template
15
-
16
- # Break up into arrays of strings
17
- @base_url = base_url.split('/').reject(&:empty?)
18
- @ssh_url = ssh_url.split('/').reject(&:empty?)
19
- end
20
-
21
- # URL to access this app for a given host and absolute file path
22
- # @param host [String] the host the app will make an ssh connection with
23
- # @param path [#to_s] the absolute path to the directory ssh app opens up in
24
- # @return [Addressable::URI] the url used to access the app
25
- def url(host: 'default', path: '')
26
- @template.expand url: @base_url + @ssh_url, host: host, path: path.to_s
27
- end
28
- end
29
- end