soar_lexicon 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8ac53357f62d2aa93269853bcf7abed99abbc45c
4
+ data.tar.gz: 1af0b3a648258b65e94340371d97c15c924a28ca
5
+ SHA512:
6
+ metadata.gz: 93d1024161709b7a05eb1ee80e1b1968987dbeccb575c23fb47a1ea9af01f2ea5a9c649568ac570dcc05b4d5e97cab86c39702cb2dbd6148678b77f353e8e3dd
7
+ data.tar.gz: a3a1d3b5468a32e9ed4af50eeaa41c085e1ead696172121cfeaf7c096b0ea07939a3b258b7d8ca49e0e65400a4fe22f66a0e19ed4aed9bc118184a62443821d4
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .byebug_history
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in soar_lexicon.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ernst Van Graan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # SoarLexicon
2
+
3
+ This middleware provides dynamic service component WADL lexicon and individal service ?wadl lexicon. If /lexicon is requested on a service component, this middleware compiles a WADL document describing all routes registered with the router meta object provided. If a specific service endpoint is requested, appended with ?wadl, this middleware compiles a WADL document describing that service.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'soar_lexicon'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install soar_lexicon
20
+
21
+ ## Usage
22
+
23
+ Ensure that your rack env includes a 'lexicon' key that is configured with route descriptions of the following form:
24
+
25
+ ```
26
+ lexicon = {
27
+ '/route-path' => {
28
+ 'description' => 'Business question answered here',
29
+ 'service_name' => 'business_service',
30
+ 'path' => '/route-path',
31
+ 'method' => 'get',
32
+ 'params' => {
33
+ 'pattern' => {
34
+ 'required' => 'true', 'type' => 'string'
35
+ }
36
+ },
37
+ }
38
+ }
39
+ ```
40
+
41
+ If you are using SoarAspects, this can be accomplished so:
42
+
43
+ ```
44
+ SoarAspects::Aspects::lexicon = lexicon
45
+ use SoarAspects::Aspects
46
+ ```
47
+
48
+ Then, in your config.ru, place:
49
+
50
+ ```
51
+ use SoarLexicon::Lexicon
52
+ ```
53
+
54
+ ## Visualizing
55
+
56
+ SoarLexicon delivers a WADL XML document and delivers an expectation of a style-sheet for display in a browser to be located on the service component at the path /wadl/wadl.xsl
57
+
58
+ ## Contributing
59
+
60
+ Please send feedback and comments to the author at:
61
+
62
+ Ernst van Graan <ernst.van.graan@hetzner.co.za>
63
+
64
+ This gem is sponsored by Hetzner (Pty) Ltd - http://hetzner.co.za
65
+
66
+ ## License
67
+
68
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
69
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "soar_lexicon"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ require "soar_lexicon/version"
2
+ require 'wadling'
3
+ require 'rack'
4
+
5
+ module SoarLexicon
6
+ class Lexicon
7
+ WADL_XSL = "/wadl/wadl.xsl" if not defined? WADL_XSL; WADL_XSL.freeze
8
+ attr_reader :app
9
+
10
+ def initialize(app)
11
+ @app = app
12
+ end
13
+
14
+ def call(env)
15
+ request = Rack::Request.new(env)
16
+ return respond(SoarLexicon::Lexicon::describe(env['lexicon'])) if Regexp.new('/lexicon').match(request.path)
17
+ return respond(SoarLexicon::Lexicon::describe_resource(env['lexicon'], request.path)) if request.env['QUERY_STRING'] == 'wadl'
18
+ app.call(env)
19
+ end
20
+
21
+ def self.describe(lexicon)
22
+ translator = Wadling::LexiconTranslator.new(SoarLexicon::Lexicon::WADL_XSL)
23
+ translator.translate_resources_into_wadl(lexicon)
24
+ end
25
+
26
+ def self.describe_resource(lexicon, route)
27
+ translator = Wadling::LexiconTranslator.new(SoarLexicon::Lexicon::WADL_XSL)
28
+ data = {}
29
+ data[route] = lexicon[route]
30
+ translator.translate_resources_into_wadl(data)
31
+ end
32
+
33
+ private
34
+
35
+ def respond(content)
36
+ [200, {"Content-Type" => "application/xml"}, [content]]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module SoarLexicon
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'soar_lexicon/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "soar_lexicon"
8
+ spec.version = SoarLexicon::VERSION
9
+ spec.authors = ["Ernst Van Graan"]
10
+ spec.email = ["ernst.van.graan@hetzner.co.za"]
11
+
12
+ spec.summary = %q{Provides a dynamic service component WADL lexicon and individal service ?wadl lexicon}
13
+ spec.description = %q{Provides a dynamic service component WADL lexicon and individal service ?wadl lexicon}
14
+ spec.homepage = "https://gitlab.host-h.net/hetznerZA/soar_lexicon"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "rack", "~> 1.6.4"
31
+ spec.add_dependency 'wadling', "~> 0.1.9"
32
+ spec.add_development_dependency "bundler", "~> 1.12"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "byebug"
36
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soar_lexicon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ernst Van Graan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: wadling
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.9
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Provides a dynamic service component WADL lexicon and individal service
98
+ ?wadl lexicon
99
+ email:
100
+ - ernst.van.graan@hetzner.co.za
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/soar_lexicon.rb
115
+ - lib/soar_lexicon/version.rb
116
+ - soar_lexicon.gemspec
117
+ homepage: https://gitlab.host-h.net/hetznerZA/soar_lexicon
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.5.1
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Provides a dynamic service component WADL lexicon and individal service ?wadl
141
+ lexicon
142
+ test_files: []