rgraph 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/guard +16 -0
- data/lib/rgraph/graph.rb +8 -0
- data/lib/rgraph/node.rb +5 -0
- data/lib/rgraph/version.rb +1 -1
- data/rgraph.gemspec +0 -1
- data/spec/rgraph/graph_spec.rb +10 -1
- data/spec/rgraph/node_spec.rb +9 -5
- metadata +2 -1
data/bin/guard
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby19
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'guard' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('guard', 'guard')
|
data/lib/rgraph/graph.rb
CHANGED
data/lib/rgraph/node.rb
CHANGED
data/lib/rgraph/version.rb
CHANGED
data/rgraph.gemspec
CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
data/spec/rgraph/graph_spec.rb
CHANGED
@@ -40,5 +40,14 @@ describe Graph do
|
|
40
40
|
expect { Graph.new('spec/fixtures/2005') }.to raise_exception("the file must be a .csv")
|
41
41
|
end
|
42
42
|
end
|
43
|
-
end
|
44
43
|
|
44
|
+
describe "Metrics" do
|
45
|
+
subject { Graph.new('spec/fixtures/three_links.csv') }
|
46
|
+
it "returns degree of all nodes as an array" do
|
47
|
+
expect(subject.degrees).to eq([2,2,2])
|
48
|
+
end
|
49
|
+
it "calculates de average degree" do
|
50
|
+
expect(subject.average_degree).to eq(2)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/rgraph/node_spec.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require_relative '../../lib/rgraph/node'
|
2
2
|
|
3
3
|
describe Node do
|
4
|
-
|
5
|
-
|
6
|
-
its(:name) { should
|
7
|
-
its(:
|
8
|
-
its(:age) { should
|
4
|
+
subject { Node.new(name: "Lucas", id: '1', age: 20) }
|
5
|
+
describe "#new" do
|
6
|
+
its(:name) { should eq "Lucas" }
|
7
|
+
its(:id) { should eq '1' }
|
8
|
+
its(:age) { should eq 20 }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#degree" do
|
12
|
+
its(:degree) { should eq 0}
|
9
13
|
end
|
10
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- LICENSE
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
111
|
+
- bin/guard
|
111
112
|
- lib/rgraph.rb
|
112
113
|
- lib/rgraph/graph.rb
|
113
114
|
- lib/rgraph/link.rb
|