cloudapp 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudapp (0.0.11)
4
+ cloudapp (0.0.12)
5
5
  addressable
6
6
  faraday (~> 0.8.0.rc2)
7
- formatador
8
7
  gli
8
+ highline
9
9
  leadlight
10
10
  typhoeus
11
11
 
@@ -19,8 +19,8 @@ GEM
19
19
  faraday (0.8.0.rc2)
20
20
  multipart-post (~> 1.1)
21
21
  fattr (2.2.1)
22
- formatador (0.2.1)
23
22
  gli (1.5.1)
23
+ highline (1.6.11)
24
24
  hookr (1.1.1)
25
25
  fail-fast (= 1.0.0)
26
26
  hpricot (0.8.6)
data/README.md CHANGED
@@ -19,9 +19,9 @@ goal of `cloudapp` is to be simple and Unix-friendly.
19
19
  ### Quick Start
20
20
 
21
21
  gem install cloudapp
22
- cloudapp --email=EMAIL --password=PASSWORD initconfig
23
22
  cloudapp list
24
23
  cloudapp bookmark http://douglasadams.com
24
+ cloduapp upload ~/Desktop/screenshot.png
25
25
 
26
26
  ### Usage
27
27
 
@@ -63,15 +63,11 @@ the picture.
63
63
 
64
64
  ### Security Considerations
65
65
 
66
- As of right now, `cloudapp` makes use of
67
- [`gli`'s built-in configuration handling][gli-config] to store your CloudApp
68
- credentials **in plain text** at `~/.cloudapp.rc`. You'll be prompted to run the
69
- following command if the global `--email` and `--password` options aren't
70
- provided:
66
+ Your credentials are stored **in plain text** at `~/.cloudapprc`. If this
67
+ worries you, keep an eye on [issue #10][issue-10]. Some sort of non-plaintext
68
+ authentication is planned before 1.0 is released.
71
69
 
72
- cloudapp --email=EMAIL --password=PASSWORD initconfig
73
-
74
- [gli-config]: https://github.com/davetron5000/gli/wiki/Config
70
+ [issue-10]: https://github.com/cloudapp/cloudapp/issues/10
75
71
 
76
72
  ### Harness the Power
77
73
 
data/bin/cloudapp CHANGED
@@ -3,8 +3,9 @@ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
3
 
4
4
  require 'rubygems'
5
5
  require 'gli'
6
- require 'formatador'
6
+ require 'highline'
7
7
  require 'pathname'
8
+ require 'yaml'
8
9
 
9
10
  require 'cloudapp'
10
11
  require 'cloudapp/drop_presenter'
@@ -12,30 +13,58 @@ require 'cloudapp/drop_service'
12
13
  require 'cloudapp/identity'
13
14
 
14
15
 
15
- def service(global_options)
16
- identity = CloudApp::Identity.from_config global_options
16
+ def service
17
17
  CloudApp::DropService.as_identity(identity).tap do |service|
18
18
  service.logger.level = Logger::WARN
19
19
  end
20
20
  end
21
21
 
22
- def check_for_credentials(global_options)
23
- return unless global_options[:email].nil? and global_options[:password].nil?
22
+ def config_file
23
+ File.expand_path '~/.cloudapprc'
24
+ end
24
25
 
25
- exit_now! [
26
- 'CloudApp credentials missing. Save them to ~/.cloudapp.rc using:',
27
- ' cloudapp --email=<email> --password=<password> initconfig' ].join("\n"),
28
- 1
26
+ def identity
27
+ return unless File.exist?(config_file)
28
+ config = File.open(config_file) {|file| YAML::load(file) }
29
+ CloudApp::Identity.from_config config
29
30
  end
30
31
 
31
- def format_from(global_options)
32
- set_default_format global_options
33
- global_options[:format].to_sym
32
+ def save_identity(email, password)
33
+ File.open(config_file, 'w', 0600) do |file|
34
+ YAML.dump({ email: email, password: password }, file)
35
+ end
36
+ end
37
+
38
+ def color(*args)
39
+ HighLine.new.color *args
34
40
  end
35
41
 
36
- def set_default_format(global_options)
37
- return unless global_options[:format].nil?
38
- global_options[:format] = $stdout.tty? ? :pretty : :csv
42
+ def plain_text_credentials_warning
43
+ """
44
+ #{ color('WARNING', :bold) }
45
+ Your credentials are stored #{ color('in plain text', :bold) } at ~/.cloudapprc. If this worries you,
46
+ keep an eye on issue #10 (https://github.com/cloudapp/cloudapp/issues/10). Some
47
+ sort of non-plaintext authentication is planned before 1.0 is released.
48
+ """
49
+ end
50
+
51
+ def check_for_credentials
52
+ return unless identity.nil?
53
+
54
+ $stdout.puts [ plain_text_credentials_warning,
55
+ 'Sign into your CloudApp account.' ]
56
+
57
+ email = HighLine.new.ask('Email: ')
58
+ password = HighLine.new.ask('Password: ') {|q| q.echo = false }
59
+ save_identity email, password
60
+ end
61
+
62
+ def format_from(global_options)
63
+ if global_options[:format].nil?
64
+ $stdout.tty? ? :pretty : :csv
65
+ else
66
+ global_options[:format].to_sym
67
+ end
39
68
  end
40
69
 
41
70
  def privacy_from(options)
@@ -49,15 +78,6 @@ include GLI
49
78
 
50
79
  program_desc 'All the pleasures of CloudApp now at your terminal'
51
80
  version CloudApp::VERSION
52
- config_file '.cloudapp.rc'
53
-
54
- desc 'CloudApp account email'
55
- arg_name 'email'
56
- flag :email
57
-
58
- desc 'CloudApp account password'
59
- arg_name 'password'
60
- flag :password
61
81
 
62
82
  desc 'Output format (default: pretty for tty, csv otherwise)'
63
83
  arg_name 'csv|pretty'
@@ -74,7 +94,7 @@ command [:bookmark, :shorten] do |c|
74
94
  c.switch :public
75
95
 
76
96
  c.action do |global_options, options, urls|
77
- check_for_credentials global_options
97
+ check_for_credentials
78
98
  format = format_from global_options
79
99
  private = privacy_from options
80
100
 
@@ -88,7 +108,7 @@ command [:bookmark, :shorten] do |c|
88
108
  new_options = { url: url }
89
109
  new_options[:private] = private unless private.nil?
90
110
 
91
- new_drop = service(global_options).create new_options
111
+ new_drop = service.create new_options
92
112
  new_drop.url
93
113
  end
94
114
  end
@@ -106,7 +126,7 @@ command :upload do |c|
106
126
  c.switch :public
107
127
 
108
128
  c.action do |global_options, options, files|
109
- check_for_credentials global_options
129
+ check_for_credentials
110
130
  format = format_from global_options
111
131
  private = privacy_from options
112
132
 
@@ -120,7 +140,7 @@ command :upload do |c|
120
140
  new_options = { path: file }
121
141
  new_options[:private] = private unless private.nil?
122
142
 
123
- new_drop = service(global_options).create new_options
143
+ new_drop = service.create new_options
124
144
  new_drop.url
125
145
  end
126
146
  end
@@ -136,7 +156,7 @@ command [:list, :ls] do |c|
136
156
  c.flag :n, :count
137
157
 
138
158
  c.action do |global_options, options, args|
139
- check_for_credentials global_options
159
+ check_for_credentials
140
160
 
141
161
  count = options[:count].to_i
142
162
  columns = { name: 'Name', url: 'Link', view_counter: 'Views' }
@@ -145,7 +165,7 @@ command [:list, :ls] do |c|
145
165
  CloudApp::DropPresenter.print(on: $stdout,
146
166
  columns: columns,
147
167
  format: format) do
148
- service(global_options).drops count
168
+ service.drops count
149
169
  end
150
170
  end
151
171
  end
data/cloudapp.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'cloudapp'
16
- s.version = '0.0.11'
16
+ s.version = '0.0.12'
17
17
  s.date = '2012-02-10'
18
18
  s.rubyforge_project = 'cloudapp'
19
19
 
@@ -45,8 +45,8 @@ Gem::Specification.new do |s|
45
45
  ## that are needed for an end user to actually USE your code.
46
46
  s.add_dependency 'addressable'
47
47
  s.add_dependency 'faraday', '~> 0.8.0.rc2'
48
- s.add_dependency 'formatador'
49
48
  s.add_dependency 'gli'
49
+ s.add_dependency 'highline'
50
50
  s.add_dependency 'leadlight'
51
51
  s.add_dependency 'typhoeus'
52
52
 
@@ -1,6 +1,5 @@
1
1
  require 'csv'
2
2
  require 'delegate'
3
- require 'formatador'
4
3
 
5
4
  module CloudApp
6
5
  class DropPresenter
data/lib/cloudapp.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CloudApp
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
data/man/cloudapp.1 CHANGED
@@ -7,7 +7,7 @@
7
7
  \fBcloudapp\fR \- All the pleasures of CloudApp now at your terminal
8
8
  .
9
9
  .SH "SYNOPSIS"
10
- \fBcloudapp\fR [\fB\-\-email\fR=\fIemail\fR] [\fB\-\-password\fR=\fIpassword\fR] \fIcommand\fR [\fIargs\fR]
10
+ \fBcloudapp\fR [\fB\-\-format\fR=\fIformat\fR] \fIcommand\fR [\fIargs\fR]
11
11
  .
12
12
  .br
13
13
  \fBcloudapp list\fR [\fB\-\-count\fR=\fIcount\fR]
@@ -24,14 +24,6 @@
24
24
  .SH "GLOBAL OPTIONS"
25
25
  .
26
26
  .TP
27
- \fB\-\-email\fR=\fIemail\fR
28
- Use \fIemail\fR for CloudApp account credentials\.
29
- .
30
- .TP
31
- \fB\-\-password\fR=\fIpassword\fR
32
- Use \fIpassword\fR for CloudApp account credentials\.
33
- .
34
- .TP
35
27
  \fB\-f\fR \fIformat\fR, \fB\-\-format\fR=\fIformat\fR
36
28
  Output using either \fBpretty\fR or \fBcsv\fR format\. (Default: \fBpretty\fR when output to a terminal and \fBcsv\fR when output is piped to another program\.)
37
29
  .
@@ -179,7 +171,7 @@ http://cl\.ly/1y0j403g3D0c0X1G0R3m
179
171
  .IP "" 0
180
172
  .
181
173
  .SH "SECURITY CONSIDERATIONS"
182
- As of right now, \fBcloudapp\fR makes use of \fBgli\fR\'s built\-in configuration handling \fIhttps://github\.com/davetron5000/gli/wiki/Config\fR to store your CloudApp credentials \fBin plain text\fR at \fB~/\.cloudapp\.rc\fR\.
174
+ Your credentials are stored \fBin plain text\fR at \fB~/\.cloudapprc\fR\. If this worries you, keep an eye on issue #10 \fIhttps://github\.com/cloudapp/cloudapp/issues/10\fR\. Some sort of non\-plaintext authentication is planned before 1\.0 is released\.
183
175
  .
184
176
  .SH "LICENSE"
185
177
  \fBcloudapp\fR is distributed under the MIT license \fIhttps://github\.com/cloudapp/cloudapp/blob/master/MIT\-LICENSE\fR\.
data/man/cloudapp.1.html CHANGED
@@ -83,7 +83,7 @@
83
83
 
84
84
  <h2 id="SYNOPSIS">SYNOPSIS</h2>
85
85
 
86
- <p><code>cloudapp</code> [<code>--email</code>=<var>email</var>] [<code>--password</code>=<var>password</var>] <var>command</var> [<var>args</var>]<br />
86
+ <p><code>cloudapp</code> [<code>--format</code>=<var>format</var>] <var>command</var> [<var>args</var>]<br />
87
87
  <code>cloudapp list</code> [<code>--count</code>=<var>count</var>]<br />
88
88
  <code>cloudapp bookmark</code> [<code>--private</code>] [<code>--public</code>] <var>url</var> [<var>url</var>...]<br />
89
89
  <code>cloudapp upload</code> [<code>--private</code>] [<code>--public</code>] <var>file</var> [<var>file</var>...]</p>
@@ -97,10 +97,8 @@ terminal and other times it's the only tool available.</p>
97
97
  <h2 id="GLOBAL-OPTIONS">GLOBAL OPTIONS</h2>
98
98
 
99
99
  <dl>
100
- <dt><code>--email</code>=<var>email</var></dt><dd><p>Use <var>email</var> for CloudApp account credentials.</p></dd>
101
- <dt><code>--password</code>=<var>password</var></dt><dd><p>Use <var>password</var> for CloudApp account credentials.</p></dd>
102
- <dt><code>-f</code> <var>format</var>, <code>--format</code>=<var>format</var></dt><dd><p>Output using either <strong>pretty</strong> or <strong>csv</strong> format. (Default: <strong>pretty</strong> when
103
- output to a terminal and <strong>csv</strong> when output is piped to another program.)</p></dd>
100
+ <dt><code>-f</code> <var>format</var>, <code>--format</code>=<var>format</var></dt><dd>Output using either <strong>pretty</strong> or <strong>csv</strong> format. (Default: <strong>pretty</strong> when
101
+ output to a terminal and <strong>csv</strong> when output is piped to another program.)</dd>
104
102
  </dl>
105
103
 
106
104
 
@@ -185,9 +183,9 @@ http://cl.ly/1y0j403g3D0c0X1G0R3m
185
183
 
186
184
  <h2 id="SECURITY-CONSIDERATIONS">SECURITY CONSIDERATIONS</h2>
187
185
 
188
- <p>As of right now, <code>cloudapp</code> makes use of
189
- <a href="https://github.com/davetron5000/gli/wiki/Config"><code>gli</code>'s built-in configuration handling</a> to store your CloudApp
190
- credentials <strong>in plain text</strong> at <code>~/.cloudapp.rc</code>.</p>
186
+ <p>Your credentials are stored <strong>in plain text</strong> at <code>~/.cloudapprc</code>. If this
187
+ worries you, keep an eye on <a href="https://github.com/cloudapp/cloudapp/issues/10">issue #10</a>. Some sort of non-plaintext
188
+ authentication is planned before 1.0 is released.</p>
191
189
 
192
190
  <h2 id="LICENSE">LICENSE</h2>
193
191
 
data/man/cloudapp.1.ronn CHANGED
@@ -3,7 +3,7 @@ cloudapp(1) -- All the pleasures of CloudApp now at your terminal
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `cloudapp` [`--email`=<email>] [`--password`=<password>] <command> [<args>]<br>
6
+ `cloudapp` [`--format`=<format>] <command> [<args>]<br>
7
7
  `cloudapp list` [`--count`=<count>]<br>
8
8
  `cloudapp bookmark` [`--private`] [`--public`] <url> [<url>...]<br>
9
9
  `cloudapp upload` [`--private`] [`--public`] <file> [<file>...]
@@ -16,12 +16,6 @@ terminal and other times it's the only tool available.
16
16
 
17
17
  ## GLOBAL OPTIONS
18
18
 
19
- * `--email`=<email>:
20
- Use <email> for CloudApp account credentials.
21
-
22
- * `--password`=<password>:
23
- Use <password> for CloudApp account credentials.
24
-
25
19
  * `-f` <format>, `--format`=<format>:
26
20
  Output using either **pretty** or **csv** format. (Default: **pretty** when
27
21
  output to a terminal and **csv** when output is piped to another program.)
@@ -105,12 +99,11 @@ Share a new bookmark and output only the URL:
105
99
 
106
100
  ## SECURITY CONSIDERATIONS
107
101
 
108
- As of right now, `cloudapp` makes use of
109
- [`gli`'s built-in configuration handling][gli-config] to store your CloudApp
110
- credentials **in plain text** at `~/.cloudapp.rc`.
111
-
112
- [gli-config]: https://github.com/davetron5000/gli/wiki/Config
102
+ Your credentials are stored **in plain text** at `~/.cloudapprc`. If this
103
+ worries you, keep an eye on [issue #10][issue-10]. Some sort of non-plaintext
104
+ authentication is planned before 1.0 is released.
113
105
 
106
+ [issue-10]: https://github.com/cloudapp/cloudapp/issues/10
114
107
 
115
108
  ## LICENSE
116
109
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &70186632051880 !ruby/object:Gem::Requirement
16
+ requirement: &70172752917860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70186632051880
24
+ version_requirements: *70172752917860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &70186632051180 !ruby/object:Gem::Requirement
27
+ requirement: &70172752917320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.0.rc2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70186632051180
35
+ version_requirements: *70172752917320
36
36
  - !ruby/object:Gem::Dependency
37
- name: formatador
38
- requirement: &70186632050560 !ruby/object:Gem::Requirement
37
+ name: gli
38
+ requirement: &70172752916840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70186632050560
46
+ version_requirements: *70172752916840
47
47
  - !ruby/object:Gem::Dependency
48
- name: gli
49
- requirement: &70186632049100 !ruby/object:Gem::Requirement
48
+ name: highline
49
+ requirement: &70172752916360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70186632049100
57
+ version_requirements: *70172752916360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: leadlight
60
- requirement: &70186632048540 !ruby/object:Gem::Requirement
60
+ requirement: &70172752915680 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70186632048540
68
+ version_requirements: *70172752915680
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: typhoeus
71
- requirement: &70186632047680 !ruby/object:Gem::Requirement
71
+ requirement: &70172752915080 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70186632047680
79
+ version_requirements: *70172752915080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70186632046640 !ruby/object:Gem::Requirement
82
+ requirement: &70172752914500 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70186632046640
90
+ version_requirements: *70172752914500
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ronn
93
- requirement: &70186632046180 !ruby/object:Gem::Requirement
93
+ requirement: &70172752914080 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70186632046180
101
+ version_requirements: *70172752914080
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &70186632045720 !ruby/object:Gem::Requirement
104
+ requirement: &70172752913640 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70186632045720
112
+ version_requirements: *70172752913640
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: vcr
115
- requirement: &70186632045180 !ruby/object:Gem::Requirement
115
+ requirement: &70172752912680 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 2.0.0.rc1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70186632045180
123
+ version_requirements: *70172752912680
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: webmock
126
- requirement: &70186632044720 !ruby/object:Gem::Requirement
126
+ requirement: &70172752911760 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70186632044720
134
+ version_requirements: *70172752911760
135
135
  description: Experience all the pleasures of sharing with CloudApp now in your terminal.
136
136
  email: larry@marburger.cc
137
137
  executables: