wherever-positions 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -13,4 +13,5 @@ group :development do
13
13
  gem "rcov", ">= 0"
14
14
  gem 'ruby-debug'
15
15
  gem 'database_cleaner'
16
+ gem 'timecop'
16
17
  end
data/Gemfile.lock CHANGED
@@ -54,6 +54,7 @@ GEM
54
54
  ruby-debug-base (0.10.4)
55
55
  linecache (>= 0.3)
56
56
  term-ansicolor (1.0.7)
57
+ timecop (0.3.5)
57
58
  tzinfo (0.3.30)
58
59
 
59
60
  PLATFORMS
@@ -69,3 +70,4 @@ DEPENDENCIES
69
70
  rcov
70
71
  rspec (~> 2.3.0)
71
72
  ruby-debug
73
+ timecop
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
@@ -12,7 +12,7 @@ module MethodLogging
12
12
  klass.send :alias_method, :"#{method}_without_logging", method
13
13
  klass.class_eval <<-END
14
14
  def #{method}_with_logging(*args)
15
- MethodLogging.log("Called: #{method}(\#{MethodLogging.strify(*args)})")
15
+ MethodLogging.log("Called #{Time.now}: #{method}(\#{MethodLogging.strify(*args)})")
16
16
  #{method}_without_logging(*args)
17
17
  end
18
18
  END
@@ -20,7 +20,9 @@ module MethodLogging
20
20
  end
21
21
 
22
22
  def log(string)
23
- File.open("log/method.log", 'a') do |f|
23
+ path = Class.constants.include?('RAILS_ROOT') ? RAILS_ROOT : File.expand_path(File.dirname(__FILE__) + '/..')
24
+ FileUtils.mkdir_p("#{path}/log") if File.exists?("#{path}/log")
25
+ File.open("#{path}/log/method.log", 'a') do |f|
24
26
  f.puts string
25
27
  end
26
28
  end
@@ -1,10 +1,10 @@
1
1
  class Wherever
2
2
  module Accessors
3
- protected
4
3
  def get_key_store(*keys)
5
4
  DbStore.new_store(get_marker(keys), keys)
6
5
  end
7
6
 
7
+ protected
8
8
  def get_marker(keys=[])
9
9
  keys.last.is_a?(Hash) ? keys.pop["marker"] : marker
10
10
  end
@@ -8,11 +8,13 @@ describe "Wherever", 'method logging' do
8
8
  let(:file) { mock(:file_io) }
9
9
  before do
10
10
  MethodLogging.stub(:log => true)
11
+ Timecop.travel(Time.now)
11
12
  end
13
+ after { Timecop.return }
12
14
  context 'the add method' do
13
15
 
14
16
  it 'is logged to file' do
15
- call_string = %Q{Called: add({"unsettled" => 0, "settled" => 100}, {"keys" => {"fund_id" => 2}, "unique" => {"trade_id" => 12, "version" => 1}})}
17
+ call_string = %Q{Called #{Time.now}: add({"unsettled" => 0, "settled" => 100}, {"keys" => {"fund_id" => 2}, "unique" => {"trade_id" => 12, "version" => 1}})}
16
18
  MethodLogging.should_receive(:log).with(call_string)
17
19
  wherever.add({"settled" => 100, "unsettled" => 0}, options)
18
20
  end
@@ -20,7 +22,7 @@ describe "Wherever", 'method logging' do
20
22
 
21
23
  context 'the get key method' do
22
24
  it 'is logged to file' do
23
- call_string = %Q{Called: get_key_store("identifier")}
25
+ call_string = %Q{Called #{Time.now}: get_key_store("identifier")}
24
26
  MethodLogging.should_receive(:log).with(call_string)
25
27
  wherever.get_key_store("identifier").datasets.all
26
28
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'rspec'
4
4
  require 'wherever'
5
5
  require 'ruby-debug'
6
6
  require 'database_cleaner'
7
+ require 'timecop'
7
8
 
8
9
  Wherever.new("keys" => ["fund"], "database" => 'wherever_test')
9
10
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wherever-positions}
8
- s.version = "0.4.6"
8
+ s.version = "0.4.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Henry"]
@@ -76,6 +76,7 @@ Gem::Specification.new do |s|
76
76
  s.add_development_dependency(%q<rcov>, [">= 0"])
77
77
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
78
78
  s.add_development_dependency(%q<database_cleaner>, [">= 0"])
79
+ s.add_development_dependency(%q<timecop>, [">= 0"])
79
80
  else
80
81
  s.add_dependency(%q<bson_ext>, [">= 0"])
81
82
  s.add_dependency(%q<mongoid>, [">= 0"])
@@ -86,6 +87,7 @@ Gem::Specification.new do |s|
86
87
  s.add_dependency(%q<rcov>, [">= 0"])
87
88
  s.add_dependency(%q<ruby-debug>, [">= 0"])
88
89
  s.add_dependency(%q<database_cleaner>, [">= 0"])
90
+ s.add_dependency(%q<timecop>, [">= 0"])
89
91
  end
90
92
  else
91
93
  s.add_dependency(%q<bson_ext>, [">= 0"])
@@ -97,6 +99,7 @@ Gem::Specification.new do |s|
97
99
  s.add_dependency(%q<rcov>, [">= 0"])
98
100
  s.add_dependency(%q<ruby-debug>, [">= 0"])
99
101
  s.add_dependency(%q<database_cleaner>, [">= 0"])
102
+ s.add_dependency(%q<timecop>, [">= 0"])
100
103
  end
101
104
  end
102
105
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wherever-positions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 6
10
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Henry
@@ -150,6 +150,20 @@ dependencies:
150
150
  prerelease: false
151
151
  type: :development
152
152
  requirement: *id009
153
+ - !ruby/object:Gem::Dependency
154
+ name: timecop
155
+ version_requirements: &id010 !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ hash: 3
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ prerelease: false
165
+ type: :development
166
+ requirement: *id010
153
167
  description: Allow Store of positions by multiple keys with teh option to mark specific points in time for use later
154
168
  email: dw_henry@yahoo.com.au
155
169
  executables: []