xqsr3 0.29.2 → 0.30.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +3 -3
- data/README.md +55 -10
- data/lib/xqsr3/containers/frequency_map.rb +12 -0
- data/lib/xqsr3/quality/parameter_checking.rb +12 -10
- data/lib/xqsr3/version.rb +3 -3
- data/lib/xqsr3/xml/utilities/compare.rb +1 -1
- data/test/performance/frequency_map.rb +48 -0
- data/test/unit/containers/tc_frequency_map.rb +21 -0
- data/test/unit/quality/tc_parameter_checking.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0aae760822aa8749a7caeb361cc3c40fd3d374d
|
4
|
+
data.tar.gz: 223189ea29f2c140cc2a866b6cc0872f18f8a9fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f190ff85d37defc8e7a9b7927a4cfea44945bb071f3d01a7090489fdbcc3dc365ad7f27970b5696096db37daa924376c8f1402aa51758f9b0220ba10a8d7a088
|
7
|
+
data.tar.gz: 75ab4d3ae800bf45f54de072b845a556c8edbd9d87198340a098e0f44cdb06681f0ffcd197ede43763de670c9d754aed08cf8df28f9de6369c9c497a1fd86184
|
data/LICENSE
CHANGED
@@ -17,9 +17,9 @@ modification, are permitted provided that the following conditions are met:
|
|
17
17
|
contributors may be used to endorse or promote products derived from
|
18
18
|
this software without specific prior written permission.
|
19
19
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
23
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
24
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
25
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
data/README.md
CHANGED
@@ -1,28 +1,73 @@
|
|
1
1
|
# xqsr3
|
2
|
-
|
2
|
+
e**X**tensions by fine **Q**uantum for **S**tandard **R**uby and **3**rd-party libraries
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/xqsr3.svg)](https://badge.fury.io/rb/xqsr3)
|
5
5
|
|
6
|
-
##
|
6
|
+
## Introduction
|
7
|
+
|
8
|
+
**xqsr3** is a lightweight, low-coupling library of assorted extensions to standard ruby and 3rd-party libraries.
|
9
|
+
|
10
|
+
It has **no dependencies** on any other non-standard library.
|
11
|
+
|
12
|
+
It may be pronounced (lamely) as "excusers".
|
13
|
+
|
14
|
+
## Table of Contents
|
15
|
+
|
16
|
+
1. [Introduction](#introduction)
|
17
|
+
2. [Installation](#installation)
|
18
|
+
3. [Components](#components)
|
19
|
+
4. [Project Information](#project-information)
|
20
|
+
|
21
|
+
## Installation
|
7
22
|
|
8
23
|
Install using `gem install xqsr3` or add it to your `Gemfile`.
|
9
24
|
|
10
|
-
##
|
25
|
+
## Components
|
11
26
|
|
12
|
-
**xqsr3**
|
27
|
+
**xqsr3** provides components in the following categories:
|
13
28
|
|
14
|
-
|
29
|
+
* Array Utilities
|
30
|
+
* Command-line Utilities
|
31
|
+
* Containers
|
32
|
+
* Conversion
|
33
|
+
* Diagnostics
|
34
|
+
* Hash Utilities
|
35
|
+
* IO
|
36
|
+
* Quality
|
37
|
+
* String Utilities
|
38
|
+
* XML Utilities
|
39
|
+
|
40
|
+
and extensions to the following standard library components:
|
41
|
+
|
42
|
+
* Array extensions
|
43
|
+
* Enumerable extensions
|
44
|
+
* Hash extensions
|
45
|
+
* IO extensions
|
46
|
+
* Kernel extensions
|
47
|
+
* String extensions
|
48
|
+
* test/unit extensions
|
49
|
+
|
50
|
+
## Project Information
|
51
|
+
|
52
|
+
### Where to get help
|
15
53
|
|
16
54
|
[GitHub Page](https://github.com/synesissoftware/xqsr3 "GitHub Page")
|
17
55
|
|
18
|
-
|
56
|
+
### Contribution guidelines
|
19
57
|
|
20
58
|
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/xqsr3.
|
21
59
|
|
22
|
-
|
60
|
+
### Related projects
|
61
|
+
|
62
|
+
**xqsr3** is a runtime dependency in:
|
63
|
+
|
64
|
+
* the **[libCLImate.Ruby](https://github.com/synesissoftware/libCLImate.Ruby)** library;
|
65
|
+
|
66
|
+
and a development dependency in:
|
23
67
|
|
24
|
-
|
68
|
+
* the **[CLASP.Ruby](https://github.com/synesissoftware/CLASP.Ruby)** library;
|
69
|
+
* the **[Pantheios.Ruby](https://github.com/synesissoftware/Pantheios.Ruby)** library;
|
25
70
|
|
26
|
-
|
71
|
+
### License
|
27
72
|
|
28
|
-
**xqsr3** is released under the 3-clause BSD license. See LICENSE for details.
|
73
|
+
**xqsr3** is released under the 3-clause BSD license. See [LICENSE](./LICENSE) for details.
|
@@ -215,6 +215,18 @@ class FrequencyMap
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
+
# Enumerates each entry pair - element + frequency - in key order
|
219
|
+
#
|
220
|
+
# Note: this method is more expensive than +each+ because an array of
|
221
|
+
# keys must be created and sorted from which enumeration is directed
|
222
|
+
def each_by_key
|
223
|
+
|
224
|
+
@counts.keys.sort.each do |key|
|
225
|
+
|
226
|
+
yield key, @counts[key]
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
218
230
|
# Enumerates each entry pair - element + frequency - in descending
|
219
231
|
# order of frequency
|
220
232
|
#
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Definition of the ParameterChecking module
|
6
6
|
#
|
7
7
|
# Created: 12th February 2015
|
8
|
-
# Updated:
|
8
|
+
# Updated: 18th October 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -353,18 +353,20 @@ module ParameterChecking
|
|
353
353
|
|
354
354
|
unless types.any? do |t|
|
355
355
|
|
356
|
-
|
357
|
-
|
356
|
+
case t
|
357
|
+
when ::Class
|
358
358
|
|
359
|
-
|
360
|
-
|
361
|
-
|
359
|
+
# the (presumed) scalar argument is of type t?
|
360
|
+
value.is_a?(t)
|
361
|
+
when ::Array
|
362
|
+
|
363
|
+
# the (presumed) vector argument's elements are the
|
364
|
+
# possible types
|
365
|
+
value.all? { |v| t.any? { |t2| v.is_a?(t2) }} if ::Array === value
|
366
|
+
else
|
362
367
|
|
363
|
-
# the (presumed) vector argument's elements are the
|
364
|
-
# possible types
|
365
|
-
value.all? { |v| t.any? { |t2| v.is_a?(t2) }} if ::Array === value
|
366
|
-
end
|
367
368
|
end
|
369
|
+
end then
|
368
370
|
|
369
371
|
failed_check = true
|
370
372
|
|
data/lib/xqsr3/version.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
# Purpose: Version for Xqsr3 library
|
6
6
|
#
|
7
7
|
# Created: 3rd April 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 28th February 2019
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
12
|
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
-
# Copyright (c) 2016-
|
14
|
+
# Copyright (c) 2016-2019, Matthew Wilson and Synesis Software
|
15
15
|
# All rights reserved.
|
16
16
|
#
|
17
17
|
# Redistribution and use in source and binary forms, with or without
|
@@ -50,7 +50,7 @@
|
|
50
50
|
module Xqsr3
|
51
51
|
|
52
52
|
# Current version of the Xqsr3 library
|
53
|
-
VERSION = '0.
|
53
|
+
VERSION = '0.30.3'
|
54
54
|
|
55
55
|
private
|
56
56
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
# File: test/performance/frequency_map.rb
|
5
|
+
#
|
6
|
+
# Purpose: COMPLETE_ME
|
7
|
+
#
|
8
|
+
# Created: 13th October 2018
|
9
|
+
# Updated: 13th October 2018
|
10
|
+
#
|
11
|
+
# Author: Matthew Wilson
|
12
|
+
#
|
13
|
+
# Copyright: <<TBD>>
|
14
|
+
#
|
15
|
+
#############################################################################
|
16
|
+
|
17
|
+
$:.unshift File.join(File.dirname($0), *(['..'] * 2), 'lib')
|
18
|
+
|
19
|
+
require 'xqsr3/containers/frequency_map'
|
20
|
+
|
21
|
+
require 'benchmark'
|
22
|
+
|
23
|
+
include ::Xqsr3::Containers
|
24
|
+
|
25
|
+
Benchmark.bm do |bm|
|
26
|
+
|
27
|
+
fm = FrequencyMap.new
|
28
|
+
|
29
|
+
(0...100000000).each do |n|
|
30
|
+
|
31
|
+
fm << (n % 4793)
|
32
|
+
end
|
33
|
+
|
34
|
+
bm.report('each ') do
|
35
|
+
|
36
|
+
fm.each do |k, freq|
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
bm.report('each (by f)') do
|
42
|
+
|
43
|
+
fm.each_by_frequency do |k, freq|
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -306,6 +306,27 @@ class Test_Xqsr3_Containers_FrequencyMap < Test::Unit::TestCase
|
|
306
306
|
assert_equal [:ghi, 2], r[2]
|
307
307
|
end
|
308
308
|
|
309
|
+
def test_each_by_key
|
310
|
+
|
311
|
+
fm = FrequencyMap.new
|
312
|
+
|
313
|
+
fm << :def
|
314
|
+
fm << :abc << :abc << :abc << :abc
|
315
|
+
fm << :ghi << :ghi
|
316
|
+
|
317
|
+
r = []
|
318
|
+
|
319
|
+
fm.each_by_key do |k, v|
|
320
|
+
|
321
|
+
r << [k, v]
|
322
|
+
end
|
323
|
+
|
324
|
+
assert_equal 3, r.size
|
325
|
+
assert_equal [:abc, 4], r[0]
|
326
|
+
assert_equal [:def, 1], r[1]
|
327
|
+
assert_equal [:ghi, 2], r[2]
|
328
|
+
end
|
329
|
+
|
309
330
|
def test_each_by_frequency
|
310
331
|
|
311
332
|
fm = FrequencyMap.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xqsr3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.30.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/xqsr3/version.rb
|
81
81
|
- lib/xqsr3/xml/utilities/compare.rb
|
82
82
|
- lib/xqsr3/xml/utilities/navigation.rb
|
83
|
+
- test/performance/frequency_map.rb
|
83
84
|
- test/unit/array_utilities/tc_join_with_or.rb
|
84
85
|
- test/unit/array_utilities/ts_all.rb
|
85
86
|
- test/unit/command_line_utilities/tc_map_option_string.rb
|
@@ -140,7 +141,7 @@ files:
|
|
140
141
|
- test/unit/xml/utilities/ts_all.rb
|
141
142
|
homepage: http://github.com/synesissoftware/xqsr3
|
142
143
|
licenses:
|
143
|
-
- BSD-3-
|
144
|
+
- BSD-3-Clause
|
144
145
|
metadata: {}
|
145
146
|
post_install_message:
|
146
147
|
rdoc_options: []
|