couchrest_changes 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module CouchRest
2
2
  class Changes
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -9,11 +9,13 @@ module CouchRest
9
9
 
10
10
  attr_writer :logger
11
11
 
12
- def initialize(db_name)
12
+ def initialize(db_name, options = {})
13
13
  db_name = Config.complete_db_name(db_name)
14
14
  logger.info "Tracking #{db_name}"
15
+ logger.debug "Options: #{options.inspect}" if options.keys.any?
16
+ @options = options
15
17
  @db = CouchRest.new(Config.couch_host).database(db_name)
16
- read_seq(Config.seq_file) unless Config.flags.include?('--rerun')
18
+ read_seq(Config.seq_file) unless rerun?
17
19
  check_seq
18
20
  end
19
21
 
@@ -44,7 +46,7 @@ module CouchRest
44
46
  callbacks(hash)
45
47
  store_seq(hash["seq"])
46
48
  end
47
- logger.info "couch stream ended unexpectedly."
49
+ logger.info "couch stream ended unexpectedly." unless run_once?
48
50
  logger.debug result.inspect
49
51
  rescue MultiJson::LoadError
50
52
  # appearently MultiJson has issues with the end of the
@@ -63,11 +65,11 @@ module CouchRest
63
65
  end
64
66
 
65
67
  def feed_options
66
- if Config.flags.include?('--run-once')
68
+ if run_once?
67
69
  { :since => since }
68
70
  else
69
71
  { :feed => :continuous, :since => since, :heartbeat => 1000 }
70
- end
72
+ end.merge @options
71
73
  end
72
74
 
73
75
  def since
@@ -127,5 +129,12 @@ module CouchRest
127
129
  return hash["last_seq"]
128
130
  end
129
131
 
132
+ def rerun?
133
+ Config.flags.include?('--rerun')
134
+ end
135
+
136
+ def run_once?
137
+ Config.flags.include?('--run-once')
138
+ end
130
139
  end
131
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchrest_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-20 00:00:00.000000000 Z
12
+ date: 2013-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: couchrest