termapinator 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'termapinator'
4
+ require 'optparse'
4
5
 
5
- query = ARGV.join(' ')
6
- Termapinator.run(query)
6
+ options = {}
7
+
8
+ optparse = OptionParser.new do |o|
9
+ o.banner = 'Usage: termapinator QUERY [OPTIONS]'
10
+
11
+ o.on('-z', '--zoom ZOOM', 'zoom level of image') do |zoom|
12
+ options[:zoom] = zoom
13
+ end
14
+ end
15
+
16
+ optparse.parse!
17
+
18
+ query = ARGV.first
19
+ options[:center] = query
20
+
21
+ Termapinator.run(options)
@@ -4,28 +4,29 @@ require 'termapinator/version'
4
4
  require 'open-uri'
5
5
  require 'chunky_png'
6
6
  require 'rainbow'
7
+ require 'optparse'
7
8
 
8
9
  module Termapinator
9
- def self.run(query)
10
- image = load_image(google_maps_request(query))
10
+ DEFAULT_OPTIONS = {
11
+ size: '640x640',
12
+ sensor: true,
13
+ style: 'element:labels|visibility:off'
14
+ }
15
+
16
+ def self.run(options)
17
+ image = load_image(google_maps_request(options))
11
18
  ascii = image_to_ascii(image)
12
19
  puts ascii
13
20
  end
14
21
 
15
- def self.google_maps_request(query)
16
- params = {
17
- center: query,
18
- size: '640x640',
19
- sensor: true,
20
- style: 'element:labels|visibility:off',
21
- zoom: 15
22
- }
23
-
22
+ def self.google_maps_request(options)
24
23
  uri = URI.parse("http://maps.googleapis.com/maps/api/staticmap")
24
+ params = DEFAULT_OPTIONS.merge(options)
25
25
  uri.query = params.map { |k, v| "#{k}=#{URI.escape(v.to_s)}" }.join('&')
26
26
  uri
27
27
  end
28
28
 
29
+
29
30
  def self.load_image(url)
30
31
  image = nil
31
32
 
@@ -1,3 +1,3 @@
1
1
  module Termapinator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termapinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: 1250386690485838814
93
+ hash: 2829485629610065924
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: 1250386690485838814
102
+ hash: 2829485629610065924
103
103
  requirements: []
104
104
  rubyforge_project:
105
105
  rubygems_version: 1.8.23