Class: Ggggsss::Command
- Inherits:
-
Object
- Object
- Ggggsss::Command
- Defined in:
- lib/ggggsss.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(args) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(args) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ggggsss.rb', line 10 def initialize(args) @bucket_name = '' opt_parser = OptionParser.new opt_parser.on('-b BUCKET_NAME', '--bucket-name BUCKET_NAME') {|name| @bucket_name = name } opt_parser.parse!(args) @keyword, @path = *args end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/ggggsss.rb', line 8 def bucket_name @bucket_name end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
8 9 10 |
# File 'lib/ggggsss.rb', line 8 def keyword @keyword end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/ggggsss.rb', line 8 def path @path end |
Instance Method Details
#execute! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ggggsss.rb', line 20 def execute! fetcher = S3Fetcher.new(@bucket_name, @path) fetcher.fetch! fetcher.objects.each do |s3_object| collector = LineCollector.new(s3_object.body, @keyword) collector.collect! printer = ResultPrinter.new(s3_object.key, collector.results) printer.print rescue => e puts "#{s3_object.key}: #{e.}" end end |