watchdocs-rails 0.5.0 → 0.6.0
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
- data/README.md +14 -14
- data/lib/watchdocs/rails/configuration.rb +9 -5
- data/lib/watchdocs/rails/middleware.rb +13 -8
- data/lib/watchdocs/rails/recordings/exporter.rb +2 -2
- data/lib/watchdocs/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 759c089b37d5306a90c488465c6f2ba497954820
|
4
|
+
data.tar.gz: cf29d40f4b26ca075296059b967e587dacd46378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da742003e254f774aba12748d588332536a22a2bc368568108b86c1c316470bc921f0d71701cf3a543c43ee2b1f912a7a321a7136cd8c6a6d9560262566a6acf
|
7
|
+
data.tar.gz: 919006c6c34e2301c7954d32c7379c4139030ae306685abfe486df334430be4338b3527e888e8e0cb5975dd8001d758fb2c48a4a7f0e29c906001a9e6cdf8846
|
data/README.md
CHANGED
@@ -20,18 +20,18 @@ bundle
|
|
20
20
|
|
21
21
|
## Configuration
|
22
22
|
|
23
|
-
Create `config/initializers/watchdocs.rb` and configure the gem
|
23
|
+
Create `config/initializers/watchdocs.rb` and configure the gem with your project credentials:
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
Watchdocs::Rails.configure do |c|
|
27
|
-
c.
|
28
|
-
c.
|
29
|
-
c.export_url = 'https://watchdocs-api.herokuapp.com/api/v1/project/10/reports'
|
30
|
-
c.api_key = '8L9qh77q9570H0LIz90Aj00T5mcOHW1w'
|
31
|
-
c.api_secret = 'G52uFXHPjyxRY3JdBIsw562uJ8bUdrE2'
|
27
|
+
c.app_id = 'YourAPPid'
|
28
|
+
c.app_secret = 'YourAPPsecret'
|
32
29
|
end
|
33
30
|
```
|
34
31
|
|
32
|
+
You can get them from your project's Settings page.
|
33
|
+
All configuration settings are listed below.
|
34
|
+
|
35
35
|
### buffer_size
|
36
36
|
|
37
37
|
**Default:** 50
|
@@ -48,21 +48,21 @@ Directory to store temporary file with recordings.
|
|
48
48
|
|
49
49
|
### export_url
|
50
50
|
|
51
|
-
**Default:** https://watchdocs-api.herokuapp.com/api/v1/
|
51
|
+
**Default:** https://watchdocs-api.herokuapp.com/api/v1/reports
|
52
52
|
|
53
|
-
URL for exporting recorgings to your Watchdocs project.
|
53
|
+
URL for exporting recorgings to your Watchdocs project.
|
54
54
|
|
55
|
-
###
|
55
|
+
### app_id
|
56
56
|
|
57
|
-
**
|
57
|
+
**No default value**
|
58
58
|
|
59
|
-
|
59
|
+
AppID key which you can get for your Watchdocs project in settings section.
|
60
60
|
|
61
|
-
###
|
61
|
+
### app_secret
|
62
62
|
|
63
|
-
**
|
63
|
+
**No default value**
|
64
64
|
|
65
|
-
|
65
|
+
App Secret key which you can get for your Watchdocs project in settings section.
|
66
66
|
|
67
67
|
## Usage
|
68
68
|
|
@@ -6,15 +6,19 @@ module Watchdocs
|
|
6
6
|
configurable :buffer_size,
|
7
7
|
:temp_directory,
|
8
8
|
:export_url,
|
9
|
-
:
|
10
|
-
:
|
9
|
+
:app_id,
|
10
|
+
:app_secret
|
11
11
|
|
12
12
|
configuration_defaults do |c|
|
13
13
|
c.buffer_size = 50
|
14
14
|
c.temp_directory = 'tmp'
|
15
|
-
c.export_url = 'https://watchdocs-api.herokuapp.com/api/v1/
|
16
|
-
|
17
|
-
|
15
|
+
c.export_url = 'https://watchdocs-api.herokuapp.com/api/v1/reports'
|
16
|
+
end
|
17
|
+
|
18
|
+
not_configured do |prop|
|
19
|
+
warn :not_configured,
|
20
|
+
"You need to configure #{prop} with
|
21
|
+
credentials from your project Settings page."
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -84,28 +84,33 @@ module Watchdocs
|
|
84
84
|
|
85
85
|
def body_string(body)
|
86
86
|
body_string = ''
|
87
|
-
body.each { |line| body_string += line }
|
87
|
+
body.each { |line| body_string += line } if body
|
88
88
|
body_string
|
89
89
|
end
|
90
90
|
|
91
91
|
def parse_response_body(body)
|
92
92
|
return if body.empty?
|
93
|
-
JSON.parse(body)
|
94
|
-
rescue JSON::ParserError
|
95
|
-
|
93
|
+
filter_body(JSON.parse(body))
|
94
|
+
rescue JSON::ParserError => e
|
95
|
+
{ watchdocs_error: "Invalid JSON data: #{e.message}" }
|
96
|
+
rescue StandardError
|
97
|
+
{ watchdocs_error: 'Response body format not supported' }
|
96
98
|
end
|
97
99
|
|
98
100
|
def parse_request_body(body)
|
99
101
|
return if body.empty?
|
100
|
-
JSON.parse(body)
|
102
|
+
filter_body(JSON.parse(body))
|
101
103
|
rescue JSON::ParserError
|
102
104
|
begin
|
103
|
-
Rack::Utils.parse_nested_query(body)
|
104
|
-
.filter_data
|
105
|
+
filter_body(Rack::Utils.parse_nested_query(body))
|
105
106
|
rescue StandardError
|
106
|
-
'Request body format not supported'
|
107
|
+
{ watchdocs_error: 'Request body format not supported' }
|
107
108
|
end
|
108
109
|
end
|
110
|
+
|
111
|
+
def filter_body(body)
|
112
|
+
body.is_a?(Enumerable) ? body.filter_data : body
|
113
|
+
end
|
109
114
|
end
|
110
115
|
end
|
111
116
|
end
|
@@ -44,8 +44,8 @@ module Watchdocs
|
|
44
44
|
|
45
45
|
def api_auth
|
46
46
|
{
|
47
|
-
username: Watchdocs::Rails.configuration.
|
48
|
-
password: Watchdocs::Rails.configuration.
|
47
|
+
username: Watchdocs::Rails.configuration.app_id,
|
48
|
+
password: Watchdocs::Rails.configuration.app_secret
|
49
49
|
}
|
50
50
|
end
|
51
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watchdocs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mazikwyry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|