Skip to content

Commit

Permalink
Merge pull request #134 from karabijavad/master
Browse files Browse the repository at this point in the history
incorporate max-execution-time
  • Loading branch information
maxdemarzi committed Jan 21, 2014
2 parents e4e3e87 + 6db7f83 commit df1a113
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/neography/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Config
:log_file, :log_enabled, :slow_log_threshold,
:max_threads,
:authentication, :username, :password,
:parser
:parser, :max_execution_time

def initialize
set_defaults
Expand All @@ -27,7 +27,8 @@ def to_hash
:authentication => @authentication,
:username => @username,
:password => @password,
:parser => @parser
:parser => @parser,
:max_execution_time => @max_execution_time
}
end

Expand All @@ -48,6 +49,7 @@ def set_defaults
@username = nil
@password = nil
@parser = MultiJsonParser
@max_execution_time = 6000
end

end
Expand Down
2 changes: 2 additions & 0 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def merge_options(options)
merged_options = options.merge!(@authentication)
merged_options[:headers].merge!(@user_agent) if merged_options[:headers]
merged_options[:headers].merge!('X-Stream' => true) if merged_options[:headers]
merged_options[:headers].merge!(@max_execution_time) if merged_options[:headers]
merged_options
end

Expand Down Expand Up @@ -88,6 +89,7 @@ def save_local_configuration(config)
@max_threads = config[:max_threads]
@parser = config[:parser]

@max_execution_time = { 'max-execution-time' => config[:max_execution_time] }
@user_agent = { "User-Agent" => USER_AGENT }

@authentication = {}
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/rest_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

it "should add a content type if there's existing headers" do
subject.merge_options({:headers => {'Content-Type' => 'foo/bar'}})[:headers].should ==
{'Content-Type' => "foo/bar", "User-Agent" => "Neography/#{Neography::VERSION}" , "X-Stream"=>true}
{'Content-Type' => "foo/bar", "User-Agent" => "Neography/#{Neography::VERSION}" , "X-Stream"=>true, "max-execution-time"=>6000}
end

end
4 changes: 3 additions & 1 deletion spec/unit/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Neography
its(:username) { should == nil }
its(:password) { should == nil }
its(:parser) { should == MultiJsonParser}
its(:max_execution_time) { should == 6000 }

it "has a hash representation" do
expected_hash = {
Expand All @@ -37,7 +38,8 @@ module Neography
:authentication => nil,
:username => nil,
:password => nil,
:parser => MultiJsonParser
:parser => MultiJsonParser,
:max_execution_time => 6000
}
config.to_hash.should == expected_hash
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module Neography
it "adds the User-Agent to the headers" do
connection.client.should_receive(:get).with(
"http://localhost:7474/db/data/foo/bar",
nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true}
nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true, "max-execution-time"=>6000}
) { double.as_null_object }

connection.get("/foo/bar", :headers => {})
Expand Down

0 comments on commit df1a113

Please sign in to comment.