xing-dev-assets 0.0.1 → 1.0.0.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bdac05d590be2ce04b7efd3fa7c8db59a071bad
4
- data.tar.gz: a773c283f92f0270b5b8662664ef6c3dc1c01363
3
+ metadata.gz: 0a5a213af0b31ab1f2a6e4eb23b8db3f73eb5232
4
+ data.tar.gz: d6a085436093e3a9928e794106f320662ba73908
5
5
  SHA512:
6
- metadata.gz: 558d585aeb9dd486efe18d5100f507a6a5127e6445f08d50aa6f5036b85e42df599655e3af6da01fc7cf3768b0edd0e785822c4f705e911054994f9d42265e9f
7
- data.tar.gz: 6837a86dd89c7ede343d5e2b667ff5d05367d6b01375f572e687a7cebc909370553583fec6a124b7f12aa75a7e37b6ed5adfc0ec1f7a059b2a7691a4a3694e01
6
+ metadata.gz: 59c61bdc1f07acd20f8a084bf7e8e2e47296550e7f1c4e8fc2d816f68d04bb50df0bf588114f9f5303757bce45d36c1427607db3ea49f05ddc364ca4114692ba
7
+ data.tar.gz: 4486a77c59807b5a122d2068dc60e7399ba122b230cfcbb8e5c892a7e039c4fea63f2a27c4f7e0fd1e01999427910c2ca1199afb8466ccfe2d18132ab9950919
@@ -1,17 +1,22 @@
1
1
  module Xing
2
2
  module DevAssets
3
3
  class Dumper
4
- def initialize(app)
4
+ def initialize(app, log_target)
5
5
  require 'pp'
6
6
  @app = app
7
+ @log_target = log_target
7
8
  end
8
9
 
9
10
  def call(env)
11
+ @log_target.debug{ wrap("REQUEST", env.pretty_inspect)}
10
12
  res = @app.call(env)
11
- pp env
12
- pp res
13
+ @log_target.debug{ wrap("RESPONSE", res.pretty_inspect) }
13
14
  return res
14
15
  end
16
+
17
+ def wrap(thing, text)
18
+ ["#{thing} start", text.lines.map{|ln| " "+ln}.join("").chomp, "#{thing} end"].join("\n") + "\n"
19
+ end
15
20
  end
16
21
  end
17
22
  end
@@ -1,6 +1,7 @@
1
1
  require 'xing/dev-assets/cookie_setter'
2
2
  require 'xing/dev-assets/goto_param'
3
3
  require 'xing/dev-assets/logger'
4
+ require 'xing/dev-assets/dumper'
4
5
  require 'xing/dev-assets/empty_file'
5
6
  require 'xing/dev-assets/strip_incoming_cache_headers'
6
7
 
@@ -23,8 +24,9 @@ module Xing
23
24
  # (because this will log into a dir in the gem, but copied into subclass
24
25
  # will be relative to that file and therefore into the project)
25
26
  def log_root
26
- File.expand_path("../../log", __FILE__)
27
+ @log_root ||= File.expand_path("../../log", __FILE__)
27
28
  end
29
+ attr_writer :log_root
28
30
 
29
31
  def logpath_for_env
30
32
  File.join( log_root, "#{env}_static.log")
@@ -42,8 +44,38 @@ module Xing
42
44
  @env ||= ENV['RAILS_ENV'] || 'development'
43
45
  end
44
46
 
47
+ def log_level
48
+ @log_level ||= Logger::WARN
49
+ end
50
+
51
+ LEVEL_LOOKUP = {
52
+ :debug => Logger::DEBUG,
53
+ :info => Logger::INFO,
54
+ :warn => Logger::WARN,
55
+ :error => Logger::ERROR,
56
+ :fatal => Logger::FATAL,
57
+ :unknown => Logger::UNKNOWN
58
+ }.freeze
59
+ def log_level=(value)
60
+ @log_level =
61
+ case value
62
+ when Symbol
63
+ LEVEL_LOOKUP.fetch(value)
64
+ when *LEVEL_LOOKUP.values
65
+ value
66
+ else
67
+ warning "Unrecognized logger level: not in #{LEVEL_LOOKUP.keys.inspect} or #{LEVEL_LOOKUP.values.inspect}"
68
+ value
69
+ end
70
+ unless @logger.nil?
71
+ @logger.level = value
72
+ end
73
+ end
74
+
45
75
  def logger
46
- @logger ||= Logger.new(logpath_for_env)
76
+ @logger ||= Logger.new(logpath_for_env).tap do |logger|
77
+ logger.level = log_level
78
+ end
47
79
  end
48
80
 
49
81
  def report_startup
@@ -70,6 +102,10 @@ module Xing
70
102
  builder.use Rack::CommonLogger, logger
71
103
  end
72
104
 
105
+ def debug_dump
106
+ builder.use Dumper, logger
107
+ end
108
+
73
109
  def shortcut_livereload
74
110
  if env != "development"
75
111
  builder.map "/assets/livereload.js" do
@@ -94,10 +130,11 @@ module Xing
94
130
  end
95
131
 
96
132
  def setup_middleware
133
+ logging
134
+ debug_dump
97
135
  goto_redirect
98
136
  cookies
99
137
  disable_caching
100
- logging
101
138
  shortcut_livereload
102
139
  static_assets
103
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xing-dev-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0.pre.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -51,7 +51,7 @@ rdoc_options:
51
51
  - "--main"
52
52
  - doc/README
53
53
  - "--title"
54
- - xing-dev-assets-0.0.1 Documentation
54
+ - xing-dev-assets-1.0.0.pre.beta Documentation
55
55
  require_paths:
56
56
  - lib/
57
57
  required_ruby_version: !ruby/object:Gem::Requirement