rspec-support 3.4.1 → 3.5.0.beta1

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: 25c6ea6acc982a2910d925f597f145145b22cf7f
4
- data.tar.gz: 4603a8c3f85cf003193e7482a19a1970339051ce
3
+ metadata.gz: ec9c4fd5101ce3289e09d787448cffbab08a563e
4
+ data.tar.gz: d2037dfbf1e7198702ea76a715322de33fc620c4
5
5
  SHA512:
6
- metadata.gz: 74d0dd544377bef599af14522a512690eff3a21b317161aee428be724da07cfb5da7edb981f2440e72f374aa960b65deb9ceaab5e59ad377200df693063494d4
7
- data.tar.gz: cc57fd580aaf7a0a78985a86f2d995f6a69637b5d379e048cfdb02ae523eea5517d8654e4d9ae6febb377f93fac19c68d6b0f0737f5c2a07e7359650af6b0db7
6
+ metadata.gz: 772ca53099ce0eadc50476aded4ae68c9485b15d1bdad55d2852dc463f3efcc1cb07a043b4bd1da755f28ffce8fe3693ae06b6691d5a2267cf155c2dd8a313be
7
+ data.tar.gz: 633fc69929b63caa86b8f29f06dad98ad0b3c74e205143225b910652388f36fa783b2b05cebdd884366b70b3fba2b0dad0960ca1318f12febb5ba6d7e9a9ada6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,14 @@
1
+ ### Development
2
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta1...master)
3
+
4
+ ### 3.5.0.beta1 / 2016-02-06
5
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.4.1...v3.5.0.beta1)
6
+
7
+ Enhancements:
8
+
9
+ * Improve formatting of objects by allowing truncation to a pre-configured length.
10
+ (Liam M, #256)
11
+
1
12
  ### 3.4.1 / 2015-11-20
2
13
  [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.4.0...v3.4.1)
3
14
 
@@ -8,6 +19,10 @@ Bug Fixes:
8
19
  it. This prevents rspec-core from trying to load and use ripper to
9
20
  extract failure snippets. (Aaron Stone, #251)
10
21
 
22
+ Changes:
23
+
24
+ * Remove `VersionChecker` in favor of `ComparableVersion`. (Yuji Nakayama, #266)
25
+
11
26
  ### 3.4.0 / 2015-11-11
12
27
  [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.3.0...v3.4.0)
13
28
 
data/README.md CHANGED
@@ -33,8 +33,8 @@ can treat each RSpec repo as an independent project.
33
33
 
34
34
  ## Patches
35
35
 
36
- Please submit a pull request or a github issue to one of the issue trackers
37
- listed below. If you submit an issue, please include a link to either of:
36
+ Please submit a pull request or a github issue. If you submit an issue, please
37
+ include a link to either of:
38
38
 
39
39
  * a gist (or equivalent) of the patch
40
40
  * a branch or commit in your github fork of the repo
@@ -2,15 +2,41 @@ module RSpec
2
2
  module Support
3
3
  # Provide additional output details beyond what `inspect` provides when
4
4
  # printing Time, DateTime, or BigDecimal
5
- module ObjectFormatter
6
- # @api private
5
+ # @api private
6
+ class ObjectFormatter
7
+ attr_accessor :max_formatted_output_length
8
+
9
+ def initialize(max_formatted_output_length=200)
10
+ @max_formatted_output_length = max_formatted_output_length
11
+ end
12
+
13
+ # Methods are deferred to a default instance of the class to maintain the interface
14
+ # For example, calling ObjectFormatter.format is still possible
15
+ @default_instance = new(200)
16
+
17
+ ELLIPSIS = "..."
18
+
19
+ def format(object)
20
+ if max_formatted_output_length.nil?
21
+ return prepare_for_inspection(object).inspect
22
+ else
23
+ formatted_object = prepare_for_inspection(object).inspect
24
+ if formatted_object.length < max_formatted_output_length
25
+ return formatted_object
26
+ else
27
+ beginning = formatted_object[0 .. max_formatted_output_length / 2]
28
+ ending = formatted_object[-max_formatted_output_length / 2 ..-1]
29
+ return beginning + ELLIPSIS + ending
30
+ end
31
+ end
32
+ end
33
+
7
34
  def self.format(object)
8
- prepare_for_inspection(object).inspect
35
+ @default_instance.format(object)
9
36
  end
10
37
 
11
38
  # rubocop:disable MethodLength
12
39
 
13
- # @private
14
40
  # Prepares the provided object to be formatted by wrapping it as needed
15
41
  # in something that, when `inspect` is called on it, will produce the
16
42
  # desired output.
@@ -20,7 +46,7 @@ module RSpec
20
46
  # with custom items that have `inspect` defined to return the desired output
21
47
  # for that item. Then we can just use `Array#inspect` or `Hash#inspect` to
22
48
  # format the entire thing.
23
- def self.prepare_for_inspection(object)
49
+ def prepare_for_inspection(object)
24
50
  case object
25
51
  when Array
26
52
  return object.map { |o| prepare_for_inspection(o) }
@@ -44,33 +70,41 @@ module RSpec
44
70
  end
45
71
  # rubocop:enable MethodLength
46
72
 
47
- # @private
48
- def self.prepare_hash(input)
73
+ def self.prepare_for_inspection(object)
74
+ @default_instance.prepare_for_inspection(object)
75
+ end
76
+
77
+ def prepare_hash(input)
49
78
  input.inject({}) do |hash, (k, v)|
50
79
  hash[prepare_for_inspection(k)] = prepare_for_inspection(v)
51
80
  hash
52
81
  end
53
82
  end
54
83
 
84
+ def self.prepare_hash(input)
85
+ @default_instance.prepare_hash(input)
86
+ end
87
+
55
88
  TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
56
89
 
57
90
  if Time.method_defined?(:nsec)
58
- # @private
59
- def self.format_time(time)
91
+ def format_time(time)
60
92
  time.strftime("#{TIME_FORMAT}.#{"%09d" % time.nsec} %z")
61
93
  end
62
94
  else # for 1.8.7
63
- # @private
64
- def self.format_time(time)
95
+ def format_time(time)
65
96
  time.strftime("#{TIME_FORMAT}.#{"%06d" % time.usec} %z")
66
97
  end
67
98
  end
68
99
 
100
+ def self.format_time(time)
101
+ @default_instance.format_time(time)
102
+ end
103
+
69
104
  DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z"
70
105
  # ActiveSupport sometimes overrides inspect. If `ActiveSupport` is
71
106
  # defined use a custom format string that includes more time precision.
72
- # @private
73
- def self.format_date_time(date_time)
107
+ def format_date_time(date_time)
74
108
  if defined?(ActiveSupport)
75
109
  date_time.strftime(DATE_TIME_FORMAT)
76
110
  else
@@ -78,7 +112,10 @@ module RSpec
78
112
  end
79
113
  end
80
114
 
81
- # @private
115
+ def self.format_date_time(date_time)
116
+ @default_instance.format_date_time(date_time)
117
+ end
118
+
82
119
  InspectableItem = Struct.new(:inspection) do
83
120
  def inspect
84
121
  inspection
@@ -89,7 +126,6 @@ module RSpec
89
126
  end
90
127
  end
91
128
 
92
- # @private
93
129
  DelegatingInspector = Struct.new(:object) do
94
130
  def inspect
95
131
  if defined?(::Delegator) && ::Delegator === object
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Support
3
3
  module Version
4
- STRING = '3.4.1'
4
+ STRING = '3.5.0.beta1'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -48,7 +48,7 @@ cert_chain:
48
48
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
49
49
  F3MdtaDehhjC
50
50
  -----END CERTIFICATE-----
51
- date: 2015-11-20 00:00:00.000000000 Z
51
+ date: 2016-02-06 00:00:00.000000000 Z
52
52
  dependencies:
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
@@ -127,7 +127,6 @@ files:
127
127
  - lib/rspec/support/spec/with_isolated_directory.rb
128
128
  - lib/rspec/support/spec/with_isolated_stderr.rb
129
129
  - lib/rspec/support/version.rb
130
- - lib/rspec/support/version_checker.rb
131
130
  - lib/rspec/support/warnings.rb
132
131
  homepage: https://github.com/rspec/rspec-support
133
132
  licenses:
@@ -145,13 +144,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
144
  version: 1.8.7
146
145
  required_rubygems_version: !ruby/object:Gem::Requirement
147
146
  requirements:
148
- - - ">="
147
+ - - ">"
149
148
  - !ruby/object:Gem::Version
150
- version: '0'
149
+ version: 1.3.1
151
150
  requirements: []
152
151
  rubyforge_project:
153
- rubygems_version: 2.2.2
152
+ rubygems_version: 2.4.5.1
154
153
  signing_key:
155
154
  specification_version: 4
156
- summary: rspec-support-3.4.1
155
+ summary: rspec-support-3.5.0.beta1
157
156
  test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,53 +0,0 @@
1
- module RSpec
2
- module Support
3
- LibraryVersionTooLowError = Class.new(StandardError)
4
-
5
- # @private
6
- class VersionChecker
7
- def initialize(library_name, library_version, min_patch_level)
8
- @library_name, @library_version = library_name, library_version
9
- @min_patch_level = min_patch_level
10
-
11
- @major, @minor, @patch = parse_version(library_version)
12
- @min_major, @min_minor, @min_patch = parse_version(min_patch_level)
13
-
14
- @comparison_result = compare_version
15
- end
16
-
17
- def check_version!
18
- raise_too_low_error if too_low?
19
- end
20
-
21
- private
22
-
23
- def too_low?
24
- @comparison_result == :too_low
25
- end
26
-
27
- def raise_too_low_error
28
- raise LibraryVersionTooLowError,
29
- "You are using #{@library_name} #{@library_version}. " \
30
- "RSpec requires version #{version_requirement}."
31
- end
32
-
33
- def compare_version
34
- case
35
- when @major < @min_major then :too_low
36
- when @major > @min_major then :ok
37
- when @minor < @min_minor then :too_low
38
- when @minor > @min_minor then :ok
39
- when @patch < @min_patch then :too_low
40
- else :ok
41
- end
42
- end
43
-
44
- def version_requirement
45
- ">= #{@min_patch_level}"
46
- end
47
-
48
- def parse_version(version)
49
- version.split('.').map { |v| v.to_i }
50
- end
51
- end
52
- end
53
- end