digup 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmQzOTM0ZjFhYTgwMmQ2ZjQxZGI1YjMxN2FmMGIwNTRkZDcxNjUyMQ==
4
+ NzkxMGJjMmU4ZjAwYTI4NzVlMmI2NGFlM2JkZTk0MmVhMWMzYzIwNg==
5
5
  data.tar.gz: !binary |-
6
- ZmI3ZDM3MzkzYmFlODRjYjI2MTk4OWZjYTU1YjQ0ODczMmZkOTUzNA==
6
+ ZTgwMmUxN2E0YWZmOTRjMjQwOTdhYjZjMTRhOWE2MGZiMDQ1ZjhmOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTdlYjU4YTFmOGYyZDExNzY4YjI4NzNmZjg1ZDM2ODJjMWMyNjFjZWVkYmZk
10
- NzVkMTQxZmM5MjgzMDlkOGEwZDAzMDcxNzNmOTZkNmZjOWFiMzdhNDA5Yjhj
11
- MjdjMzMxY2Q1ZDEwN2I2ZmQzZDdmOTI0M2M3NjMxOTBkODhlMWY=
9
+ ODQwNmI4ODNmY2JjZWVkMWM3MGYzODc3ZTBhYTEyZjJmOGQ3NDMxMDgzNDU5
10
+ MjUzYTU1NzE0NDJmYmUwNzU3MzE4NmFiYzI0MzNhZmQxYzAzZWQwOWEzOTg0
11
+ Mzk1MDdiMDliZjE1YTlkNWRmMTk2MDY1NmJlNDhmMWZhMTNhN2M=
12
12
  data.tar.gz: !binary |-
13
- NDAyYzg0Y2ZkMTUwODBlNmNiMGE1YmM4ZjYzNjk3ZTdjYmJiMTQ0ZTIzYjc3
14
- Zjg1MzI1NGQ0ZjU5NTdlYzMxYzUzMGZlZmVlYWU5MDg1N2ZkMThmZTBkMjFl
15
- NDk1NjNhZTJkOGFmM2FlMjk5YTFlNDc3NDlkZDhkYTBhZTgxN2M=
13
+ ZjJhY2VhNGU1ZWY5NzlkOTJhYTZkYjFhODdjN2I5NzFlNWU1Zjg3YmU1NmNh
14
+ Nzc5NzA3ZGVjNGZmNTY2YWQxNmMxMzM0OTk5ZGM1OTY5NDAwZGQ4ZThhOGE3
15
+ MzJlM2U5NDNhMGQ0OGZlM2M0ZTY0YmZkMWQ0ZDliYTVmMjFiYmU=
data/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.5
2
+ Rails 4.2.0 support and corrected dyanamic method generation
3
+
4
+ # 0.0.4
5
+ Correction for javascript error undefined jsonResponse
6
+
1
7
  # 0.0.3
2
8
 
3
9
  - 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.
data/README.md CHANGED
@@ -55,9 +55,10 @@ You can configure digup to operate the way you want.
55
55
 
56
56
  Possible options for response type are :js, :json, :html
57
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
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.
59
+ In this case we need to specify response that server will send as digup_write second parameter
59
60
 
60
- eg) digup_log 'Print this', :html
61
+ eg) digup_write 'Print this', :html
61
62
 
62
63
  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
 
data/digup.gemspec CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
 
24
- spec.add_runtime_dependency 'rails', '>= 3.0.0', '< 4.2.0'
24
+ spec.add_runtime_dependency 'rails', '>= 3.0.0'
25
25
  end
@@ -9,4 +9,6 @@ class Object
9
9
  Digup.response_type = response_type
10
10
  end
11
11
 
12
+ alias :digup_log :digup_write
13
+
12
14
  end
data/lib/digup/logger.rb CHANGED
@@ -41,7 +41,7 @@ module Digup
41
41
  RequestResponseInfo.create(
42
42
  :request_method => @responder.request.request_method,
43
43
  :request_accepts => @responder.request.accepts,
44
- :response_type => @responder.response.content_type,
44
+ :response_type => @responder.content_type,
45
45
  :response_status => @responder.status,
46
46
  :params => @responder.request.filtered_parameters
47
47
  ).digup_logs.create(Digup.message_store)
data/lib/digup/rack.rb CHANGED
@@ -8,6 +8,7 @@ module Digup
8
8
 
9
9
  def call(env)
10
10
  responder = Responder.new(@app.call(env))
11
+ responder.request = ActionDispatch::Request.new(env)
11
12
  if Setting.enabled? && responder.valid?
12
13
  logger = Logger.new(responder)
13
14
  logger.log_all
@@ -2,17 +2,13 @@ module Digup
2
2
 
3
3
  class Responder
4
4
 
5
- attr_accessor :status, :headers, :response, :response_body
5
+ attr_accessor :status, :headers, :response, :response_body, :request
6
6
 
7
7
  def initialize(original_response)
8
8
  @original_response = original_response
9
9
  @status, @headers, @response = original_response
10
10
  end
11
11
 
12
- def request
13
- response.request
14
- end
15
-
16
12
  # Appends template to reponse depending on the settings
17
13
  def append_template_to_response(template)
18
14
  position = if response_body.include?('</body>')
@@ -69,14 +65,14 @@ module Digup
69
65
  end
70
66
 
71
67
  def can_handle_response?
72
- Setting.content_type_to_handle.include?(response.content_type)
68
+ Setting.content_type_to_handle.include?(content_type)
73
69
  end
74
70
 
75
71
  def html_response?
76
72
  if Digup.response_type.present?
77
73
  Digup.response_type == :html
78
74
  else
79
- response.content_type == 'text/html'
75
+ content_type == 'text/html'
80
76
  end
81
77
  end
82
78
 
@@ -84,7 +80,7 @@ module Digup
84
80
  if Digup.response_type.present?
85
81
  Digup.response_type == :js
86
82
  else
87
- response.content_type == 'text/javascript'
83
+ content_type == 'text/javascript'
88
84
  end
89
85
  end
90
86
 
@@ -92,10 +88,14 @@ module Digup
92
88
  if Digup.response_type.present?
93
89
  Digup.response_type == :json
94
90
  else
95
- response.content_type == 'application/json'
91
+ content_type == 'application/json'
96
92
  end
97
93
  end
98
94
 
95
+ def content_type
96
+ headers['Content-Type'].split(';').first
97
+ end
98
+
99
99
  end
100
100
 
101
101
  end
data/lib/digup/setting.rb CHANGED
@@ -14,20 +14,18 @@ module Digup
14
14
  class << self
15
15
  attr_accessor :options
16
16
 
17
- def build_functions
18
- RESPONSE_TYPE.each do |rt|
19
- self.class.send(:define_method, "handle_#{rt}?") { options[:response_type].include?(rt) }
20
- end
21
-
22
- LOG_TO.each do |lt|
23
- self.class.send(:define_method, "log_to_#{lt}?") { options[:log_to].include?(lt) }
24
- end
17
+ RESPONSE_TYPE.each do |rt|
18
+ define_method("handle_#{rt}?") { enabled? && options[:response_type].include?(rt) }
19
+ end
25
20
 
26
- BOOLEAN_SETTINGS.each do |s|
27
- self.class.send(:define_method, "#{s}?") { options[s] }
28
- end
21
+ LOG_TO.each do |lt|
22
+ define_method("log_to_#{lt}?") { enabled? && options[:log_to].include?(lt) }
29
23
  end
30
24
 
25
+ BOOLEAN_SETTINGS.each do |s|
26
+ define_method("#{s}?") { enabled? && options[s] }
27
+ end
28
+
31
29
  def enabled?
32
30
  @options.present?
33
31
  end
@@ -41,11 +39,9 @@ module Digup
41
39
  elsif options == :default
42
40
  @options = DEFAULT_SETTINGS
43
41
  end
44
- build_functions
45
42
  end
46
43
 
47
44
  def option_to_array(options, key)
48
- return DEFAULT_SETTINGS[key] unless options[key]
49
45
  if options[key].is_a? Array
50
46
  options[key]
51
47
  else
@@ -123,7 +123,7 @@ module Digup
123
123
  file_log += "Request method: #{responder.request.request_method} | "
124
124
  file_log += "Request accepts: #{responder.request.accepts}\n"
125
125
  file_log += "response status: #{responder.status} | "
126
- file_log += "response type: #{responder.response.content_type}\n"
126
+ file_log += "response type: #{responder.content_type}\n"
127
127
  file_log += "params: #{responder.request.filtered_parameters}"
128
128
  file_log += Digup.text_message
129
129
  file_log += "\n\n#{'=' * 180}\n\n"
data/lib/digup/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Digup
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  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
4
+ version: 0.0.5
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-22 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,9 +45,6 @@ dependencies:
45
45
  - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.0.0
48
- - - <
49
- - !ruby/object:Gem::Version
50
- version: 4.2.0
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -55,9 +52,6 @@ dependencies:
55
52
  - - ! '>='
56
53
  - !ruby/object:Gem::Version
57
54
  version: 3.0.0
58
- - - <
59
- - !ruby/object:Gem::Version
60
- version: 4.2.0
61
55
  description: Debug by printing data directly as html or in web console. Digup have
62
56
  diffrent logging mode file logging, db logging and logging debug data directly to
63
57
  console and html page. Digup can also be used as a logger