Class: Specbandit::Publisher
- Inherits:
-
Object
- Object
- Specbandit::Publisher
- Defined in:
- lib/specbandit/publisher.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#key_ttl ⇒ Object
readonly
Returns the value of attribute key_ttl.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(key: Specbandit.configuration.key, key_ttl: Specbandit.configuration.key_ttl, queue: nil, output: $stdout) ⇒ Publisher
constructor
A new instance of Publisher.
-
#publish(files: [], pattern: nil) ⇒ Object
Resolve files from the three input sources (priority: stdin > pattern > args) and push them onto the Redis queue.
Constructor Details
#initialize(key: Specbandit.configuration.key, key_ttl: Specbandit.configuration.key_ttl, queue: nil, output: $stdout) ⇒ Publisher
Returns a new instance of Publisher.
9 10 11 12 13 14 15 |
# File 'lib/specbandit/publisher.rb', line 9 def initialize(key: Specbandit.configuration.key, key_ttl: Specbandit.configuration.key_ttl, queue: nil, output: $stdout) @key = key @key_ttl = key_ttl @queue = queue || RedisQueue.new @output = output end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/specbandit/publisher.rb', line 7 def key @key end |
#key_ttl ⇒ Object (readonly)
Returns the value of attribute key_ttl.
7 8 9 |
# File 'lib/specbandit/publisher.rb', line 7 def key_ttl @key_ttl end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
7 8 9 |
# File 'lib/specbandit/publisher.rb', line 7 def output @output end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/specbandit/publisher.rb', line 7 def queue @queue end |
Instance Method Details
#publish(files: [], pattern: nil) ⇒ Object
Resolve files from the three input sources (priority: stdin > pattern > args) and push them onto the Redis queue.
Returns the number of files enqueued.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/specbandit/publisher.rb', line 21 def publish(files: [], pattern: nil) resolved = resolve_files(files: files, pattern: pattern) if resolved.empty? output.puts '[specbandit] No files to enqueue.' return 0 end queue.push(key, resolved, ttl: key_ttl) output.puts "[specbandit] Enqueued #{resolved.size} files onto key '#{key}' (TTL: #{key_ttl}s)." resolved.size end |