Class: Barcoder::Bucket
Instance Attribute Summary collapse
-
#import_hook ⇒ Object
Returns the value of attribute import_hook.
-
#name ⇒ Object
Returns the value of attribute name.
-
#persisted ⇒ Object
Returns the value of attribute persisted.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
-
.all(&block) ⇒ Object
Returns an array of all Buckets belonging to the account identified by the account_token (see Barcoder::Config).
- .bucket_uri(bucket) ⇒ Object
- .buckets_uri ⇒ Object
Instance Method Summary collapse
- #decode_from_file(filename) ⇒ Object
- #decode_from_string(string) ⇒ Object
- #method_missing(symbol, *args) ⇒ Object
-
#partial_imports(use_cache = true) ⇒ Object
Fetches partial_imports.
-
#recent_imports(since, use_cache = true) ⇒ Object
Fetches recent_imports.
-
#save ⇒ Object
Persists the Bucket.
-
#unmatched_pages(use_cache = true) ⇒ Object
Fetches unmatched_pages.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Barcoder::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/barcoder/bucket.rb', line 85 def method_missing(symbol, *args) # e.g., if users calls queue_unmatched_pages, add unmatched_pages_request # to hydra queue if symbol.to_s =~ /queue_(.*)/ request_method = "#{$1}_request" Barcoder::Config.hydra.queue send(request_method, *args) else super end end |
Instance Attribute Details
#import_hook ⇒ Object
Returns the value of attribute import_hook.
3 4 5 |
# File 'lib/barcoder/bucket.rb', line 3 def import_hook @import_hook end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/barcoder/bucket.rb', line 3 def name @name end |
#persisted ⇒ Object
Returns the value of attribute persisted.
3 4 5 |
# File 'lib/barcoder/bucket.rb', line 3 def persisted @persisted end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/barcoder/bucket.rb', line 3 def token @token end |
Class Method Details
.all(&block) ⇒ Object
Returns an array of all Buckets belonging to the account identified by the account_token (see Barcoder::Config).
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/barcoder/bucket.rb', line 9 def self.all(&block) response = Typhoeus::Request.new(buckets_uri).run buckets_data = response_to_json(response) buckets = buckets_data.map do |data| new(data.merge(persisted: true)) end buckets end |
Instance Method Details
#decode_from_file(filename) ⇒ Object
29 30 31 32 |
# File 'lib/barcoder/bucket.rb', line 29 def decode_from_file(filename) return false unless token.present? Barcoder::PDF.decode_from_file(self, filename) end |
#decode_from_string(string) ⇒ Object
34 35 36 37 |
# File 'lib/barcoder/bucket.rb', line 34 def decode_from_string(string) return false unless token.present? Barcoder::PDF.decode_from_string(self, string) end |
#partial_imports(use_cache = true) ⇒ Object
Fetches partial_imports.
This method is also queueable by calling #queue_partial_imports.
64 65 66 67 68 69 70 |
# File 'lib/barcoder/bucket.rb', line 64 def partial_imports(use_cache=true) (use_cache && @partial_imports) || begin partial_imports_request.run end @partial_imports end |
#recent_imports(since, use_cache = true) ⇒ Object
Fetches recent_imports.
This method is also queueable by calling #queue_recent_imports.
53 54 55 56 57 58 59 |
# File 'lib/barcoder/bucket.rb', line 53 def recent_imports(since, use_cache=true) (use_cache && @recent_imports) || begin recent_imports_request(since).run end @recent_imports end |
#save ⇒ Object
Persists the Bucket.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/barcoder/bucket.rb', line 73 def save return false unless valid? if !persisted create_bucket! else update_bucket! end true end |
#unmatched_pages(use_cache = true) ⇒ Object
Fetches unmatched_pages.
This method is also queueable by calling #queue_unmatched_pages.
42 43 44 45 46 47 48 |
# File 'lib/barcoder/bucket.rb', line 42 def unmatched_pages(use_cache=true) (use_cache && @unmatched_pages) || begin unmatched_pages_request.run end @unmatched_pages end |