lurker 0.5.2 → 0.5.3
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 +4 -4
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.travis.yml +1 -5
- data/README.md +7 -5
- data/features/support/env.rb +3 -0
- data/lib/lurker/controller_spec_watcher.rb +4 -1
- data/lib/lurker/endpoint.rb +5 -0
- data/lib/lurker/endpoint_scaffold.rb +1 -1
- data/lib/lurker/engine.rb +4 -2
- data/lib/lurker/request_spec_watcher.rb +11 -5
- data/lib/lurker/schema.rb +14 -4
- data/lib/lurker/server.rb +5 -3
- data/lib/lurker/service.rb +9 -7
- data/lib/lurker/version.rb +1 -1
- data/lurker.gemspec +1 -0
- data/spec/lurker/yaml_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -0
- metadata +18 -2
- metadata.gz.asc +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e03cec0753864d2fba1831cef5a23e4e8f7ee6
|
4
|
+
data.tar.gz: 2c774884cdfceaab040541bf62587408186b3f8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 674d6b9eb0f82ed400c16dc63b251dc2640b75b5cefcc796f3bcf8053a8e5ddafa8b538d3dec7bda67bdd0b9e7463269ffcf7c0f022015f80eb7fb4aad1d83e6
|
7
|
+
data.tar.gz: 161d9b376e1e6a8c3497877655677ed97478be2fcc711af971c166a8c8d64f4c31c2bbb4015f6c01c40de5a204c55750a1d7b83a9841044dba5112ff8d914105
|
checksums.yaml.gz.asc
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
Version: GnuPG v1
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7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yYPZmD4xx6tchE8ZnyLZ8ErX4EimDFxoP/Q9Bk=
|
11
|
+
=T/zF
|
12
12
|
-----END PGP SIGNATURE-----
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -46,7 +46,8 @@ and it fails if your code changes the api!
|
|
46
46
|
- The property '#/user/last_sign_in_at' of type String did not match the following type:
|
47
47
|
null in schema file:///.../lurker/api/v1/users-POST.json.yml#
|
48
48
|
|
49
|
-
Let's run your `rails s` and visit [http://localhost:3000/lurker/](http://localhost:3000/lurker/)
|
49
|
+
Let's run your `rails s` and visit [http://localhost:3000/lurker/](http://localhost:3000/lurker/)
|
50
|
+
(or see [demo][demo_app2] for example)
|
50
51
|
|
51
52
|
Now, you can test your API on-line (for real)
|
52
53
|
|
@@ -75,7 +76,7 @@ Now, you can test your API on-line (for real)
|
|
75
76
|
# e.g. config/environtents/staging.rb
|
76
77
|
config.middleware.use Lurker::Sandbox
|
77
78
|
|
78
|
-
E.g. demo application runs with it: when creating, updating repos or users
|
79
|
+
E.g. demo application on Heroku runs with it: when creating, updating repos or users
|
79
80
|
ids getting increased, but if you look into GET #index,
|
80
81
|
new items are NOT showing up. **This is NOT a bug!** - sequences in postgres
|
81
82
|
are increasing notwithstanding ROLLBACK is called. As such:
|
@@ -88,7 +89,7 @@ are increasing notwithstanding ROLLBACK is called. As such:
|
|
88
89
|
|
89
90
|
You can clone the repo & run `rake build_example_docs`.
|
90
91
|
It will generate testing rails application under `tmp/lurker_app`.
|
91
|
-
Currently it is deployed [here][demo_app].
|
92
|
+
Currently it is deployed [here][demo_app] within sandbox mode and [here][demo_app2].
|
92
93
|
|
93
94
|
|
94
95
|
## Contributions
|
@@ -151,8 +152,9 @@ Also thanks to [React.js][reactjs] for two-way binding.
|
|
151
152
|
[partial_example]: https://www.relishapp.com/razum2um/lurker/docs/docs-generation/partials
|
152
153
|
[partial_example_demo]: http://lurker-app.herokuapp.com/lurker/api/v1/users/__user_id/repos-POST.html
|
153
154
|
[evil_martians]: http://evilmartians.com/
|
154
|
-
[demo_app]: http://lurker-app.herokuapp.com
|
155
|
-
[
|
155
|
+
[demo_app]: http://lurker-app.herokuapp.com
|
156
|
+
[demo_app2]: http://lurker.razum2um.me
|
157
|
+
[demo_live]: http://lurker.razum2um.me/lurker/api/v1/users-POST.html
|
156
158
|
|
157
159
|
[Gem Version]: https://rubygems.org/gems/lurker
|
158
160
|
[Build Status]: https://travis-ci.org/razum2um/lurker
|
data/features/support/env.rb
CHANGED
@@ -9,10 +9,13 @@ module Lurker
|
|
9
9
|
included do
|
10
10
|
# _describe = self # RSpec::ExampleGroups::... # class
|
11
11
|
actions = [:get, :post, :put, :delete]
|
12
|
-
|
12
|
+
if defined?(ActionDispatch::Request::HTTP_METHODS) && ActionDispatch::Request::HTTP_METHODS.include?('PATCH')
|
13
|
+
actions << :patch
|
14
|
+
end
|
13
15
|
actions.each do |verb|
|
14
16
|
send(:define_method, "#{verb}_with_lurker") do |*params|
|
15
17
|
@__action, @__request_params = params
|
18
|
+
@__request_params ||= {}
|
16
19
|
|
17
20
|
send("#{verb}_without_lurker", @__action, @__request_params)
|
18
21
|
|
data/lib/lurker/endpoint.rb
CHANGED
data/lib/lurker/engine.rb
CHANGED
@@ -3,8 +3,10 @@ require 'lurker/server'
|
|
3
3
|
module Lurker
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
config.after_initialize do |app|
|
6
|
-
app.routes.
|
7
|
-
|
6
|
+
app.routes.append do
|
7
|
+
unless ::Rails.env.production? || app.routes.routes.map(&:app).any? { |e| e.is_a?(Class) && e.name.to_s.match(/Lurker::Rack/) }
|
8
|
+
mount Lurker::Server.to_rack(path: 'html'), at: "/#{Lurker::DEFAULT_URL_BASE}"
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -9,7 +9,10 @@ module Lurker
|
|
9
9
|
included do
|
10
10
|
# _describe = self # RSpec::ExampleGroups::... # class
|
11
11
|
actions = [:get, :post, :put, :delete]
|
12
|
-
|
12
|
+
if defined?(ActionDispatch::Request::HTTP_METHODS) && ActionDispatch::Request::HTTP_METHODS.include?('PATCH')
|
13
|
+
actions << :patch
|
14
|
+
end
|
15
|
+
|
13
16
|
actions.each do |verb|
|
14
17
|
send(:define_method, "#{verb}_with_lurker") do |*params|
|
15
18
|
@__action, @__request_params, @__env = params
|
@@ -18,12 +21,15 @@ module Lurker
|
|
18
21
|
@__query_params ||= {}
|
19
22
|
@__env ||= {}
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
if @__action.is_a?(Symbol)
|
25
|
+
unless @__example.metadata.described_class.is_a?(Class)
|
26
|
+
raise 'cannot determine request url: provide proper described class like: "describe MyController do"'
|
27
|
+
end
|
28
|
+
controller_name = @__example.metadata.described_class.name.tableize.gsub(/_controllers$/, '')
|
29
|
+
@__action = URI.parse(url_for({ controller: controller_name, action: @__action }.merge(@__request_params))).path
|
23
30
|
end
|
24
31
|
|
25
|
-
|
26
|
-
@__query_params.merge! Rack::Utils.parse_query URI.parse(@__action).query
|
32
|
+
@__query_params.merge! ::Rack::Utils.parse_query URI.parse(@__action).query
|
27
33
|
|
28
34
|
send("#{verb}_without_lurker", @__action, @__request_params, @__env)
|
29
35
|
|
data/lib/lurker/schema.rb
CHANGED
@@ -17,7 +17,7 @@ module Lurker
|
|
17
17
|
def initialize(json_schema_hash, extensions={})
|
18
18
|
@hash = json_schema_hash
|
19
19
|
@extensions = if extensions.blank? && @hash.has_key?(KEY)
|
20
|
-
@hash.delete(KEY)
|
20
|
+
@hash.delete(KEY) || {}
|
21
21
|
else
|
22
22
|
extensions
|
23
23
|
end
|
@@ -50,12 +50,22 @@ module Lurker
|
|
50
50
|
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
51
51
|
|
52
52
|
File.open(path, "w") do |file|
|
53
|
-
file.write(
|
54
|
-
KEY => Hash[@extensions.sort]
|
55
|
-
)))
|
53
|
+
file.write(to_yaml)
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
57
|
+
def to_yaml
|
58
|
+
YAML.dump(@hash.merge(
|
59
|
+
KEY => @extensions
|
60
|
+
))
|
61
|
+
end
|
62
|
+
|
63
|
+
def ordered!
|
64
|
+
@hash = Hash[@hash.sort]
|
65
|
+
@extensions = Hash[@extensions.sort]
|
66
|
+
self
|
67
|
+
end
|
68
|
+
|
59
69
|
protected
|
60
70
|
|
61
71
|
def serialized_for_diff
|
data/lib/lurker/server.rb
CHANGED
@@ -28,15 +28,15 @@ module Lurker
|
|
28
28
|
def self.to_rack(options = {})
|
29
29
|
default_path = options[:path] || Lurker::DEFAULT_SERVICE_PATH
|
30
30
|
|
31
|
-
Class.new(Sinatra::Base) do
|
31
|
+
cls = Class.new(Sinatra::Base) do
|
32
32
|
|
33
33
|
if !Rails.env.development? && (username, password = options.values_at(:username, :password)).all?(&:present?)
|
34
|
-
use Rack::Auth::Basic, "Protected Area" do |u, p|
|
34
|
+
use ::Rack::Auth::Basic, "Protected Area" do |u, p|
|
35
35
|
username == u && password == p
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
use Rack::Deflater
|
39
|
+
use ::Rack::Deflater
|
40
40
|
|
41
41
|
use TryStatic,
|
42
42
|
:root => "#{::Rails.root}/#{default_path}", # static files root dir
|
@@ -48,6 +48,8 @@ module Lurker
|
|
48
48
|
:try => ['.html', 'index.html', '/index.html'] # try these postfixes sequentially
|
49
49
|
|
50
50
|
end
|
51
|
+
Lurker.const_set("Rack_#{rand 10}_#{Time.now.to_i}", cls)
|
52
|
+
cls
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
data/lib/lurker/service.rb
CHANGED
@@ -11,17 +11,17 @@ class Lurker::Service
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(service_dir, service_name = nil)
|
14
|
-
@name = service_name
|
15
14
|
@opened_endpoints = []
|
16
15
|
@service_dir = File.expand_path(service_dir)
|
16
|
+
@service_filename = service_name
|
17
17
|
@schema = if persisted? && (schema = YAML.load_file(service_path)).is_a?(Hash)
|
18
18
|
Lurker::Schema.new(schema)
|
19
19
|
else
|
20
20
|
Lurker::Schema.new({
|
21
|
-
'name' =>
|
21
|
+
'name' => service_filename,
|
22
22
|
'basePath' => '',
|
23
23
|
'description' => '',
|
24
|
-
'domains' => {
|
24
|
+
'domains' => {}
|
25
25
|
})
|
26
26
|
end
|
27
27
|
end
|
@@ -31,7 +31,11 @@ class Lurker::Service
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def service_path
|
34
|
-
@service_path ||= "#{service_dir}/#{
|
34
|
+
@service_path ||= "#{service_dir}/#{service_filename}#{SUFFIX}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def service_filename
|
38
|
+
@service_filename ||= Pathname.new(Dir["#{service_dir}/*#{SUFFIX}"].first.to_s).basename.to_s.gsub(SUFFIX, '').presence || 'application'
|
35
39
|
end
|
36
40
|
|
37
41
|
def persist!
|
@@ -90,9 +94,7 @@ class Lurker::Service
|
|
90
94
|
end
|
91
95
|
|
92
96
|
def name
|
93
|
-
|
94
|
-
Pathname.new(Dir["#{service_dir}/*#{SUFFIX}"].first.to_s).basename.to_s.gsub(SUFFIX, '').presence ||
|
95
|
-
'application')
|
97
|
+
schema['name']
|
96
98
|
end
|
97
99
|
|
98
100
|
def base_path
|
data/lib/lurker/version.rb
CHANGED
data/lurker.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency("sinatra", "~> 1.4")
|
27
27
|
|
28
28
|
# testing
|
29
|
+
spec.add_development_dependency("psych", "~> 2.0")
|
29
30
|
spec.add_development_dependency("bundler", "~> 1.3")
|
30
31
|
spec.add_development_dependency("rails", "~> 4.1")
|
31
32
|
spec.add_development_dependency("rake", "~> 10.2")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Yaml dump' do
|
4
|
+
it 'dumps strings with slashes' do
|
5
|
+
hash = { "extensions" => { "path_info" => "/api/v1/users/1/repos/1" } }
|
6
|
+
expect(Psych.dump(hash)).to eq(
|
7
|
+
'---
|
8
|
+
extensions:
|
9
|
+
path_info: "/api/v1/users/1/repos/1"
|
10
|
+
'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lurker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Bokov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: psych
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -420,6 +434,7 @@ files:
|
|
420
434
|
- lib/lurker/version.rb
|
421
435
|
- lurker.gemspec
|
422
436
|
- spec/lurker/endpoint_spec.rb
|
437
|
+
- spec/lurker/yaml_spec.rb
|
423
438
|
- spec/spec_helper.rb
|
424
439
|
- templates/generate_stuff.rb
|
425
440
|
- templates/lurker_app.rb
|
@@ -463,5 +478,6 @@ test_files:
|
|
463
478
|
- features/step_definitions/additional_cli_steps.rb
|
464
479
|
- features/support/env.rb
|
465
480
|
- spec/lurker/endpoint_spec.rb
|
481
|
+
- spec/lurker/yaml_spec.rb
|
466
482
|
- spec/spec_helper.rb
|
467
483
|
has_rdoc:
|
metadata.gz.asc
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
Version: GnuPG v1
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/
|
11
|
-
=
|
5
|
+
iQEcBAABCgAGBQJTYSdDAAoJENcoxKfNVdjbTd0H/ikPlNf2LUQtakmpxDMxCZKo
|
6
|
+
iT3v87Ssz07yZcgt8wZDF64rVBZZ1yM2bssQftCLOvVqKGzXzlemwp7dO4m2hcBE
|
7
|
+
8QoeueyTieMo9gN+p2/sNk3RaMwsUy4X24Q1ZSUdBiez/K8QPnjSnSeReVHBwI3X
|
8
|
+
GDag9EdC+i79eTM+/06Ab5ReY4Wxn7w5pxRATWFrv4s0r3yElaOaARQQbH2RLe66
|
9
|
+
KCkKSmh6QVG3f08rRkvnXyx0CbpQqSIxz6jN696z1PfeWecRBs9LYfxRSM/0BgCW
|
10
|
+
KDSFDju69n2mNdGKNsOIicpguq8RNlG+7o3JzYyPru/4qEZfDS4uFsnZIuPxSfE=
|
11
|
+
=kKPC
|
12
12
|
-----END PGP SIGNATURE-----
|