drain 0.5.1 → 0.6.0

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
  SHA256:
3
- metadata.gz: 6705260fddd5fa51a51c2985c143400b89527c0ee0d2bffcc326f5fe2bbff6f3
4
- data.tar.gz: 744ca23e60895094238628160e1dc3c3dfccdaa58d757013880835e96f3de21f
3
+ metadata.gz: 3dea94fa15923f71b70d9dc67df57c6ea196e0cd68e2b8bf68dca52af40b98cc
4
+ data.tar.gz: eef6894d11959d219f09bb3c6e9f8a81d04a1c35ff262ca61aca6fe16b44e0c9
5
5
  SHA512:
6
- metadata.gz: b3fe3cfd0ea0d9f9bd10df890a97b958bc8652e33b0993692188481d4759e242a5603dedcb696f244cc2f1b2dd835ba0520e2620d9ab2490339f028c0bb504b5
7
- data.tar.gz: e61a5c90fb6f6bd515fa101667f53e53ad780f712196f5db8418800e8bc8c00697196188cb6efde4f2ec2ceffd962c9be63280350eb37c9327bfac26ac91248d
6
+ metadata.gz: 21cbef6b4255d768f7c4b827edb317432e8c82c19aedc26cd11055c25883f5d09e8f53dc726432b0c0736465ed78800da0e2369a6d87bede7318905c7993eddb
7
+ data.tar.gz: 8ca316496349c54e69ef811b6eb2f90326c254d8a95c8b380a45509240d2d50bd0d5dc1765abac63a64ebb127e802224fd2cf4c5481d1b2c6ffe7af8dcbda74a
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+ jobs:
5
+ test:
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ os: [ ubuntu-latest, macos-latest ]
10
+ ruby: [ 2.3, 2.4, 2.5, 2.6, 2.7, jruby, truffleruby ]
11
+ runs-on: ${{ matrix.os }}
12
+ steps:
13
+ - name: 'Git checkout'
14
+ uses: actions/checkout@v2
15
+ - name: 'Setup ruby'
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ - name: 'Install bundler and gems'
20
+ run: |
21
+ gem install bundler
22
+ bundle install --jobs 4 --retry 3
23
+ - name: "Run tests"
24
+ run: |
25
+ bundle exec rake test
@@ -1,9 +1,13 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
5
- - 2.4.4
6
- - 2.3.7
4
+ - 2.7.0
5
+ - 2.6.5
6
+ - 2.5.7
7
+ - 2.4.9
8
+ - 2.3.8 #eol, but still used in debian
9
+ #- 2.2.10
10
+ #- 2.1.10
7
11
  #- ruby-head
8
12
  #- ruby-head-clang
9
13
  script: rake test
@@ -1,3 +1,13 @@
1
+ == Release v0.6.0 (2020-02-26) ==
2
+
3
+ * Add github actions for tests
4
+ * Add github action for tests
5
+ * Bump travis versions
6
+ * Fix ruby 2.7 warning
7
+ * graph.rb: add merge! and merge
8
+ * test: fix minitest warnings
9
+ * gemspec: add chronic and chronic_duration
10
+
1
11
  == Release v0.5.1 (2020-02-18) ==
2
12
 
3
13
  * DR::URI -> DR::URIEscape
data/Gemfile CHANGED
@@ -2,6 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- group :development do
5
+ group :extra_devel do
6
+ gem 'minitest-reporters', '~> 1.4'
7
+ gem 'yard', '~> 0.9'
6
8
  gem 'kramdown'
9
+ gem 'rubygems-tasks', '~> 0.2'
7
10
  end
data/README.md CHANGED
@@ -3,9 +3,10 @@
3
3
  * [Homepage](https://github.com/DamienRobert/drain#readme)
4
4
  * [Issues](https://github.com/DamienRobert/drain/issues)
5
5
  * [Documentation](http://rubydoc.info/gems/drain)
6
- * [Email](mailto:Damien.Olivier.Robert+gems at gmail.com)
6
+ * [Email](mailto:Damien.Olivier.Robert+gems@gmail.com)
7
7
 
8
8
  [![Gem Version](https://img.shields.io/gem/v/drain.svg)](https://rubygems.org/gems/drain)
9
+ [![Ruby test result](https://github.com/DamienRobert/drain/workflows/Ruby/badge.svg)](https://github.com/DamienRobert/drain/actions?query=workflow%3ARuby)
9
10
  [![Build Status](https://travis-ci.org/DamienRobert/drain.svg?branch=master)](https://travis-ci.org/DamienRobert/drain)
10
11
 
11
12
  ## Description
@@ -17,15 +18,25 @@ The Api is far from stable yet, so use at your own risk!
17
18
 
18
19
  For now the API is experimental and some parts are not ready to use!
19
20
 
21
+ ## Examples
22
+
23
+ ~~~ ruby
24
+ require 'drain'
25
+ ~~~
26
+
27
+ ## Requirements
28
+
20
29
  ## Install
21
30
 
31
+ ~~~ sh
22
32
  $ gem install drain
33
+ ~~~
23
34
 
24
35
  ## Copyright
25
36
 
26
- Copyright © 2015–2018 Damien Robert
37
+ Copyright © 2015–2020 Damien Robert
27
38
 
28
- MIT License. See [LICENSE.txt](./LICENSE.txt) for details.
39
+ MIT License. See [`LICENSE.txt`](LICENSE.txt) for details.
29
40
 
30
41
  Some of the code is inspired by other project, in general I give proper
31
42
  acknowledgement in the corresponding file.
data/Rakefile CHANGED
@@ -1,3 +1,9 @@
1
+ ## Uncomment to use `rake` directly rather than `bundle exec rake`
2
+ #begin
3
+ # require 'bundler/setup'
4
+ #rescue LoadError => e
5
+ # warn "Could not setup bundler: #{e.message}"
6
+ #end
1
7
  require 'rake'
2
8
 
3
9
  require 'rake/testtask'
@@ -15,6 +21,7 @@ rescue LoadError => e
15
21
  warn e.message
16
22
  end
17
23
  end
24
+ desc 'Generate docs'
18
25
  task :doc => :yard
19
26
 
20
27
  begin
@@ -24,3 +31,4 @@ rescue LoadError => e
24
31
  warn e.message
25
32
  end
26
33
 
34
+ task :default => :test
@@ -33,6 +33,7 @@ Gem::Specification.new do |gem|
33
33
  end
34
34
  end
35
35
  gem.files = glob[gemspec['files']] if gemspec['files']
36
+ gem.files = gem.files + gemspec['extra_files'] if gemspec['extra_files']
36
37
 
37
38
  gem.executables = gemspec.fetch('executables') do
38
39
  glob['bin/*'].map { |path| File.basename(path) }
@@ -9,6 +9,6 @@ homepage: https://github.com/DamienRobert/drain#readme
9
9
 
10
10
  development_dependencies:
11
11
  minitest: "~> 5.0"
12
- rake: "~> 10"
13
- rubygems-tasks: "~> 0.2"
14
- yard: "~> 0.8"
12
+ rake: ">= 10"
13
+ chronic: "~> 0.10"
14
+ chronic_duration: "~> 0.10"
@@ -225,14 +225,17 @@ module DR
225
225
  end
226
226
 
227
227
  # allow a hash too
228
- def |(graph)
228
+ def merge!(graph)
229
229
  graph=Graph.new(graph, **{}) unless Graph===graph
230
230
  build(*graph.all, recursive: false)
231
231
  end
232
- def +(graph)
232
+ def merge(graph)
233
233
  clone.|(graph)
234
234
  end
235
235
 
236
+ alias | merge!
237
+ alias + merge
238
+
236
239
  def dump(mode: :graph, nodes_list: :roots, show_attr: true, out: [], **_opts)
237
240
  n=case nodes_list
238
241
  when :roots; roots
@@ -377,7 +380,7 @@ module DR
377
380
  while !new_nodes.empty?
378
381
  g2=yield(*new_nodes)
379
382
  g2=Graph.new(g2) unless g2.is_a?(Graph)
380
- g|g2
383
+ g.merge!(g2)
381
384
  nodes=nodes.concat(new_nodes)
382
385
  new_nodesg.nodes.map(&:name)-nodes
383
386
  end
@@ -15,7 +15,7 @@ module DR
15
15
  first=m[1]
16
16
  second=m[2]
17
17
  opt[:norange]=true
18
- return Chronic::Span.new(self.parse(first, opt),self.parse(second,opt))
18
+ return Chronic::Span.new(self.parse(first, **opt),self.parse(second, **opt))
19
19
  end
20
20
 
21
21
  if s.match(/\A[[:space:]]*\z/) # blank
@@ -1,4 +1,4 @@
1
1
  module DR
2
2
  # drain version
3
- VERSION = "0.5.1"
3
+ VERSION = "0.6.0"
4
4
  end
@@ -0,0 +1,4 @@
1
+ module Drain
2
+ # drain version
3
+ VERSION = "0.1.0"
4
+ end
@@ -1,11 +1,21 @@
1
+ ## Uncomment if you want to run a test directly without running
2
+ ## `bundle exec ruby -I test test/test_...rb`
3
+ ## (another solution if 'bundler/setup' is called on the Rakefile is to use
4
+ ## `rake test TEST=test/test_...rb`)
5
+ # begin
6
+ # require 'bundler/setup'
7
+ # rescue LoadError => error
8
+ # warn "Could not setup bundler: #{error.message}"
9
+ # end
10
+
1
11
  require 'minitest/autorun'
2
12
 
3
13
  ## Uncomment to launch pry on a failure
4
14
  #require 'pry-rescue/minitest'
5
15
 
6
16
  begin
7
- # require 'minitest/reporters'
8
- # Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
17
+ require 'minitest/reporters'
18
+ Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
9
19
  #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
10
20
  #Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
11
21
  rescue LoadError => error
@@ -17,26 +17,26 @@ describe DR::Converter do
17
17
  end
18
18
 
19
19
  it "Output a hash with the attributes" do
20
- DR::Converter.to_hash(@obj1, methods: [:a,:h]).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}})
20
+ _(DR::Converter.to_hash(@obj1, methods: [:a,:h])).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}})
21
21
  end
22
22
 
23
23
  it ":compact compress the values when there is only one method" do
24
- DR::Converter.to_hash(@obj1, methods: [:a,:h], compact: true).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}})
25
- DR::Converter.to_hash(@obj1, methods: [:a], compact: true).must_equal({@obj1 => @obj1.a})
24
+ _(DR::Converter.to_hash(@obj1, methods: [:a,:h], compact: true)).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}})
25
+ _(DR::Converter.to_hash(@obj1, methods: [:a], compact: true)).must_equal({@obj1 => @obj1.a})
26
26
  end
27
27
 
28
28
  it ":check checks that the method exists" do
29
- -> {DR::Converter.to_hash(@obj1, methods: [:none], check: false)}.must_raise NoMethodError
30
- DR::Converter.to_hash(@obj1, methods: [:none], check: true).must_equal({@obj1 => {}})
29
+ _(-> {DR::Converter.to_hash(@obj1, methods: [:none], check: false)}).must_raise NoMethodError
30
+ _(DR::Converter.to_hash(@obj1, methods: [:none], check: true)).must_equal({@obj1 => {}})
31
31
  end
32
32
 
33
33
  it "accepts a list" do
34
- DR::Converter.to_hash([@obj1,@obj2], methods: [:a,:h]).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}, @obj2 => {a: @obj2.a, h: @obj2.h}})
34
+ _(DR::Converter.to_hash([@obj1,@obj2], methods: [:a,:h])).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}, @obj2 => {a: @obj2.a, h: @obj2.h}})
35
35
  end
36
36
 
37
37
  #this test also test that cycles work
38
38
  it ":recursive generate the hash on the values" do
39
- DR::Converter.to_hash(@obj3, methods: [:a,:h], recursive: true).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}, @obj2 => {a: @obj2.a, h: @obj2.h}, @obj3 => {a: @obj3.a, h: @obj3.h}})
39
+ _(DR::Converter.to_hash(@obj3, methods: [:a,:h], recursive: true)).must_equal({@obj1 => {a: @obj1.a, h: @obj1.h}, @obj2 => {a: @obj2.a, h: @obj2.h}, @obj3 => {a: @obj3.a, h: @obj3.h}})
40
40
  end
41
41
 
42
42
  end
@@ -11,7 +11,7 @@ module TestCoreExt
11
11
  describe DR::CoreExt do
12
12
  describe Enumerable do
13
13
  it "Can classify enumerable" do
14
- [1,2,3,4].classify({odd: [1,3], default: :even}).must_equal({:odd=>[1, 3], :even=>[2, 4]})
14
+ _([1,2,3,4].classify({odd: [1,3], default: :even})).must_equal({:odd=>[1, 3], :even=>[2, 4]})
15
15
  end
16
16
  end
17
17
 
@@ -19,48 +19,48 @@ module TestCoreExt
19
19
  it "Implements Hash#deep_merge" do
20
20
  h1 = { x: { y: [4,5,6] }, z: [7,8,9] }
21
21
  h2 = { x: { y: [7,8,9] }, z: 'xyz' }
22
- h1.deep_merge(h2).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
23
- h2.deep_merge(h1).must_equal({x: {y: [4, 5, 6]}, z: [7, 8, 9]})
24
- h1.deep_merge(h2) { |key, old, new| Array(old) + Array(new) }.must_equal({:x=>{:y=>[4, 5, 6, 7, 8, 9]}, :z=>[7, 8, 9, "xyz"]})
22
+ _(h1.deep_merge(h2)).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
23
+ _(h2.deep_merge(h1)).must_equal({x: {y: [4, 5, 6]}, z: [7, 8, 9]})
24
+ _(h1.deep_merge(h2) { |key, old, new| Array(old) + Array(new) }).must_equal({:x=>{:y=>[4, 5, 6, 7, 8, 9]}, :z=>[7, 8, 9, "xyz"]})
25
25
  end
26
26
 
27
27
  it "Hash#deep_merge merge array when they start with nil" do
28
28
  h1 = { x: { y: [4,5,6] }, z: [7,8,9] }
29
29
  h2 = { x: { y: [nil, 7,8,9] }, z: 'xyz' }
30
- h1.deep_merge(h2).must_equal({x: {y: [4,5,6,7, 8, 9]}, z: "xyz"})
31
- {x: { y: []} }.deep_merge(h2).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
32
- {z: "foo"}.deep_merge(h2).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
30
+ _(h1.deep_merge(h2)).must_equal({x: {y: [4,5,6,7, 8, 9]}, z: "xyz"})
31
+ _({x: { y: []} }.deep_merge(h2)).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
32
+ _({z: "foo"}.deep_merge(h2)).must_equal({x: {y: [7, 8, 9]}, z: "xyz"})
33
33
  end
34
34
 
35
35
  it "Implements Hash#inverse" do
36
36
  h={ploum: 2, plim: 2, plam: 3}
37
- h.inverse.must_equal({2=>[:ploum, :plim], 3=>[:plam]})
37
+ _(h.inverse).must_equal({2=>[:ploum, :plim], 3=>[:plam]})
38
38
  end
39
39
 
40
40
  it "Implements Hash#keyed_value" do
41
41
  h = { x: { y: { z: "foo" } } }
42
- h.keyed_value("x/y/z").must_equal("foo")
42
+ _(h.keyed_value("x/y/z")).must_equal("foo")
43
43
  end
44
44
 
45
45
  it "Implements Hash#set_keyed_value" do
46
46
  h = { x: { y: { z: "foo" } } }
47
- h.set_keyed_value("x/y/z","bar").must_equal({ x: { y: { z: "bar" } } })
48
- h.set_keyed_value("x/y","bar2").must_equal({ x: { y: "bar2" } })
49
- h.set_keyed_value("z/y","bar3").must_equal({ x: { y: "bar2" } , z: {y: "bar3"}})
47
+ _(h.set_keyed_value("x/y/z","bar")).must_equal({ x: { y: { z: "bar" } } })
48
+ _(h.set_keyed_value("x/y","bar2")).must_equal({ x: { y: "bar2" } })
49
+ _(h.set_keyed_value("z/y","bar3")).must_equal({ x: { y: "bar2" } , z: {y: "bar3"}})
50
50
  end
51
51
 
52
52
  it "Implements Hash#leafs" do
53
- {foo: [:bar, :baz], bar: [:plum, :qux]}.leafs([:foo]).must_equal([:plum, :qux, :baz])
53
+ _({foo: [:bar, :baz], bar: [:plum, :qux]}.leafs([:foo])).must_equal([:plum, :qux, :baz])
54
54
  end
55
55
  end
56
56
 
57
57
  describe UnboundMethod do
58
58
  it "Can be converted to a proc" do
59
59
  m=String.instance_method(:length)
60
- ["foo", "ploum"].map(&m).must_equal([3,5])
60
+ _(["foo", "ploum"].map(&m)).must_equal([3,5])
61
61
  end
62
62
  it "Can call" do
63
- String.instance_method(:length).call("foo").must_equal(3)
63
+ _(String.instance_method(:length).call("foo")).must_equal(3)
64
64
  end
65
65
  end
66
66
 
@@ -73,34 +73,34 @@ module TestCoreExt
73
73
  it "Can do rcurry" do
74
74
  l=->(x,y) {"#{x}: #{y}"}
75
75
  m=l.rcurry("foo")
76
- m.call("bar").must_equal("bar: foo")
76
+ _(m.call("bar")).must_equal("bar: foo")
77
77
  end
78
78
 
79
79
  it "Can compose functions" do
80
80
  somme=->(x,y) {x+y}
81
81
  carre=->(x) {x*x}
82
- carre.compose(somme).(2,3).must_equal(25)
82
+ _(carre.compose(somme).(2,3)).must_equal(25)
83
83
  end
84
84
 
85
85
  it "Can uncurry functions" do
86
- (->(x) {->(y) {x+y}}).uncurry.(2,3).must_equal(5)
87
- (->(x,y) {x+y}).curry.uncurry.(2,3).must_equal(5)
86
+ _((->(x) {->(y) {x+y}}).uncurry.(2,3)).must_equal(5)
87
+ _((->(x,y) {x+y}).curry.uncurry.(2,3)).must_equal(5)
88
88
  end
89
89
  end
90
90
 
91
91
  describe Array do
92
92
  it "Can be converted to proc (providing extra arguments)" do
93
- ["ploum","plam"].map(&[:+,"foo"]).must_equal(["ploumfoo", "plamfoo"])
93
+ _(["ploum","plam"].map(&[:+,"foo"])).must_equal(["ploumfoo", "plamfoo"])
94
94
  end
95
95
  end
96
96
 
97
97
  describe Object do
98
98
  it "this can change the object" do
99
- "foo".this {|s| s.size}.+(1).must_equal(4)
99
+ _("foo".this {|s| s.size}.+(1)).must_equal(4)
100
100
  end
101
101
 
102
102
  it "and_this emulates the Maybe Monad" do
103
- "foo".and_this {|s| s.size}.must_equal(3)
103
+ _("foo".and_this {|s| s.size}).must_equal(3)
104
104
  assert_nil nil.and_this {|s| s.size}
105
105
  end
106
106
  end
@@ -109,7 +109,7 @@ module TestCoreExt
109
109
  it "Generates keys when needed" do
110
110
  h=DR::RecursiveHash.new
111
111
  h[:foo][:bar]=3
112
- h.must_equal({foo: {bar: 3}})
112
+ _(h).must_equal({foo: {bar: 3}})
113
113
  end
114
114
  end
115
115
  end
@@ -12,18 +12,18 @@ describe DR::DateRange do
12
12
  end
13
13
 
14
14
  it "Can parse dates" do
15
- @daterange.d.must_equal [["2014-01-02", "2014-01-03"], ["2014-01-05"], ["2014-02", :now]]
15
+ _(@daterange.d).must_equal [["2014-01-02", "2014-01-03"], ["2014-01-05"], ["2014-02", :now]]
16
16
  end
17
17
 
18
18
  it "Can output a date range" do
19
- @daterange.to_s.must_equal "Jan. 2014 – Jan. 2014, Jan. 2014, Feb. 2014 – Present"
19
+ _(@daterange.to_s).must_equal "Jan. 2014 – Jan. 2014, Jan. 2014, Feb. 2014 – Present"
20
20
  end
21
21
 
22
22
  it "Can output a date range with full time information" do
23
- @daterange.to_s(output_date_length: :all).must_equal "02 Jan. 2014 – 03 Jan. 2014, 05 Jan. 2014, Feb. 2014 – Present"
23
+ _(@daterange.to_s(output_date_length: :all)).must_equal "02 Jan. 2014 – 03 Jan. 2014, 05 Jan. 2014, Feb. 2014 – Present"
24
24
  end
25
25
 
26
26
  it "Has time information" do
27
- @daterange.t[0].to_s.must_equal "[2014-01-02 00:00:00 +0000, 2014-01-03 00:00:00 +0000]".encode('US-ASCII')
27
+ _(@daterange.t[0].to_s).must_equal "[2014-01-02 00:00:00 +0000, 2014-01-03 00:00:00 +0000]".encode('US-ASCII')
28
28
  end
29
29
  end
@@ -8,53 +8,53 @@ describe DR::Graph do
8
8
  end
9
9
 
10
10
  it "builds the graph" do
11
- @graph.nodes.length.must_equal 3
11
+ _(@graph.nodes.length).must_equal 3
12
12
  end
13
13
 
14
14
  it "accepts :to_a" do
15
- @graph.to_a.map(&:name).must_equal(["foo", "bar", "baz"])
15
+ _(@graph.to_a.map(&:name)).must_equal(["foo", "bar", "baz"])
16
16
  end
17
17
 
18
18
  it "accepts :to_hash" do
19
- @graph.to_hash.first[1].keys.must_equal [:children, :parents, :attributes]
19
+ _(@graph.to_hash.first[1].keys).must_equal [:children, :parents, :attributes]
20
20
  end
21
21
 
22
22
  it "can be converted to a hash" do
23
- @graph.to_h.must_equal ({"foo"=> ["bar","baz"], "bar" => ["baz"], "baz" => []})
23
+ _(@graph.to_h).must_equal ({"foo"=> ["bar","baz"], "bar" => ["baz"], "baz" => []})
24
24
  end
25
25
 
26
26
  it "can give a node" do
27
- @graph["foo"].class.must_equal DR::Node
27
+ _(@graph["foo"].class).must_equal DR::Node
28
28
  end
29
29
 
30
30
  it "can give descendants of a node" do
31
- @graph["foo"].descendants.map(&:to_s).must_equal(["bar", "baz"])
31
+ _(@graph["foo"].descendants.map(&:to_s)).must_equal(["bar", "baz"])
32
32
  end
33
33
 
34
34
  it "can give ancestors of a node" do
35
- @graph["baz"].ancestors.map(&:to_s).must_equal(["foo", "bar"])
35
+ _(@graph["baz"].ancestors.map(&:to_s)).must_equal(["foo", "bar"])
36
36
  end
37
37
 
38
38
  it "can give the root nodes" do
39
- @graph.roots.map(&:name).must_equal(["foo"])
39
+ _(@graph.roots.map(&:name)).must_equal(["foo"])
40
40
  end
41
41
 
42
42
  it "can give the bottom nodes" do
43
- @graph.bottom.map(&:name).must_equal(["baz"])
43
+ _(@graph.bottom.map(&:name)).must_equal(["baz"])
44
44
  end
45
45
 
46
46
  it "can show all ancestors of nodes" do
47
- @graph.ancestors("baz","bar").map(&:to_s).must_equal(["baz", "bar", "foo"])
48
- @graph.ancestors("baz","bar", ourselves: false).map(&:to_s).must_equal(["foo"])
47
+ _(@graph.ancestors("baz","bar").map(&:to_s)).must_equal(["baz", "bar", "foo"])
48
+ _(@graph.ancestors("baz","bar", ourselves: false).map(&:to_s)).must_equal(["foo"])
49
49
  end
50
50
 
51
51
  it "can show all descendants of nodes" do
52
- @graph.descendants("foo","bar").map(&:to_s).must_equal(["foo", "bar", "baz"])
53
- @graph.descendants("foo","bar", ourselves: false).map(&:to_s).must_equal(["baz"])
52
+ _(@graph.descendants("foo","bar").map(&:to_s)).must_equal(["foo", "bar", "baz"])
53
+ _(@graph.descendants("foo","bar", ourselves: false).map(&:to_s)).must_equal(["baz"])
54
54
  end
55
55
 
56
56
  it "can give a hash of children" do
57
- @graph.to_children.must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>[]})
57
+ _(@graph.to_children).must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>[]})
58
58
  end
59
59
 
60
60
  describe "build" do
@@ -64,11 +64,11 @@ describe DR::Graph do
64
64
  end
65
65
 
66
66
  it "detects unneeded nodes" do
67
- @graph.unneeded("foo","bar").map(&:name).must_equal ["foo","bar"]
68
- @graph.unneeded("bar").map(&:name).must_equal []
67
+ _(@graph.unneeded("foo","bar").map(&:name)).must_equal ["foo","bar"]
68
+ _(@graph.unneeded("bar").map(&:name)).must_equal []
69
69
  end
70
70
  it "detects unneeded descendants" do
71
- @graph.unneeded_descendants("foo").map(&:name).must_equal ["foo", "bar", "baz"]
71
+ _(@graph.unneeded_descendants("foo").map(&:name)).must_equal ["foo", "bar", "baz"]
72
72
  end
73
73
 
74
74
  describe "It works with a cycle" do
@@ -77,7 +77,7 @@ describe DR::Graph do
77
77
  end
78
78
 
79
79
  it "It builds the graph" do
80
- @graph.nodes.length.must_equal 3
80
+ _(@graph.nodes.length).must_equal 3
81
81
  end
82
82
  end
83
83
 
@@ -97,9 +97,9 @@ describe DR::Graph do
97
97
  end
98
98
 
99
99
  it "It builds the graph" do
100
- @graph.nodes.length.must_equal 3
101
- @graph.to_h.must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["foo"]})
102
- @graph['baz'].attributes.must_equal(real: true)
100
+ _(@graph.nodes.length).must_equal 3
101
+ _(@graph.to_h).must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["foo"]})
102
+ _(@graph['baz'].attributes).must_equal(real: true)
103
103
  end
104
104
  end
105
105
 
@@ -109,18 +109,18 @@ describe DR::Graph do
109
109
  end
110
110
 
111
111
  it "Graph2 is well defined" do
112
- @graph2.nodes.map(&:name).must_equal(%w(foo bar baz qux))
112
+ _(@graph2.nodes.map(&:name)).must_equal(%w(foo bar baz qux))
113
113
  end
114
114
 
115
115
  it "Can be merged in place" do
116
- @graph | @graph2
117
- @graph.to_h.must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["bar", "qux"], "qux"=>[]})
116
+ @graph.merge!(@graph2) #alias @graph | @graph2
117
+ _(@graph.to_h).must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["bar", "qux"], "qux"=>[]})
118
118
  end
119
119
 
120
120
  it "Can be merged" do
121
121
  @graph3 = @graph + @graph2
122
- @graph.to_h.must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>[]})
123
- @graph3.to_h.must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["bar", "qux"], "qux"=>[]})
122
+ _(@graph.to_h).must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>[]})
123
+ _(@graph3.to_h).must_equal({"foo"=>["bar", "baz"], "bar"=>["baz"], "baz"=>["bar", "qux"], "qux"=>[]})
124
124
  end
125
125
  end
126
126
  end
@@ -49,17 +49,17 @@ describe DR::Meta do
49
49
  # end
50
50
 
51
51
  it "Can show all ancestors" do
52
- DR::Meta.all_ancestors("foo").include?(String.singleton_class).must_equal(true)
52
+ _(DR::Meta.all_ancestors("foo").include?(String.singleton_class)).must_equal(true)
53
53
  end
54
54
 
55
55
  it "Can generate bound methods" do
56
56
  m=DR::Meta.get_bound_method("foo", :bar) do |x|
57
57
  self+x
58
58
  end
59
- m.call("bar").must_equal("foobar")
59
+ _(m.call("bar")).must_equal("foobar")
60
60
  end
61
61
 
62
62
  it "Can apply unbound methods" do
63
- DR::Meta.apply(method: String.instance_method(:length), to: "foo").must_equal(3)
63
+ _(DR::Meta.apply(method: String.instance_method(:length), to: "foo")).must_equal(3)
64
64
  end
65
65
  end
@@ -10,27 +10,27 @@ describe DR::SimpleKeywordsParser do
10
10
  end
11
11
 
12
12
  it "Can parse keywords" do
13
- @parser.parse("FOO(ploum, plam)").must_equal 'FOO: ["ploum", "plam"]'
13
+ _(@parser.parse("FOO(ploum, plam)")).must_equal 'FOO: ["ploum", "plam"]'
14
14
  end
15
15
 
16
16
  it "Can preserver spaces" do
17
- @parser.parse("FOO( ploum , plam )", space: true).must_equal "FOO: [\" ploum \", \" plam \"]"
17
+ _(@parser.parse("FOO( ploum , plam )", space: true)).must_equal "FOO: [\" ploum \", \" plam \"]"
18
18
  end
19
19
 
20
20
  it "Can change delimiters" do
21
- @parser.parse("FOO[ ploum , plam ]", delims: '[]').must_equal "FOO: [\"ploum\", \"plam\"]"
21
+ _(@parser.parse("FOO[ ploum , plam ]", delims: '[]')).must_equal "FOO: [\"ploum\", \"plam\"]"
22
22
  end
23
23
 
24
24
  it "Can have a one caracter delimiter" do
25
- @parser.parse("FOO! ploum , plam !", delims: '!').must_equal "FOO: [\"ploum\", \"plam\"]"
25
+ _(@parser.parse("FOO! ploum , plam !", delims: '!')).must_equal "FOO: [\"ploum\", \"plam\"]"
26
26
  end
27
27
 
28
28
  it "Can parse keywords inside keywords" do
29
- @parser.parse("FOO(ploum, BAR( foo, bar ))").must_equal "FOO: [\"ploum\", \"BAR: [\\\"foo\\\"\", \"\\\"bar\\\"]\"]"
29
+ _(@parser.parse("FOO(ploum, BAR( foo, bar ))")).must_equal "FOO: [\"ploum\", \"BAR: [\\\"foo\\\"\", \"\\\"bar\\\"]\"]"
30
30
  end
31
31
 
32
32
  it "Can add a keyword" do
33
33
  @parser.keyword("PLOUM") { |a,b| a.to_i+b.to_i}
34
- @parser.parse("Hello PLOUM(2,3)").must_equal 'Hello 5'
34
+ _(@parser.parse("Hello PLOUM(2,3)")).must_equal 'Hello 5'
35
35
  end
36
36
  end
@@ -4,34 +4,34 @@ require 'dr/parse/simple_parser'
4
4
  describe DR::SimpleParser do
5
5
  describe "parse_namevalue" do
6
6
  it "parses a simple name value" do
7
- DR::SimpleParser.parse_namevalue("foo:bar").must_equal([:foo,"bar"])
7
+ _(DR::SimpleParser.parse_namevalue("foo:bar")).must_equal([:foo,"bar"])
8
8
  end
9
9
  it "can let the name be a string" do
10
- DR::SimpleParser.parse_namevalue("foo:bar",symbolize:false).must_equal(["foo","bar"])
10
+ _(DR::SimpleParser.parse_namevalue("foo:bar",symbolize:false)).must_equal(["foo","bar"])
11
11
  end
12
12
  it "only splits on the first ':'" do
13
- DR::SimpleParser.parse_namevalue("foo:bar:baz").must_equal([:foo,"bar:baz"])
13
+ _(DR::SimpleParser.parse_namevalue("foo:bar:baz")).must_equal([:foo,"bar:baz"])
14
14
  end
15
15
  it "can change the separation" do
16
- DR::SimpleParser.parse_namevalue("foo:bar!baz", sep: "!",symbolize:false).must_equal(["foo:bar","baz"])
16
+ _(DR::SimpleParser.parse_namevalue("foo:bar!baz", sep: "!",symbolize:false)).must_equal(["foo:bar","baz"])
17
17
  end
18
18
  it "can set a default" do
19
- DR::SimpleParser.parse_namevalue("foo", default: 0).must_equal([:foo,0])
19
+ _(DR::SimpleParser.parse_namevalue("foo", default: 0)).must_equal([:foo,0])
20
20
  end
21
21
  it "If the default is true then support 'no-foo'" do
22
- DR::SimpleParser.parse_namevalue("no-foo", default: true).must_equal([:foo,false])
22
+ _(DR::SimpleParser.parse_namevalue("no-foo", default: true)).must_equal([:foo,false])
23
23
  end
24
24
  it "can set the default to true" do
25
- DR::SimpleParser.parse_namevalue("foo", default: true, symbolize:false).must_equal(["foo",true])
25
+ _(DR::SimpleParser.parse_namevalue("foo", default: true, symbolize:false)).must_equal(["foo",true])
26
26
  end
27
27
  end
28
28
 
29
29
  describe "parse_strings" do
30
30
  it "can parse several name values" do
31
- DR::SimpleParser.parse_string("foo:bar,ploum:plim")[:values].must_equal({foo: "bar", ploum: "plim"})
31
+ _(DR::SimpleParser.parse_string("foo:bar,ploum:plim")[:values]).must_equal({foo: "bar", ploum: "plim"})
32
32
  end
33
33
  it "can handle options" do
34
- DR::SimpleParser.parse_string("name1:value1!option1=ploum!option2=plam!option3,name2:value2!!globalopt1=foo,globalopt2=bar").must_equal({
34
+ _(DR::SimpleParser.parse_string("name1:value1!option1=ploum!option2=plam!option3,name2:value2!!globalopt1=foo,globalopt2=bar")).must_equal({
35
35
  values: {name1: "value1", name2: "value2"},
36
36
  local_opts: {name1: {option1:"ploum",option2:"plam",option3:true}, name2: {}},
37
37
  global_opts: {globalopt1: "foo", globalopt2: "bar"},
@@ -20,20 +20,20 @@ describe DR::TimeParse do
20
20
  end
21
21
 
22
22
  it "Can parse a range" do
23
- DR::TimeParse.parse("+100..tomorrow").must_equal(
23
+ _(DR::TimeParse.parse("+100..tomorrow")).must_equal(
24
24
  Time.parse("2000-01-01 00:01:40")..Time.parse("2000-01-02 12:00:00")
25
25
  )
26
- DR::TimeParse.parse("now..in seven days").must_equal(
26
+ _(DR::TimeParse.parse("now..in seven days")).must_equal(
27
27
  Time.parse("2000-01-01 00:00:00")..Time.parse("2000-01-08 00:00:00")
28
28
  )
29
29
  end
30
30
 
31
31
  it "Can parse a date" do
32
- DR::TimeParse.parse("today").must_equal(Time.parse("2000-01-01-12:00:00"))
32
+ _(DR::TimeParse.parse("today")).must_equal(Time.parse("2000-01-01-12:00:00"))
33
33
  end
34
34
 
35
35
  it "Can put a date in a range" do
36
- DR::TimeParse.parse("today", range: true).must_equal(
36
+ _(DR::TimeParse.parse("today", range: true)).must_equal(
37
37
  Time.parse("2000-01-01-00:00:00")..Time.parse("2000-01-02-00:00:00")
38
38
  )
39
39
  end
@@ -3,33 +3,33 @@ require 'dr/base/uri'
3
3
 
4
4
  describe DR::URIWrapper do
5
5
  before do
6
- @uri=DR::URIWrapper.new(URI.escape("http://ploum:secret@plam:443/foo bar"))
6
+ @uri=DR::URIWrapper.new(DR::URIEscape.escape("http://ploum:secret@plam:443/foo bar"))
7
7
  end
8
8
  it "Wraps an uri element" do
9
- @uri.scheme.must_equal "http"
9
+ _(@uri.scheme).must_equal "http"
10
10
  end
11
11
  it "Auto escapes attribute" do
12
- @uri.path.must_equal "/foo bar"
12
+ _(@uri.path).must_equal "/foo bar"
13
13
  end
14
14
  it "Auto escape setting elements" do
15
15
  @uri.user="ploum plam"
16
- @uri.user.must_equal "ploum plam"
16
+ _(@uri.user).must_equal "ploum plam"
17
17
  end
18
18
  it "Can convert to a hash" do
19
- @uri.to_h[:user].must_equal("ploum")
19
+ _(@uri.to_h[:user]).must_equal("ploum")
20
20
  end
21
21
  it "Can convert to json" do
22
22
  require 'json'
23
- @uri.to_json.must_equal("{\"uri\":\"http://ploum:secret@plam:443/foo%20bar\",\"scheme\":\"http\",\"userinfo\":\"ploum:secret\",\"host\":\"plam\",\"port\":443,\"path\":\"/foo bar\",\"user\":\"ploum\",\"password\":\"secret\"}")
23
+ _(@uri.to_json).must_equal("{\"uri\":\"http://ploum:secret@plam:443/foo%20bar\",\"scheme\":\"http\",\"userinfo\":\"ploum:secret\",\"host\":\"plam\",\"port\":443,\"path\":\"/foo bar\",\"user\":\"ploum\",\"password\":\"secret\"}")
24
24
  end
25
25
  it "Can remove password" do
26
- @uri.to_public.must_equal("http://ploum@plam:443/foo%20bar")
26
+ _(@uri.to_public).must_equal("http://ploum@plam:443/foo%20bar")
27
27
  end
28
28
  it "Can be merged" do
29
- @uri.soft_merge("foo://plim@").to_s.must_equal("foo://plim:secret@plam:443/foo%20bar")
29
+ _(@uri.soft_merge("foo://plim@").to_s).must_equal("foo://plim:secret@plam:443/foo%20bar")
30
30
  end
31
31
  it "Can be reverse merged" do
32
- DR::URIWrapper.parse("//user@server").reverse_merge(@uri).to_s.must_equal("http://user:secret@server:443/foo%20bar")
32
+ _(DR::URIWrapper.parse("//user@server").reverse_merge(@uri).to_s).must_equal("http://user:secret@server:443/foo%20bar")
33
33
  end
34
34
  end
35
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-18 00:00:00.000000000 Z
11
+ date: 2020-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubygems-tasks
42
+ name: chronic
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.2'
47
+ version: '0.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.2'
54
+ version: '0.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: yard
56
+ name: chronic_duration
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.8'
61
+ version: '0.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.8'
68
+ version: '0.10'
69
69
  description: 'Drain is a small set of libraries that I use in my other gems.
70
70
 
71
71
  '
@@ -77,6 +77,7 @@ extra_rdoc_files:
77
77
  - LICENSE.txt
78
78
  - README.md
79
79
  files:
80
+ - ".github/workflows/ruby.yml"
80
81
  - ".gitignore"
81
82
  - ".travis.yml"
82
83
  - ".yardopts"
@@ -112,6 +113,7 @@ files:
112
113
  - lib/dr/tools/gtk.rb
113
114
  - lib/dr/version.rb
114
115
  - lib/drain.rb
116
+ - lib/drain/version.rb
115
117
  - test/helper.rb
116
118
  - test/test_converter.rb
117
119
  - test/test_core_ext.rb