flickr_cli 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/authentication.rb +2 -2
- data/lib/image_cutter.rb +12 -16
- data/lib/menu.rb +4 -4
- metadata +71 -89
data/lib/authentication.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module FlickrCli
|
2
2
|
module Authentication
|
3
3
|
def self.establish_session
|
4
|
-
auth_file =
|
4
|
+
auth_file = File.join(Dir.home, ".flickr_clirc")
|
5
5
|
FlickRaw.api_key = "e8505c88feb2c0cc9d2da6bcbe18767c"
|
6
6
|
FlickRaw.shared_secret = "d344de362ea86f0e"
|
7
7
|
|
8
8
|
if File.exists?(auth_file)
|
9
|
-
puts "authenticating
|
9
|
+
puts "authenticating with #{auth_file}"
|
10
10
|
data = YAML.load_file(auth_file)
|
11
11
|
auth = flickr.auth.checkToken :auth_token => data["api_token"]
|
12
12
|
else
|
data/lib/image_cutter.rb
CHANGED
@@ -1,31 +1,23 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
module FlickrCli
|
2
4
|
module ImageCutter
|
3
5
|
|
4
|
-
CHARS
|
6
|
+
CHARS = [" ", ".", "~", ":", "+", "=", "o", "*", "x", "^", "%", "#", "@", "$", "M", "W"]
|
5
7
|
FONT_ROWS = 8
|
6
8
|
FONT_COLS = 4
|
7
9
|
|
8
10
|
def self.convert_to_ascii(file)
|
9
11
|
|
10
12
|
img = Magick::Image.read(file).first
|
11
|
-
|
12
|
-
|
13
|
-
# about twice the size of the input, so if the original image is too
|
14
|
-
# large we need to make it smaller so the ASCII version won't be too
|
15
|
-
# big. The `change_geometry' method computes new dimensions for an
|
16
|
-
# image based on the geometry argument. The '320x320>' argument says
|
17
|
-
# "If the image is too big to fit in a 320x320 square, compute the
|
18
|
-
# dimensions of an image that will fit, but retain the original aspect
|
19
|
-
# ratio. If the image is already smaller than 320x320, keep the same
|
20
|
-
# dimensions."
|
21
|
-
img.change_geometry('728x728>') do |cols, rows|
|
22
|
-
img.resize!(cols, rows) if cols != img.columns || rows != img.rows
|
23
|
-
end
|
13
|
+
|
14
|
+
img.resize_to_fit!('728')
|
24
15
|
|
25
16
|
# Compute the image size in ASCII "pixels" and resize the image to have
|
26
17
|
# those dimensions. The resulting image does not have the same aspect
|
27
18
|
# ratio as the original, but since our "pixels" are twice as tall as
|
28
19
|
# they are wide we'll get our proportions back (roughly) when we render.
|
20
|
+
|
29
21
|
pr = img.rows / FONT_ROWS
|
30
22
|
pc = img.columns / FONT_COLS
|
31
23
|
img.resize!(pc, pr)
|
@@ -33,21 +25,25 @@ module FlickrCli
|
|
33
25
|
img = img.quantize(16, Magick::GRAYColorspace)
|
34
26
|
img = img.normalize
|
35
27
|
|
28
|
+
# Depending on compile-time options for ImageMagick - pixel instensity is stored in different scales
|
29
|
+
# This will calculate the correct denominator to use
|
30
|
+
quantum_calc = Magick::QuantumRange / Magick::QuantumPixel.to_i
|
31
|
+
|
36
32
|
# Draw the image surrounded by a border. The `view' method is slow but
|
37
33
|
# it makes it easy to address individual pixels. In grayscale images,
|
38
34
|
# all three RGB channels have the same value so the red channel is as
|
39
35
|
# good as any for choosing which character to represent the intensity of
|
40
36
|
# this particular pixel.
|
37
|
+
|
41
38
|
border = '+' + ('-' * pc) + '+'
|
42
39
|
puts border
|
43
40
|
|
44
41
|
img.view(0, 0, pc, pr) do |view|
|
45
42
|
pr.times do |i|
|
46
43
|
putc '|'
|
47
|
-
pc.times { |j| putc CHARS[view[i][j].red/
|
44
|
+
pc.times { |j| putc CHARS[view[i][j].red/quantum_calc] }
|
48
45
|
puts '|'
|
49
46
|
end
|
50
|
-
|
51
47
|
end
|
52
48
|
border
|
53
49
|
end
|
data/lib/menu.rb
CHANGED
@@ -3,7 +3,7 @@ module FlickrCli
|
|
3
3
|
|
4
4
|
def self.main_menu
|
5
5
|
choose do |menu|
|
6
|
-
menu.prompt = "What
|
6
|
+
menu.prompt = "What do you want to explore?"
|
7
7
|
menu.choice("Your Photostream") { menu_for(flickr.test.login.username) }
|
8
8
|
menu.choice("Contacts' Photostream") { contacts }
|
9
9
|
menu.choice("Quit") { end_program }
|
@@ -45,14 +45,14 @@ module FlickrCli
|
|
45
45
|
photos = flickr.photos.getSizes(:photo_id => picked_photo.id)
|
46
46
|
download_url = nil
|
47
47
|
|
48
|
-
["
|
48
|
+
["Large", "Medium"].each do |style|
|
49
49
|
if picture = photos.find{ |photo| photo.label == style }
|
50
50
|
download_url = picture.source
|
51
51
|
end
|
52
52
|
break if download_url
|
53
53
|
end
|
54
|
-
|
55
|
-
my_file = Tempfile.new(
|
54
|
+
|
55
|
+
my_file = Tempfile.new("tempimage#{File.basename(download_url)}")
|
56
56
|
my_file << Net::HTTP.get_response(URI.parse(download_url)).body
|
57
57
|
my_file.close
|
58
58
|
puts FlickrCli::ImageCutter.convert_to_ascii(my_file.path)
|
metadata
CHANGED
@@ -1,133 +1,115 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickr_cli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 5
|
10
|
-
version: 0.1.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Stephen Schor
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: highline
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 25
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 6
|
33
|
-
- 11
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.6.11
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: launchy
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.11
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: launchy
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
41
33
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 4
|
49
|
-
- 0
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
50
37
|
version: 0.4.0
|
51
38
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: flickraw
|
55
39
|
prerelease: false
|
56
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: flickraw
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
57
49
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 55
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
- 8
|
65
|
-
- 4
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
66
53
|
version: 0.8.4
|
67
54
|
type: :runtime
|
68
|
-
version_requirements: *id003
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rmagick
|
71
55
|
prerelease: false
|
72
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rmagick
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
73
65
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
81
70
|
type: :runtime
|
82
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
83
78
|
description: A Command-Line tool for exploring your flickr account
|
84
|
-
email:
|
79
|
+
email:
|
85
80
|
- beholdthepanda@gmail.com
|
86
|
-
executables:
|
81
|
+
executables:
|
87
82
|
- flickr_cli
|
88
83
|
extensions: []
|
89
|
-
|
90
84
|
extra_rdoc_files: []
|
91
|
-
|
92
|
-
files:
|
85
|
+
files:
|
93
86
|
- bin/flickr_cli
|
94
87
|
- lib/authentication.rb
|
95
88
|
- lib/flickr_cli.rb
|
96
89
|
- lib/image_cutter.rb
|
97
90
|
- lib/menu.rb
|
98
|
-
has_rdoc: true
|
99
91
|
homepage: https://github.com/nodanaonlyzuul/flickr_cli
|
100
92
|
licenses: []
|
101
|
-
|
102
93
|
post_install_message:
|
103
94
|
rdoc_options: []
|
104
|
-
|
105
|
-
require_paths:
|
95
|
+
require_paths:
|
106
96
|
- lib
|
107
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
98
|
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
|
113
|
-
|
114
|
-
- 0
|
115
|
-
version: "0"
|
116
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
104
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
segments:
|
123
|
-
- 0
|
124
|
-
version: "0"
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
125
109
|
requirements: []
|
126
|
-
|
127
110
|
rubyforge_project: nowarning
|
128
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.24
|
129
112
|
signing_key:
|
130
113
|
specification_version: 3
|
131
114
|
summary: A Command-Line tool for exploring your flickr account
|
132
115
|
test_files: []
|
133
|
-
|