acts_as_graph_vertex 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. checksums.yaml +5 -5
  2. metadata +45 -19
  3. data/README.md +0 -80
  4. data/lib/acts_as_graph_vertex.rb +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c77bf69f9ed79801c8a55148fc1448a4af1f9b27
4
- data.tar.gz: d38f2b2cd7290bf95e61e5fe743cf97aa099b248
2
+ SHA256:
3
+ metadata.gz: 41ba258f515e6d7a0880ecefdca9eb80777119a1fe5d09d9de40204de967171d
4
+ data.tar.gz: 34ee45ec18a832a2b8439717add8b886e08e229146e647d31982409b07769c02
5
5
  SHA512:
6
- metadata.gz: a765c73435a316e9b14aedfd86b00b70c43bb4676f4f90ddd2a5f360c76ce6967da0f87652ddc5d42d3a5d4132623b138fa4d6e0cf55a6ff2b6239669f0d1115
7
- data.tar.gz: 561414bae337114e3883d6f45d1a5761b5270dc38f04504a966b54b8f88001ba3056699c733d0acee5d2fa404704c665e049473a57e2d2df041278d18e0c0830
6
+ metadata.gz: 4935e7ee48473abbf8cbfee640e905f36f2167a3a06a529a4549f6b98cbe4b5a63819379c457442c900d9ffbc263a0eb3a9554869f2782dd94d30fbf03034cea
7
+ data.tar.gz: aa09dd160478277c7da1903085170c5c0a2a4eb62bd789df2348fca323f6ddbc86a2b12e6ed25385f0e73913b72a023f0bd98796b41c9a9560989856ff15a4a5
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_graph_vertex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kleyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -16,93 +16,119 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.7'
19
+ version: 0.8.22
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.7'
26
+ version: 0.8.22
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: filewatcher
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: '1.1'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.1.1
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '0.3'
43
+ version: '1.1'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.1.1
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: pry-byebug
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '2.0'
53
+ version: '3.6'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.6.0
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
61
  - - "~>"
53
62
  - !ruby/object:Gem::Version
54
- version: '2.0'
63
+ version: '3.6'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.6.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: rspec
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
71
  - - "~>"
60
72
  - !ruby/object:Gem::Version
61
- version: '3.1'
73
+ version: '3.8'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.8.0
62
77
  type: :development
63
78
  prerelease: false
64
79
  version_requirements: !ruby/object:Gem::Requirement
65
80
  requirements:
66
81
  - - "~>"
67
82
  - !ruby/object:Gem::Version
68
- version: '3.1'
83
+ version: '3.8'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.8.0
69
87
  - !ruby/object:Gem::Dependency
70
88
  name: rubocop
71
89
  requirement: !ruby/object:Gem::Requirement
72
90
  requirements:
73
91
  - - "~>"
74
92
  - !ruby/object:Gem::Version
75
- version: '0.28'
93
+ version: 0.59.2
76
94
  type: :development
77
95
  prerelease: false
78
96
  version_requirements: !ruby/object:Gem::Requirement
79
97
  requirements:
80
98
  - - "~>"
81
99
  - !ruby/object:Gem::Version
82
- version: '0.28'
100
+ version: 0.59.2
83
101
  - !ruby/object:Gem::Dependency
84
102
  name: rubocop-rspec
85
103
  requirement: !ruby/object:Gem::Requirement
86
104
  requirements:
87
105
  - - "~>"
88
106
  - !ruby/object:Gem::Version
89
- version: '1.2'
107
+ version: '1.29'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.29.1
90
111
  type: :development
91
112
  prerelease: false
92
113
  version_requirements: !ruby/object:Gem::Requirement
93
114
  requirements:
94
115
  - - "~>"
95
116
  - !ruby/object:Gem::Version
96
- version: '1.2'
97
- description: See https://github.com/nathankleyn/acts_as_graph_vertex for more information!
117
+ version: '1.29'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 1.29.1
121
+ description: |
122
+ Simple mixin for adding graph like functions (parents, children, traversal,
123
+ etc) to any class. Effectively, you'll get DAG (directed acyclic graph)
124
+ behaviour between your classes and therefore the ability to model parent,
125
+ child and sibling behaviours with ease!
98
126
  email:
99
127
  - nathan@nathankleyn.com
100
128
  executables: []
101
129
  extensions: []
102
130
  extra_rdoc_files: []
103
- files:
104
- - README.md
105
- - lib/acts_as_graph_vertex.rb
131
+ files: []
106
132
  homepage: https://github.com/nathankleyn/acts_as_graph_vertex
107
133
  licenses:
108
134
  - MIT
@@ -123,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
149
  version: '0'
124
150
  requirements: []
125
151
  rubyforge_project:
126
- rubygems_version: 2.4.5
152
+ rubygems_version: 2.7.6
127
153
  signing_key:
128
154
  specification_version: 4
129
155
  summary: Simple mixin for adding graph like functions (parents, children, traversal,
data/README.md DELETED
@@ -1,80 +0,0 @@
1
- # acts_as_graph_vertex [![Build Status](https://travis-ci.org/nathankleyn/acts_as_graph_vertex.svg?branch=master)](https://travis-ci.org/nathankleyn/acts_as_graph_vertex) [![Coverage Status](https://coveralls.io/repos/nathankleyn/acts_as_graph_vertex/badge.png?branch=master)](https://coveralls.io/r/nathankleyn/acts_as_graph_vertex?branch=master)
2
-
3
- Simple mixin for adding graph like functions (parents, children, traversal, etc) to any class.
4
-
5
- ## Installing
6
-
7
- You can install this gem via RubyGems:
8
-
9
- ```sh
10
- gem install acts_as_graph_vertex
11
- ```
12
-
13
- ## Using
14
-
15
- Sometimes it's useful to be able to add graph like functionality to existing classes you have. This is where acts_as_graph_vertex comes in! Simply mixin this module, and you'll get basic directed acyclic graph (DAG) functionality for free:
16
-
17
- ```ruby
18
- require 'acts_as_graph_vertex'
19
-
20
- class MyAmazingClass
21
- include ActsAsGraphVertex
22
- end
23
- ```
24
-
25
- And now you can use the functions:
26
-
27
- ```ruby
28
- parent = MyAmazingClass.new
29
- child1 = MyAmazingClass.new
30
- child2 = MyAmazingClass.new
31
- child3 = MyAmazingClass.new
32
-
33
- # The following calls will create a DAG like the following:
34
- #
35
- # --> child1 --
36
- # / \
37
- # parent-- --> child3
38
- # \ /
39
- # --> child2 --
40
-
41
- parent.add_child(child1)
42
- child2.add_parent(child1)
43
- child3.add_parent(child1)
44
- child3.add_parent(child2)
45
- ```
46
-
47
- You can now traverse the graph from any of these vertices:
48
-
49
- ```ruby
50
- parent.children # => [child1, child2]
51
- parent.all_children # => [child1, child2, child3]
52
- child3.parents # => [child1, child2]
53
- child3.all_parents # => [child1, child2, parent]
54
- ```
55
-
56
- Note that this mixin does not currently prevent or handle cyclic dependencies; it's intended to be simple rather than exhaustive. If cycle detection is required, using something as a layer over this mixin such as Tarjan's algorithm for finding strongly connected components of a graph is recommended. Tarjan's algorithm is bundled with the Ruby standard library as `TSort` (despite the naming, this class does not provide topographic sorting).
57
-
58
- ## License
59
-
60
- The MIT License (MIT)
61
-
62
- Copyright (c) 2015 Nathan Kleyn
63
-
64
- Permission is hereby granted, free of charge, to any person obtaining a copy
65
- of this software and associated documentation files (the "Software"), to deal
66
- in the Software without restriction, including without limitation the rights
67
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
68
- copies of the Software, and to permit persons to whom the Software is
69
- furnished to do so, subject to the following conditions:
70
-
71
- The above copyright notice and this permission notice shall be included in
72
- all copies or substantial portions of the Software.
73
-
74
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
76
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
77
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
78
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
80
- THE SOFTWARE.
@@ -1,75 +0,0 @@
1
- # A mixin module enabling classes to have parents and children. It provides
2
- # convenience methods for determining dependencies, and depdenants.
3
- #
4
- # Note that in contrast to a tree, this graph module allows multiple parents.
5
- module ActsAsGraphVertex
6
- # The self.included idiom. This is described in great detail in a
7
- # fantastic blog post here:
8
- #
9
- # http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/
10
- #
11
- # Basically, this idiom allows us to add both instance *and* class methods
12
- # to the class that is mixing this module into itself without forcing them
13
- # to call extend and include for this mixin. You'll see this idiom everywhere
14
- # in the Ruby/Rails world, so we use it too.
15
- def self.included(cls)
16
- cls.extend(ClassMethods)
17
- end
18
-
19
- # Common methods inherited by all classes
20
- module ClassMethods
21
- attr_writer :parents, :children
22
- end
23
-
24
- # Public: The parents linked to this instance.
25
- #
26
- # Returns an Array of Objects.
27
- def parents
28
- @parents ||= []
29
- end
30
-
31
- # Public: The children linked to this instance.
32
- #
33
- # Returns an Array of Objects.
34
- def children
35
- @children ||= []
36
- end
37
-
38
- # Public: Add a vertex to the parents linked to this instance. Will automatically add as a child of the given parent
39
- # if the given parent also mixes in the graph functionality.
40
- #
41
- # vertex - The Object to add as a parent.
42
- # add_child - Whether to add this item as a child of the given parent.
43
- def add_parent(vertex, add_child = true)
44
- return if parents.include?(vertex)
45
- vertex.add_child(self, false) if add_child && vertex.respond_to?(:add_child)
46
- parents << vertex
47
- end
48
-
49
- # Public: Add a vertex to the children linked to this instance. Will automatically add as a parent of the given child
50
- # if the given child also mixes in the graph functionality.
51
- #
52
- # vertex - The Object to add as a child.
53
- # add_parent - Whether to add this item as a parent of the given child.
54
- def add_child(vertex, add_parent = true)
55
- return if children.include?(vertex)
56
- vertex.add_parent(self, false) if add_parent && vertex.respond_to?(:add_parent)
57
- children << vertex
58
- end
59
-
60
- # Public: Convenience method to return all of the parents from this vertex in
61
- # the tree upwards to the root of the tree.
62
- #
63
- # Returns an Array of parent Objects.
64
- def all_parents
65
- ((parents + parents.map(&:all_parents)).flatten).uniq
66
- end
67
-
68
- # Public: Convenience method to return all of the children from this vertex in
69
- # the tree downwards to the leaves of the tree.
70
- #
71
- # Returns an Array of child Objects.
72
- def all_children
73
- (children + children.map(&:all_children).flatten).uniq
74
- end
75
- end