inversion 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # vim: set noet nosta sw=4 ts=4 :
3
3
 
4
+ require 'loggability'
5
+
4
6
  require 'inversion' unless defined?( Inversion )
5
7
  require 'inversion/template' unless defined?( Inversion::Template )
6
8
 
@@ -14,10 +16,13 @@ require 'inversion/mixins'
14
16
  # in a gem of your own, put them into a directory named 'inversion/template' and
15
17
  # name the files <tt><tagname>tag.rb</tt> and the classes <tagname.capitalize>Tag.
16
18
  class Inversion::Template::Tag < Inversion::Template::Node
17
- extend Inversion::MethodUtilities
18
- include Inversion::Loggable,
19
- Inversion::AbstractClass
19
+ extend Loggability,
20
+ Inversion::MethodUtilities
21
+ include Inversion::AbstractClass
22
+
20
23
 
24
+ # Loggability API -- set up logging through the Inversion module's logger
25
+ log_to :inversion
21
26
 
22
27
  # The glob pattern for matching template tag plugins
23
28
  TAG_PLUGIN_PATTERN = 'inversion/template/*tag.rb'
@@ -5,7 +5,6 @@ require 'inversion/template/node'
5
5
 
6
6
  # Inversion text node class -- container for static content in templates between tags.
7
7
  class Inversion::Template::TextNode < Inversion::Template::Node
8
- include Inversion::Loggable
9
8
 
10
9
  ### Create a new TextNode with the specified +source+.
11
10
  def initialize( body, linenum=nil, colnum=nil )
@@ -18,8 +18,7 @@ require 'inversion/template/elsetag'
18
18
  # <?unless obj.method ?>...<?end?>
19
19
  #
20
20
  class Inversion::Template::UnlessTag < Inversion::Template::AttrTag
21
- include Inversion::Loggable,
22
- Inversion::Template::ContainerTag
21
+ include Inversion::Template::ContainerTag
23
22
 
24
23
  # Inherits AttrTag's tag patterns
25
24
 
@@ -14,10 +14,8 @@ require 'inversion/template/tag'
14
14
  # == Example
15
15
  #
16
16
  # <?yield ?>
17
- #
17
+ #
18
18
  class Inversion::Template::YieldTag < Inversion::Template::Tag
19
- include Inversion::Loggable
20
-
21
19
 
22
20
  ######
23
21
  public
@@ -18,40 +18,6 @@ require 'inversion/mixins'
18
18
 
19
19
  describe Inversion, "mixins" do
20
20
 
21
- describe Inversion::Loggable do
22
- before(:each) do
23
- @logfile = StringIO.new('')
24
- Inversion.logger = Logger.new( @logfile )
25
-
26
- @test_class = Class.new do
27
- include Inversion::Loggable
28
-
29
- def log_test_message( level, msg )
30
- self.log.send( level, msg )
31
- end
32
-
33
- def logdebug_test_message( msg )
34
- self.log_debug.debug( msg )
35
- end
36
- end
37
- @obj = @test_class.new
38
- end
39
-
40
-
41
- it "is able to output to the log via its #log method" do
42
- @obj.log_test_message( :debug, "debugging message" )
43
- @logfile.rewind
44
- @logfile.read.should =~ /debugging message/
45
- end
46
-
47
- it "is able to output to the log via its #log_debug method" do
48
- @obj.logdebug_test_message( "sexydrownwatch" )
49
- @logfile.rewind
50
- @logfile.read.should =~ /sexydrownwatch/
51
- end
52
- end
53
-
54
-
55
21
  describe Inversion::HashUtilities do
56
22
  it "includes a function for stringifying Hash keys" do
57
23
  testhash = {
@@ -17,14 +17,10 @@ require 'inversion'
17
17
  describe Inversion do
18
18
 
19
19
  before( :all ) do
20
- @original_logger = Inversion.default_logger
21
- @original_log_formatter = Inversion.default_log_formatter
22
20
  setup_logging( :fatal )
23
21
  end
24
22
 
25
23
  after( :each ) do
26
- Inversion.default_logger = @original_logger
27
- Inversion.default_log_formatter = @original_log_formatter
28
24
  reset_logging()
29
25
  end
30
26
 
@@ -44,52 +40,5 @@ describe Inversion do
44
40
  end
45
41
  end
46
42
 
47
-
48
- describe " logging subsystem" do
49
- before(:each) do
50
- Inversion.reset_logger
51
- end
52
-
53
- after(:each) do
54
- Inversion.reset_logger
55
- end
56
-
57
-
58
- it "knows if its default logger is replaced" do
59
- Inversion.reset_logger
60
- Inversion.should be_using_default_logger
61
- Inversion.logger = Logger.new( $stderr )
62
- Inversion.should_not be_using_default_logger
63
- end
64
-
65
- it "has the default logger instance after being reset" do
66
- Inversion.logger.should equal( Inversion.default_logger )
67
- end
68
-
69
- it "has the default log formatter instance after being reset" do
70
- Inversion.logger.formatter.should equal( Inversion.default_log_formatter )
71
- end
72
-
73
- end
74
-
75
-
76
- describe " logging subsystem with new defaults" do
77
- it "uses the new defaults when the logging subsystem is reset" do
78
- logger = double( "dummy logger" )
79
- formatter = double( "dummy logger" )
80
-
81
- Inversion.default_logger = logger
82
- Inversion.default_log_formatter = formatter
83
-
84
- logger.should_receive( :formatter= ).with( formatter )
85
- logger.should_receive( :level= ).with( Logger::WARN )
86
-
87
- Inversion.reset_logger
88
- Inversion.logger.should equal( logger )
89
- end
90
-
91
- end
92
-
93
-
94
43
  end
95
44
 
data/spec/lib/helpers.rb CHANGED
@@ -25,78 +25,16 @@ if ENV['COVERAGE']
25
25
  end
26
26
 
27
27
  require 'rspec'
28
+ require 'loggability'
28
29
 
29
30
  require 'inversion'
30
31
  require 'spec/lib/constants'
31
32
 
32
- ### IRb.start_session, courtesy of Joel VanderWerf in [ruby-talk:42437].
33
- require 'irb'
34
- require 'irb/completion'
35
-
36
-
37
- module IRB # :nodoc:
38
- def self.start_session( obj )
39
- unless @__initialized
40
- args = ARGV
41
- ARGV.replace( ARGV.dup )
42
- IRB.setup( nil )
43
- ARGV.replace( args )
44
- @__initialized = true
45
- end
46
-
47
- workspace = WorkSpace.new( obj )
48
- irb = Irb.new( workspace )
49
-
50
- @CONF[:IRB_RC].call( irb.context ) if @CONF[:IRB_RC]
51
- @CONF[:MAIN_CONTEXT] = irb.context
52
-
53
- begin
54
- prevhandler = Signal.trap( 'INT' ) do
55
- irb.signal_handle
56
- end
57
-
58
- catch( :IRB_EXIT ) do
59
- irb.eval_input
60
- end
61
- ensure
62
- Signal.trap( 'INT', prevhandler )
63
- end
64
-
65
- end
66
- end
67
-
68
33
 
69
34
  ### RSpec helper functions.
70
35
  module Inversion::SpecHelpers
71
36
  include Inversion::TestConstants
72
37
 
73
- class ArrayLogger
74
- ### Create a new ArrayLogger that will append content to +array+.
75
- def initialize( array )
76
- @array = array
77
- end
78
-
79
- ### Write the specified +message+ to the array.
80
- def write( message )
81
- @array << message
82
- end
83
-
84
- ### No-op -- this is here just so Logger doesn't complain
85
- def close; end
86
-
87
- end # class ArrayLogger
88
-
89
-
90
- unless defined?( LEVEL )
91
- LEVEL = {
92
- :debug => Logger::DEBUG,
93
- :info => Logger::INFO,
94
- :warn => Logger::WARN,
95
- :error => Logger::ERROR,
96
- :fatal => Logger::FATAL,
97
- }
98
- end
99
-
100
38
  ###############
101
39
  module_function
102
40
  ###############
@@ -109,29 +47,25 @@ module Inversion::SpecHelpers
109
47
 
110
48
  ### Reset the logging subsystem to its default state.
111
49
  def reset_logging
112
- Inversion.reset_logger
50
+ Loggability.formatter = nil
51
+ Loggability.output_to( $stderr )
52
+ Loggability.level = :fatal
113
53
  end
114
54
 
115
55
 
116
56
  ### Alter the output of the default log formatter to be pretty in SpecMate output
117
- def setup_logging( level=Logger::FATAL )
118
-
119
- # Turn symbol-style level config into Logger's expected Fixnum level
120
- if Inversion::Logging::LOG_LEVELS.key?( level.to_s )
121
- level = Inversion::Logging::LOG_LEVELS[ level.to_s ]
122
- end
123
-
124
- logger = Logger.new( $stderr )
125
- Inversion.logger = logger
126
- Inversion.logger.level = level
57
+ def setup_logging( level=:fatal )
127
58
 
128
59
  # Only do this when executing from a spec in TextMate
129
60
  if ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
130
- Thread.current['logger-output'] = []
131
- logdevice = ArrayLogger.new( Thread.current['logger-output'] )
132
- Inversion.logger = Logger.new( logdevice )
133
- # Inversion.logger.level = level
134
- Inversion.logger.formatter = Inversion::Logging::HtmlFormatter.new( logger )
61
+ $stderr.puts "Setting up HTML logs."
62
+ logarray = []
63
+ Thread.current['logger-output'] = logarray
64
+ Loggability.output_to( logarray )
65
+ Loggability.format_as( :html )
66
+ Loggability.level = :debug
67
+ else
68
+ Loggability.level = level
135
69
  end
136
70
  end
137
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -37,11 +37,27 @@ cert_chain:
37
37
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
38
38
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
39
39
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
40
- date: 2012-04-24 00:00:00.000000000 Z
40
+ date: 2012-05-07 00:00:00.000000000 Z
41
41
  dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: loggability
44
+ requirement: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '0.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: '0.0'
42
58
  - !ruby/object:Gem::Dependency
43
59
  name: hoe-mercurial
44
- requirement: &70266679150500 !ruby/object:Gem::Requirement
60
+ requirement: !ruby/object:Gem::Requirement
45
61
  none: false
46
62
  requirements:
47
63
  - - ~>
@@ -49,10 +65,15 @@ dependencies:
49
65
  version: 1.4.0
50
66
  type: :development
51
67
  prerelease: false
52
- version_requirements: *70266679150500
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ version: 1.4.0
53
74
  - !ruby/object:Gem::Dependency
54
75
  name: hoe-manualgen
55
- requirement: &70266679150000 !ruby/object:Gem::Requirement
76
+ requirement: !ruby/object:Gem::Requirement
56
77
  none: false
57
78
  requirements:
58
79
  - - ~>
@@ -60,10 +81,15 @@ dependencies:
60
81
  version: 0.3.0
61
82
  type: :development
62
83
  prerelease: false
63
- version_requirements: *70266679150000
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.0
64
90
  - !ruby/object:Gem::Dependency
65
91
  name: hoe-highline
66
- requirement: &70266679149420 !ruby/object:Gem::Requirement
92
+ requirement: !ruby/object:Gem::Requirement
67
93
  none: false
68
94
  requirements:
69
95
  - - ~>
@@ -71,10 +97,15 @@ dependencies:
71
97
  version: 0.1.0
72
98
  type: :development
73
99
  prerelease: false
74
- version_requirements: *70266679149420
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: 0.1.0
75
106
  - !ruby/object:Gem::Dependency
76
107
  name: rdoc
77
- requirement: &70266679148880 !ruby/object:Gem::Requirement
108
+ requirement: !ruby/object:Gem::Requirement
78
109
  none: false
79
110
  requirements:
80
111
  - - ~>
@@ -82,10 +113,15 @@ dependencies:
82
113
  version: '3.10'
83
114
  type: :development
84
115
  prerelease: false
85
- version_requirements: *70266679148880
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: '3.10'
86
122
  - !ruby/object:Gem::Dependency
87
123
  name: rspec
88
- requirement: &70266679148440 !ruby/object:Gem::Requirement
124
+ requirement: !ruby/object:Gem::Requirement
89
125
  none: false
90
126
  requirements:
91
127
  - - ~>
@@ -93,10 +129,15 @@ dependencies:
93
129
  version: '2.8'
94
130
  type: :development
95
131
  prerelease: false
96
- version_requirements: *70266679148440
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ version: '2.8'
97
138
  - !ruby/object:Gem::Dependency
98
139
  name: tilt
99
- requirement: &70266679147840 !ruby/object:Gem::Requirement
140
+ requirement: !ruby/object:Gem::Requirement
100
141
  none: false
101
142
  requirements:
102
143
  - - ~>
@@ -104,10 +145,15 @@ dependencies:
104
145
  version: '1.3'
105
146
  type: :development
106
147
  prerelease: false
107
- version_requirements: *70266679147840
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: '1.3'
108
154
  - !ruby/object:Gem::Dependency
109
155
  name: sinatra
110
- requirement: &70266679147360 !ruby/object:Gem::Requirement
156
+ requirement: !ruby/object:Gem::Requirement
111
157
  none: false
112
158
  requirements:
113
159
  - - ~>
@@ -115,10 +161,15 @@ dependencies:
115
161
  version: '1.2'
116
162
  type: :development
117
163
  prerelease: false
118
- version_requirements: *70266679147360
164
+ version_requirements: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ~>
168
+ - !ruby/object:Gem::Version
169
+ version: '1.2'
119
170
  - !ruby/object:Gem::Dependency
120
171
  name: rack-test
121
- requirement: &70266679146920 !ruby/object:Gem::Requirement
172
+ requirement: !ruby/object:Gem::Requirement
122
173
  none: false
123
174
  requirements:
124
175
  - - ~>
@@ -126,10 +177,15 @@ dependencies:
126
177
  version: '0.6'
127
178
  type: :development
128
179
  prerelease: false
129
- version_requirements: *70266679146920
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ~>
184
+ - !ruby/object:Gem::Version
185
+ version: '0.6'
130
186
  - !ruby/object:Gem::Dependency
131
187
  name: simplecov
132
- requirement: &70266679146420 !ruby/object:Gem::Requirement
188
+ requirement: !ruby/object:Gem::Requirement
133
189
  none: false
134
190
  requirements:
135
191
  - - ~>
@@ -137,10 +193,15 @@ dependencies:
137
193
  version: '0.4'
138
194
  type: :development
139
195
  prerelease: false
140
- version_requirements: *70266679146420
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ none: false
198
+ requirements:
199
+ - - ~>
200
+ - !ruby/object:Gem::Version
201
+ version: '0.4'
141
202
  - !ruby/object:Gem::Dependency
142
203
  name: trollop
143
- requirement: &70266679145640 !ruby/object:Gem::Requirement
204
+ requirement: !ruby/object:Gem::Requirement
144
205
  none: false
145
206
  requirements:
146
207
  - - ~>
@@ -148,10 +209,15 @@ dependencies:
148
209
  version: '1.16'
149
210
  type: :development
150
211
  prerelease: false
151
- version_requirements: *70266679145640
212
+ version_requirements: !ruby/object:Gem::Requirement
213
+ none: false
214
+ requirements:
215
+ - - ~>
216
+ - !ruby/object:Gem::Version
217
+ version: '1.16'
152
218
  - !ruby/object:Gem::Dependency
153
219
  name: highline
154
- requirement: &70266679160900 !ruby/object:Gem::Requirement
220
+ requirement: !ruby/object:Gem::Requirement
155
221
  none: false
156
222
  requirements:
157
223
  - - ~>
@@ -159,10 +225,15 @@ dependencies:
159
225
  version: '1.6'
160
226
  type: :development
161
227
  prerelease: false
162
- version_requirements: *70266679160900
228
+ version_requirements: !ruby/object:Gem::Requirement
229
+ none: false
230
+ requirements:
231
+ - - ~>
232
+ - !ruby/object:Gem::Version
233
+ version: '1.6'
163
234
  - !ruby/object:Gem::Dependency
164
235
  name: sysexits
165
- requirement: &70266679159920 !ruby/object:Gem::Requirement
236
+ requirement: !ruby/object:Gem::Requirement
166
237
  none: false
167
238
  requirements:
168
239
  - - ~>
@@ -170,10 +241,15 @@ dependencies:
170
241
  version: '1.0'
171
242
  type: :development
172
243
  prerelease: false
173
- version_requirements: *70266679159920
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ none: false
246
+ requirements:
247
+ - - ~>
248
+ - !ruby/object:Gem::Version
249
+ version: '1.0'
174
250
  - !ruby/object:Gem::Dependency
175
251
  name: hoe
176
- requirement: &70266679159060 !ruby/object:Gem::Requirement
252
+ requirement: !ruby/object:Gem::Requirement
177
253
  none: false
178
254
  requirements:
179
255
  - - ~>
@@ -181,7 +257,12 @@ dependencies:
181
257
  version: '3.0'
182
258
  type: :development
183
259
  prerelease: false
184
- version_requirements: *70266679159060
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ none: false
262
+ requirements:
263
+ - - ~>
264
+ - !ruby/object:Gem::Version
265
+ version: '3.0'
185
266
  description: ! 'Inversion is a templating system for Ruby. It uses the "Inversion
186
267
  of Control"
187
268
 
@@ -209,7 +290,6 @@ files:
209
290
  - bin/inversion
210
291
  - lib/inversion.rb
211
292
  - lib/inversion/exceptions.rb
212
- - lib/inversion/logging.rb
213
293
  - lib/inversion/mixins.rb
214
294
  - lib/inversion/monkeypatches.rb
215
295
  - lib/inversion/parser.rb
@@ -245,7 +325,6 @@ files:
245
325
  - lib/inversion/template/yieldtag.rb
246
326
  - lib/inversion/tilt.rb
247
327
  - spec/data/sinatra/hello.inversion
248
- - spec/inversion/logging_spec.rb
249
328
  - spec/inversion/mixins_spec.rb
250
329
  - spec/inversion/monkeypatches_spec.rb
251
330
  - spec/inversion/parser_spec.rb
@@ -309,7 +388,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
388
  version: '0'
310
389
  requirements: []
311
390
  rubyforge_project: inversion
312
- rubygems_version: 1.8.16
391
+ rubygems_version: 1.8.24
313
392
  signing_key:
314
393
  specification_version: 3
315
394
  summary: Inversion is a templating system for Ruby