Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
42 lib/pacer/graph/yaml_encoder.rb
@@ -15,12 +15,12 @@ def self.encode_property(value)
value
when Numeric
if value.is_a? Bignum
- value.to_yaml
+ dump value
else
- value
+ value.to_java
end
when true, false
- value
+ value.to_java
when Array
if value.length == 0
value_type = Fixnum
@@ -44,33 +44,27 @@ def self.encode_property(value)
when String
value.to_java :string
else
- value.to_yaml
+ dump value
end
else
- value.to_yaml
+ dump value
end
end
- if 'x'.to_yaml[0, 5] == '%YAML'
- def self.decode_property(value)
- if value.is_a? String and value[0, 5] == '%YAML'
- YAML.load(value)
- elsif value.is_a? ArrayJavaProxy
- value.to_a
- else
- value
- end
- end
- else
- def self.decode_property(value)
- if value.is_a? String and value[0, 3] == '---'
- YAML.load(value)
- elsif value.is_a? ArrayJavaProxy
- value.to_a
- else
- value
- end
+ def self.decode_property(value)
+ if value.is_a? String and value[0, 1] == ' '
+ YAML.load(value[1..-1])
+ elsif value.is_a? ArrayJavaProxy
+ value.to_a
+ else
+ value
end
end
+
+ private
+
+ def self.dump(value)
+ " #{ YAML.dump value }"
+ end
end
end
View
12 spec/pacer/core/graph/vertices_route_spec.rb
@@ -24,7 +24,7 @@
# TODO: (dw 12-9) I don't really like that the pipe filters falsy
# values but I'm not worrying about it any further for now.
- graph.v.property?(:falsy).count.should == 0
+ graph.v.property?(:falsy).count.should == 1
end
end
end
@@ -59,12 +59,12 @@
subject { graph.v.out }
it { should be_a Pacer::Core::Graph::VerticesRoute }
its(:count) { should == 14 }
- its(:to_a) { should == graph.v.out_e.in_v.to_a }
+ its(:to_set) { should == graph.v.out_e.in_v.to_set }
describe '(:uses, :wrote)' do
subject { graph.v.out(:uses, :wrote) }
its(:count) { should == 9 }
- it { subject.to_a.should == graph.v.out_e(:uses, :wrote).in_v.to_a }
+ it { subject.to_set.should == graph.v.out_e(:uses, :wrote).in_v.to_set }
end
it 'should not apply extensions to new route' do
@@ -76,11 +76,11 @@
subject { graph.v.in }
it { should be_a Pacer::Core::Graph::VerticesRoute }
its(:count) { should == 14 }
- its(:to_a) { should == graph.v.in_e.out_v.to_a }
+ its(:to_set) { should == graph.v.in_e.out_v.to_set }
describe '(:uses, :wrote)' do
subject { graph.v.in(:uses, :wrote) }
its(:count) { should == 9 }
- it { subject.to_a.should == graph.v.in_e(:uses, :wrote).out_v.to_a }
+ it { subject.to_set.should == graph.v.in_e(:uses, :wrote).out_v.to_set }
end
it 'should not apply extensions to new route' do
@@ -126,7 +126,7 @@
r = graph.v.out_e.in_v.in_e { |e| e.label == 'wrote' }.out_v
paths = r.paths
paths.first.should_not be_nil
- graph.v.out_e.in_v.in_e(:wrote).out_v.paths.collect(&:to_a).should == paths.collect(&:to_a)
+ graph.v.out_e.in_v.in_e(:wrote).out_v.paths.to_a.should == paths.to_a
end
end
end
View
4 spec/pacer/graph/yaml_encoder_spec.rb
@@ -34,12 +34,12 @@
end
specify 'numbers should be javafied' do
- subject[:integer].should == 121.to_java(:int)
+ subject[:integer].should == 121.to_java(:long)
subject[:float].should == 100.001
end
specify 'everything else should be yaml' do
- subject[:time].should == YAML.dump(Time.utc(1999, 11, 9, 9, 9, 1))
+ subject[:time].should == ' ' + YAML.dump(Time.utc(1999, 11, 9, 9, 9, 1))
end
end

No commit comments for this range

Something went wrong with that request. Please try again.