digup 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Changelog.md +8 -0
- data/README.md +19 -1
- data/Todo.md +3 -0
- data/lib/digup/extension.rb +6 -1
- data/lib/digup/logger.rb +2 -2
- data/lib/digup/rack.rb +2 -2
- data/lib/digup/responder.rb +21 -7
- data/lib/digup/template.rb +14 -12
- data/lib/digup/version.rb +1 -1
- data/lib/digup.rb +6 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmQzOTM0ZjFhYTgwMmQ2ZjQxZGI1YjMxN2FmMGIwNTRkZDcxNjUyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmI3ZDM3MzkzYmFlODRjYjI2MTk4OWZjYTU1YjQ0ODczMmZkOTUzNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTdlYjU4YTFmOGYyZDExNzY4YjI4NzNmZjg1ZDM2ODJjMWMyNjFjZWVkYmZk
|
10
|
+
NzVkMTQxZmM5MjgzMDlkOGEwZDAzMDcxNzNmOTZkNmZjOWFiMzdhNDA5Yjhj
|
11
|
+
MjdjMzMxY2Q1ZDEwN2I2ZmQzZDdmOTI0M2M3NjMxOTBkODhlMWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDAyYzg0Y2ZkMTUwODBlNmNiMGE1YmM4ZjYzNjk3ZTdjYmJiMTQ0ZTIzYjc3
|
14
|
+
Zjg1MzI1NGQ0ZjU5NTdlYzMxYzUzMGZlZmVlYWU5MDg1N2ZkMThmZTBkMjFl
|
15
|
+
NDk1NjNhZTJkOGFmM2FlMjk5YTFlNDc3NDlkZDhkYTBhZTgxN2M=
|
data/Changelog.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# 0.0.3
|
2
|
+
|
3
|
+
- Added feature to specify type of response to be sent from the controllers action. This will help digup to append appropriate template. It can be used when 'script' request(i.e accepts in request header text/javascript, application/javascript) is made to the server and server returns html instead of javascript.
|
4
|
+
- Solved bugs in case when json was returned from the server
|
5
|
+
|
6
|
+
# 0.0.2
|
7
|
+
|
8
|
+
Initial working release
|
data/README.md
CHANGED
@@ -18,6 +18,13 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install digup
|
20
20
|
|
21
|
+
## Dependencies
|
22
|
+
Digup requires rails( 4.2 < version > 3.0). It also requires jquery for handling log for js and json request
|
23
|
+
|
24
|
+
## Note
|
25
|
+
- Digup modifies json when Digup is used to get json response. It appends data to json. If application is calculating number of object inside json data or doing other manipulation then the manipulation may get affected.
|
26
|
+
- If you are using firebug and 'track throw catch' is enable under script it may catch the exception throw. You can disable it so that it doesn't respond to exception already caught by Digup.
|
27
|
+
|
21
28
|
## Usage
|
22
29
|
|
23
30
|
Digup have several settings to be set to operate diffrently.
|
@@ -46,7 +53,18 @@ You can configure digup to operate the way you want.
|
|
46
53
|
|
47
54
|
eg) If it includes :json, then log will be appended to json response otherwise it would not be appended
|
48
55
|
|
49
|
-
Possible options for
|
56
|
+
Possible options for response type are :js, :json, :html
|
57
|
+
|
58
|
+
If request for 'script'(i.e 'accepts' header of request header is text/javascript, application/javascript) is made to a server and server returns html instead of javascript then Digup might not work as accepted. In this case we need to specify response that server will send as digup_log second parameter
|
59
|
+
|
60
|
+
eg) digup_log 'Print this', :html
|
61
|
+
|
62
|
+
We need to use second parameter only once and for subsequent use of digu_log method in same controller action we can be skip second parameter. We can also use method set_digup_response to set response type as
|
63
|
+
|
64
|
+
eg) set_digup_response :html
|
65
|
+
|
66
|
+
Note: Above condition may occur when we use jquery dataType: 'script' in ajax call and server returns html. We can also specify second parameter as :js or :json if 'accepts' parameter of request header is different from the server response type(i.e is 'accepts' in request header is html and server is sending json)
|
67
|
+
|
50
68
|
- log_to: It takes single value as symbol or array of symbol to specify multiple options. It sets places where the output should be logged.
|
51
69
|
|
52
70
|
Possible options
|
data/Todo.md
ADDED
data/lib/digup/extension.rb
CHANGED
data/lib/digup/logger.rb
CHANGED
@@ -30,10 +30,10 @@ module Digup
|
|
30
30
|
Template.console_template_for_html_response
|
31
31
|
when @responder.javascript_response?
|
32
32
|
Template.console_template_for_javascript_response
|
33
|
-
|
33
|
+
when !Setting.log_to_html_body?
|
34
34
|
new_json_template
|
35
35
|
end
|
36
|
-
@responder.append_template_to_response(template)
|
36
|
+
@responder.append_template_to_response(template) if template
|
37
37
|
end
|
38
38
|
|
39
39
|
# Add log to database. ActiveRecord required
|
data/lib/digup/rack.rb
CHANGED
@@ -13,10 +13,10 @@ module Digup
|
|
13
13
|
logger.log_all
|
14
14
|
responder.append_javascript_to_evaluate_json if Setting.handle_json? && responder.html_response?
|
15
15
|
responder.headers['Content-Length'] = responder.response_body.bytesize.to_s
|
16
|
-
responder.
|
16
|
+
responder.clear_parameters
|
17
17
|
responder.build_response
|
18
18
|
else
|
19
|
-
responder.
|
19
|
+
responder.clear_parameters
|
20
20
|
end
|
21
21
|
responder.build_response
|
22
22
|
end
|
data/lib/digup/responder.rb
CHANGED
@@ -18,7 +18,7 @@ module Digup
|
|
18
18
|
position = if response_body.include?('</body>')
|
19
19
|
response_body.rindex('</body>')
|
20
20
|
else
|
21
|
-
|
21
|
+
json_response? ? response_body.length - 1 : response_body.length
|
22
22
|
end
|
23
23
|
response_body.insert(position, (json_response? ? '' : "\n") + template )
|
24
24
|
end
|
@@ -56,10 +56,12 @@ module Digup
|
|
56
56
|
valid? ? [status, headers, [response_body]] : @original_response
|
57
57
|
end
|
58
58
|
|
59
|
-
# clears log message unless its not a redirection
|
59
|
+
# clears log message and reponse_type unless its not a redirection
|
60
60
|
# If its redirection log needs to be displayed on redirected page. So its not cleared
|
61
|
-
def
|
62
|
-
|
61
|
+
def clear_parameters
|
62
|
+
unless [301, 302].include?(status)
|
63
|
+
Digup.clear_all
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
def response_body
|
@@ -71,15 +73,27 @@ module Digup
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def html_response?
|
74
|
-
|
76
|
+
if Digup.response_type.present?
|
77
|
+
Digup.response_type == :html
|
78
|
+
else
|
79
|
+
response.content_type == 'text/html'
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
def javascript_response?
|
78
|
-
|
84
|
+
if Digup.response_type.present?
|
85
|
+
Digup.response_type == :js
|
86
|
+
else
|
87
|
+
response.content_type == 'text/javascript'
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
91
|
def json_response?
|
82
|
-
|
92
|
+
if Digup.response_type.present?
|
93
|
+
Digup.response_type == :json
|
94
|
+
else
|
95
|
+
response.content_type == 'application/json'
|
96
|
+
end
|
83
97
|
end
|
84
98
|
|
85
99
|
end
|
data/lib/digup/template.rb
CHANGED
@@ -90,19 +90,21 @@ module Digup
|
|
90
90
|
end
|
91
91
|
executable_javascript += console_template_for_javascript_response if Setting.log_to_console?
|
92
92
|
code = <<-CODE
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
<script type='text/javascript'>
|
94
|
+
$(document).bind("ajaxComplete", function(event, xhr, settings){
|
95
|
+
try {
|
96
|
+
var jsonResponse = JSON.parse(xhr.responseText);
|
97
|
+
} catch(e) {}
|
98
|
+
if (typeof jsonResponse !== 'undefined') {
|
99
|
+
if ($.isArray(jsonResponse)) {
|
100
|
+
digupData = jsonResponse[jsonResponse.length - 1].digup
|
101
|
+
} else {
|
102
|
+
digupData = jsonResponse.digup
|
103
|
+
}
|
104
|
+
#{executable_javascript}
|
101
105
|
}
|
102
|
-
|
103
|
-
|
104
|
-
});
|
105
|
-
</script>
|
106
|
+
});
|
107
|
+
</script>
|
106
108
|
CODE
|
107
109
|
end
|
108
110
|
|
data/lib/digup/version.rb
CHANGED
data/lib/digup.rb
CHANGED
@@ -9,7 +9,7 @@ require 'digup/extension'
|
|
9
9
|
module Digup
|
10
10
|
|
11
11
|
class << self
|
12
|
-
attr_accessor :message_store
|
12
|
+
attr_accessor :message_store, :response_type
|
13
13
|
|
14
14
|
def message_store
|
15
15
|
@message_store ||= []
|
@@ -63,6 +63,11 @@ module Digup
|
|
63
63
|
def cursor_info?(record)
|
64
64
|
Setting.cursor_info? && record[:cursor_info]
|
65
65
|
end
|
66
|
+
|
67
|
+
def clear_all
|
68
|
+
Digup.message_store.clear
|
69
|
+
Digup.response_type = nil
|
70
|
+
end
|
66
71
|
end
|
67
72
|
|
68
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: digup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rohan Pujari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,10 +68,12 @@ extensions: []
|
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
|
+
- Changelog.md
|
71
72
|
- Gemfile
|
72
73
|
- LICENSE.txt
|
73
74
|
- README.md
|
74
75
|
- Rakefile
|
76
|
+
- Todo.md
|
75
77
|
- digup.gemspec
|
76
78
|
- lib/digup.rb
|
77
79
|
- lib/digup/digup_railtie.rb
|