assert-view 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assert-view (0.5.0)
4
+ assert-view (0.6.0)
5
5
  ansi (~> 1.3)
6
- undies (~> 2.0)
7
6
 
8
7
  GEM
9
8
  remote: http://rubygems.org/
10
9
  specs:
11
- ansi (1.4.1)
10
+ ansi (1.4.2)
12
11
  assert (0.7.3)
13
12
  assert-view (~> 0.5)
14
13
  rake (0.9.2)
15
- undies (2.0.0)
16
14
 
17
15
  PLATFORMS
18
16
  ruby
@@ -54,7 +54,7 @@ All view initializers take two things at minimum:
54
54
  The suite reader provides access to the suite of tests that will be or has been run. Use this reader to do things like count tests or test results, iterate through the tests and display detailed results, etc. This reader provides all the model data needed to render your view.
55
55
 
56
56
  === The Renderer
57
- The view renderer provided by the base class uses Undies (https://github.com/kelredd/undies) to define and render view templates. It mixes in a 'render' method to the base view that handles creating an Undies::Template from the view's template definition and wiring up the necessary runner callbacks.
57
+ The view renderer provided by the base class defines and renders view templates. It mixes in a 'render' method to the base view that handles creating a Template object from the view's template definition and wiring up the necessary runner callbacks.
58
58
 
59
59
  === Utilities
60
60
  The base class provides a few utilities for rendering views:
@@ -87,7 +87,7 @@ In addition, the DefaultView specifies a few options of its own:
87
87
  Use options in your views to override the base default options or to define your own for tweaking behavior and customization.
88
88
 
89
89
  === 2 - Template / Template Helpers
90
- The base class provides a 'template' class method. Use this method to define an Undies template to render your view. Check out Undies for details on how to create an Undies template. Templates are given two locals to work with:
90
+ The base class provides a 'template' class method. Use this method to define template source to render your view. Templates are given two locals to work with:
91
91
  * *view*: this local refers to the instance of the view class. Use it to get data or run logic.
92
92
  * *runner*: this is a block used to callback to Assert's runner and run the tests. Pass this local to the base 'run_tests' method to control when (in rendering your view) the tests are run. Optionally pass a block to 'run_tests' that will be called each time a new result is generated by the running tests. Use this to render live runtime result data.
93
93
 
@@ -113,7 +113,7 @@ TODO: put in guidlines for submitting new views...
113
113
 
114
114
  == License
115
115
 
116
- Copyright (c) 2011 Kelly Redding and Team Insight
116
+ Copyright (c) 2011-Present Kelly Redding and Team Insight
117
117
 
118
118
  Permission is hereby granted, free of charge, to any person
119
119
  obtaining a copy of this software and associated documentation
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Assert::View::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Kelly Redding"]
10
- s.email = ["kelly@kelredd.com"]
10
+ s.email = ["kelly@kellyredding.com"]
11
11
  s.homepage = "http://github.com/teaminsight/assert-view"
12
12
  s.summary = %q{A collection of views for use in the Assert testing framework}
13
13
  s.description = %q{A collection of views for use in the Assert testing framework}
@@ -21,5 +21,4 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency("assert")
22
22
 
23
23
  s.add_dependency("ansi", ["~> 1.3"])
24
- s.add_dependency("undies", ["~> 2.0"])
25
24
  end
@@ -4,9 +4,7 @@ require 'assert/options'
4
4
  module Assert::View
5
5
 
6
6
  # this module is mixed in to the Assert::View::Base class
7
- # it use Undies to define and render view templates
8
7
  module Renderer
9
- require 'undies'
10
8
 
11
9
  def self.included(receiver)
12
10
  receiver.send(:extend, ClassMethods)
@@ -15,23 +13,40 @@ module Assert::View
15
13
  # define rendering template class to use for rendering
16
14
  # need to overwrite the '_' and '__' meths to add trailing newlines
17
15
  # b/c streaming output doesn't add any whitespace
18
- class Template < ::Undies::Template
16
+ class Template
19
17
 
20
- def _(data="", nl=true); super(data.to_s + (nl ? "\n" : "")); end
21
- def __(data="", nl=true); super(data.to_s + (nl ? "\n" : "")); end
18
+ def initialize(*args)
19
+ # setup a node stack with the given output obj
20
+ @io = args.pop
21
+
22
+ # apply any given data to template scope
23
+ data = args.last.kind_of?(::Hash) ? args.pop : {}
24
+ if (data.keys.map(&:to_s) & self.public_methods.map(&:to_s)).size > 0
25
+ raise ArgumentError, "data conflicts with template public methods."
26
+ end
27
+ metaclass = class << self; self; end
28
+ data.each {|key, value| metaclass.class_eval { define_method(key){value} }}
29
+
30
+ # setup a source stack with the given source
31
+ @source = args.pop || Proc.new {}
32
+ instance_eval(&@source)
33
+ end
34
+
35
+ def _(data="", nl=true); @io << (data.to_s + (nl ? "\n" : "")); end
36
+ def __(data="", nl=true); @io << (data.to_s + (nl ? "\n" : "")); end
22
37
 
23
38
  end
24
39
 
25
40
  # this method is required by assert and is called by the test runner
26
- # use Undies to render the template
41
+ # render the template
27
42
  # using the view's template file
28
43
  # streaming to the view's output io
29
44
  # passing in the view itself and any runner_callback as locals
30
45
  def render(*args, &runner_callback)
31
- Template.new(Undies::Source.new(self.class.template), {
46
+ Template.new(self.class.template, {
32
47
  :view => self,
33
48
  :runner => runner_callback
34
- }, Undies::Output.new(self.output_io))
49
+ }, self.output_io)
35
50
  end
36
51
 
37
52
  module ClassMethods
@@ -75,8 +90,8 @@ module Assert::View
75
90
  attr_accessor :suite, :output_io, :runtime_result_callback
76
91
 
77
92
  def initialize(output_io, suite=Assert.suite)
78
- self.suite = suite
79
93
  self.output_io = output_io
94
+ self.suite = suite
80
95
  end
81
96
 
82
97
  def view
@@ -1,5 +1,5 @@
1
1
  module Assert; end
2
2
 
3
3
  module Assert::View
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert-view
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-05 00:00:00 Z
18
+ date: 2012-03-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :development
22
- prerelease: false
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
@@ -29,11 +28,11 @@ dependencies:
29
28
  segments:
30
29
  - 0
31
30
  version: "0"
32
- version_requirements: *id001
33
31
  name: bundler
32
+ version_requirements: *id001
33
+ prerelease: false
34
34
  - !ruby/object:Gem::Dependency
35
35
  type: :development
36
- prerelease: false
37
36
  requirement: &id002 !ruby/object:Gem::Requirement
38
37
  none: false
39
38
  requirements:
@@ -43,11 +42,11 @@ dependencies:
43
42
  segments:
44
43
  - 0
45
44
  version: "0"
46
- version_requirements: *id002
47
45
  name: assert
46
+ version_requirements: *id002
47
+ prerelease: false
48
48
  - !ruby/object:Gem::Dependency
49
49
  type: :runtime
50
- prerelease: false
51
50
  requirement: &id003 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
@@ -58,26 +57,12 @@ dependencies:
58
57
  - 1
59
58
  - 3
60
59
  version: "1.3"
61
- version_requirements: *id003
62
60
  name: ansi
63
- - !ruby/object:Gem::Dependency
64
- type: :runtime
61
+ version_requirements: *id003
65
62
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ~>
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 2
74
- - 0
75
- version: "2.0"
76
- version_requirements: *id004
77
- name: undies
78
63
  description: A collection of views for use in the Assert testing framework
79
64
  email:
80
- - kelly@kelredd.com
65
+ - kelly@kellyredding.com
81
66
  executables: []
82
67
 
83
68
  extensions: []