brass 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/.ruby +2 -2
  2. data/HISTORY.rdoc +11 -0
  3. data/lib/brass.rb +43 -24
  4. metadata +7 -7
data/.ruby CHANGED
@@ -41,7 +41,7 @@ revision: 0
41
41
  created: '2012-01-24'
42
42
  summary: Bare-Metal Ruby Assertion System Standard
43
43
  title: BRASS
44
- version: 1.0.0
44
+ version: 1.1.0
45
45
  name: brass
46
46
  description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It is
47
47
  a very basic
@@ -50,4 +50,4 @@ description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It i
50
50
 
51
51
  to make use so they can all work together harmoniously.'
52
52
  organization: Rubyworks
53
- date: '2012-01-24'
53
+ date: '2012-01-25'
data/HISTORY.rdoc CHANGED
@@ -1,5 +1,16 @@
1
1
  = HISTORY
2
2
 
3
+ == 1.1.0 | 2012-01-25
4
+
5
+ Quick fix for issue with parsing arguments of #assert and #refute methods.
6
+ Also added #fail! method to dry-up code.
7
+
8
+ Changes:
9
+
10
+ * Fix arguments parsing for assert/refute.
11
+ * Add #fail! method to dry-up code.
12
+
13
+
3
14
  == 1.0.0 | 2012-01-24
4
15
 
5
16
  This is the initial release of BRASS. It is given a 1.0.0 version
data/lib/brass.rb CHANGED
@@ -10,6 +10,12 @@ class Exception
10
10
  @assertion = boolean # ? true : false
11
11
  end
12
12
 
13
+ # Set message.
14
+ # (not strictly needed here, but can be useful anyway).
15
+ def set_message(msg)
16
+ @mesg = msg.to_str
17
+ end
18
+
13
19
  end
14
20
 
15
21
  module Kernel
@@ -29,18 +35,7 @@ module Kernel
29
35
  # if fail set assertion=true then just,
30
36
  # fail *raise_arguments
31
37
  # but alas ...
32
- if Exception === raise_arguments.first
33
- error = raise_arguments.shift
34
- else
35
- if Exception > raise_arguments.first
36
- error_class = raise_arguments.shift
37
- else
38
- error_class = StandardError
39
- end
40
- error = error_class.new(*raise_arguments)
41
- end
42
- error.set_assertion(true)
43
- raise error
38
+ fail! *raise_arguments
44
39
  end
45
40
  end
46
41
 
@@ -56,18 +51,7 @@ module Kernel
56
51
  # if fail set assertion=true then just,
57
52
  # fail *raise_arguments
58
53
  # but alas ...
59
- if Exception === raise_arguments.first
60
- error = raise_arguments.shift
61
- else
62
- if Exception > raise_arguments.first
63
- error_class = raise_arguments.shift
64
- else
65
- error_class = StandardError
66
- end
67
- error = error_class.new(*raise_arguments)
68
- end
69
- error.set_assertion(true)
70
- raise error
54
+ fail! *raise_arguments
71
55
  else
72
56
  $ASSERTION_COUNTS[:pass] += 1
73
57
  end
@@ -75,4 +59,39 @@ module Kernel
75
59
 
76
60
  module_function :refute
77
61
 
62
+ #
63
+ # Alternate for #fail that also sets assertion flag to +true+.
64
+ #
65
+ def fail!(*raise_arguments)
66
+ backtrace = case raise_arguments.last
67
+ when Array
68
+ raise_arguments.pop
69
+ else
70
+ nil
71
+ end
72
+
73
+ exception = case raise_arguments.first
74
+ when Exception
75
+ raise_arguments.shift
76
+ when Class
77
+ raise ArgumentError unless Exception > raise_arguments.first
78
+ error_class = raise_arguments.shift
79
+ error_class.new(*raise_arguments)
80
+ else
81
+ error_class = StandardError
82
+ error_class.new(*raise_arguments)
83
+ end
84
+
85
+ exception.set_backtrace(backtrace) if backtrace
86
+ exception.set_assertion(true)
87
+
88
+ fail exception
89
+ end
90
+
91
+ module_function :fail!
92
+
93
+ private :assert
94
+ private :refute
95
+ private :fail!
96
+
78
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: detroit
16
- requirement: &26437340 !ruby/object:Gem::Requirement
16
+ requirement: &19650860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *26437340
24
+ version_requirements: *19650860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: lemon
27
- requirement: &26436120 !ruby/object:Gem::Requirement
27
+ requirement: &19650020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *26436120
35
+ version_requirements: *19650020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rubytest
38
- requirement: &26460580 !ruby/object:Gem::Requirement
38
+ requirement: &19649060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *26460580
46
+ version_requirements: *19649060
47
47
  description: ! 'BRASS stands for Bare-Metal Ruby Assertion System Standard. It is
48
48
  a very basic
49
49