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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c23ba266af8e362dea8a252ee94b8f14ea674b04
4
- data.tar.gz: 1ad9a1c35537eef31a26556ce1d3089359c07438
3
+ metadata.gz: 759c089b37d5306a90c488465c6f2ba497954820
4
+ data.tar.gz: cf29d40f4b26ca075296059b967e587dacd46378
5
5
  SHA512:
6
- metadata.gz: 2e8e923956c0d9f084484ea0a91e007ca3f811b71c4f44c1b9dbd4fff2a84386d403e8306bd25ab3ae81e483c132948de4a72f49932cdf34bda9dce30dd9c03b
7
- data.tar.gz: b4ef7736521736cfa8d7c33c719e04b1772e27d840e7dc81380338af88d239ff5152eec7c2b7388929abf364e1eb32ae9c28f46c2460c9c43f38f8d5626fe4f8
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 if you need to change default configuration:
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.buffer_size = 50
28
- c.temp_directory = 'tmp'
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/project/10/reports
51
+ **Default:** https://watchdocs-api.herokuapp.com/api/v1/reports
52
52
 
53
- URL for exporting recorgings to your Watchdocs project. (Change 10 to a random number)
53
+ URL for exporting recorgings to your Watchdocs project.
54
54
 
55
- ### api_key
55
+ ### app_id
56
56
 
57
- **Default:** 8L9qh77q9570H0LIz90Aj00T5mcOHW1w
57
+ **No default value**
58
58
 
59
- API Key which you can get for your Watchdocs project in settings section.
59
+ AppID key which you can get for your Watchdocs project in settings section.
60
60
 
61
- ### api_secret
61
+ ### app_secret
62
62
 
63
- **Default:** G52uFXHPjyxRY3JdBIsw562uJ8bUdrE2
63
+ **No default value**
64
64
 
65
- API Secret which you can get for your Watchdocs project in settings section.
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
- :api_key,
10
- :api_secret
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/project/10/reports'
16
- c.api_key = '8L9qh77q9570H0LIz90Aj00T5mcOHW1w'
17
- c.api_secret = 'G52uFXHPjyxRY3JdBIsw562uJ8bUdrE2'
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).filter_data
94
- rescue JSON::ParserError
95
- 'Invalid JSON'
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).filter_data
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.api_key,
48
- password: Watchdocs::Rails.configuration.api_secret
47
+ username: Watchdocs::Rails.configuration.app_id,
48
+ password: Watchdocs::Rails.configuration.app_secret
49
49
  }
50
50
  end
51
51
  end
@@ -1,5 +1,5 @@
1
1
  module Watchdocs
2
2
  module Rails
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  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.5.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-03-21 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler