cloudapp-cli 1.0.0.beta.6 → 1.0.0.beta.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,36 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudapp-cli (1.0.0.beta.6)
5
- clipboard
6
- cloudapp (~> 2.0.0.beta.1)
7
- ffi-ncurses
8
- highline
9
- ruby-termios
4
+ cloudapp-cli (1.0.0.beta.7)
5
+ cloudapp (~> 2.0.0.beta.4)
6
+ netrc (~> 0.7.7)
10
7
 
11
8
  GEM
12
9
  remote: http://rubygems.org/
13
10
  specs:
14
11
  addressable (2.2.8)
15
- clipboard (1.0.1)
16
- cloudapp (2.0.0.beta.2)
17
- leadlight
12
+ cloudapp (2.0.0.beta.4)
13
+ leadlight (~> 0.0.7)
18
14
  typhoeus (~> 0.3.3)
19
- diff-lcs (1.1.3)
20
15
  fail-fast (1.0.0)
21
16
  faraday (0.8.1)
22
17
  multipart-post (~> 1.1)
23
18
  fattr (2.2.1)
24
- ffi (1.1.5)
25
- ffi-locale (1.0.1)
26
- ffi (>= 1.0.9)
27
- ffi-ncurses (0.4.0)
28
- ffi (>= 1.0.9)
29
- ffi-locale (>= 1.0.0)
30
- highline (1.6.13)
31
19
  hookr (1.1.1)
32
20
  fail-fast (= 1.0.0)
33
- hpricot (0.8.6)
34
21
  leadlight (0.0.7)
35
22
  addressable (~> 2.2.0)
36
23
  faraday (= 0.8.1)
@@ -43,22 +30,8 @@ GEM
43
30
  mime-types (1.19)
44
31
  multi_json (1.0.4)
45
32
  multipart-post (1.1.5)
46
- mustache (0.99.4)
33
+ netrc (0.7.7)
47
34
  rake (0.9.2.2)
48
- rdiscount (1.6.8)
49
- ronn (0.7.3)
50
- hpricot (>= 0.8.2)
51
- mustache (>= 0.7.0)
52
- rdiscount (>= 1.5.8)
53
- rspec (2.11.0)
54
- rspec-core (~> 2.11.0)
55
- rspec-expectations (~> 2.11.0)
56
- rspec-mocks (~> 2.11.0)
57
- rspec-core (2.11.1)
58
- rspec-expectations (2.11.2)
59
- diff-lcs (~> 1.1.3)
60
- rspec-mocks (2.11.2)
61
- ruby-termios (0.9.6)
62
35
  typhoeus (0.3.3)
63
36
  mime-types
64
37
 
@@ -68,5 +41,3 @@ PLATFORMS
68
41
  DEPENDENCIES
69
42
  cloudapp-cli!
70
43
  rake
71
- ronn
72
- rspec
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # CloudApp CLI
2
2
 
3
- Experience all the pleasures of sharing with [CloudApp][] from your terminal
4
- using a gorgeous and cutting-edge ncurses text user interface.
3
+ Experience all the pleasures of sharing with [CloudApp][] from your terminal.
5
4
 
6
5
  [cloudapp]: http://getcloudapp.com
7
6
 
@@ -14,24 +13,36 @@ using a gorgeous and cutting-edge ncurses text user interface.
14
13
  ## Getting Started
15
14
 
16
15
  ``` bash
17
- gem install cloudapp
18
- cloudapp
16
+ $ gem install cloudapp-cli
17
+ $ cloudapp upload screenshot.png
18
+ $ cloudapp bookmark http://getcloudapp.com
19
19
  ```
20
20
 
21
- ## Wish List
21
+ ## Commands
22
22
 
23
- Along with the ncurses interface, a few simple commands to allow scripting and
24
- input from other Unix programs would be ideal.
23
+ ### cloudapp upload
25
24
 
26
- ### Phase: One
25
+ ``` bash
26
+ $ cloudapp upload screenshot.png
27
+ http://cl.ly/abc123
28
+ ```
27
29
 
28
- - Bookmark a link: `cloudapp bookmark http://getcloudapp.com`
29
- - Bookmark several links: `cloudapp bookmark http://douglasadams.com http://zombo.com`
30
- - Share a file: `cloudapp upload screenshot.png`
31
- - Share several files: `cloudapp upload *.png`
30
+ ### cloudapp bookmark
32
31
 
33
- ### Phase: Two
32
+ ``` bash
33
+ $ cloudapp bookmark http://getcloudapp.com
34
+ http://cl.ly/abc123
35
+ ```
34
36
 
37
+ ## Wish List
38
+
39
+ A few simple commands to allow scripting and input from other Unix programs
40
+ would be ideal.
41
+
42
+ ### Phase: Next
43
+
44
+ - Share several files: `cloudapp upload *.png`
45
+ - Bookmark several links: `cloudapp bookmark http://douglasadams.com http://zombo.com`
35
46
  - Handle bookmarks from STDIN: `pbpaste | cloudapp bookmark`
36
47
  - Handle files from STDIN: `find *.png | cloudapp upload`
37
48
  - Download a drop: `cloudapp download http://cl.ly/abc123`
data/Rakefile CHANGED
@@ -41,20 +41,6 @@ def replace_header(head, header_name)
41
41
  head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
42
42
  end
43
43
 
44
- #############################################################################
45
- #
46
- # Standard tasks
47
- #
48
- #############################################################################
49
-
50
- require 'rspec'
51
- require 'rspec/core/rake_task'
52
-
53
- desc "Run all specs"
54
- task RSpec::Core::RakeTask.new('spec')
55
-
56
- task :default => "spec"
57
-
58
44
  #############################################################################
59
45
  #
60
46
  # Custom tasks (add your own tasks here)
data/bin/cloudapp CHANGED
@@ -1,230 +1,153 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'cloudapp'
4
- require 'cloudapp/cli'
5
- require 'clipboard'
6
- require 'highline'
7
- require 'ffi-ncurses'
8
-
9
- include FFI::NCurses
3
+ # cloudapp file /path/to/file.png
4
+ # cloudapp bookmark http://google.com
5
+ # cloudapp file /path/to/file.png --private --name=File
6
+ # > http://cl.ly/abc123
10
7
 
11
- def config
12
- CloudApp::CLI::Config.new
13
- end
14
-
15
- def account
16
- CloudApp::Account.using_token config.token
17
- end
18
-
19
- def require_credentials
20
- return unless config.token.nil?
8
+ require 'cloudapp'
9
+ require 'uri'
21
10
 
22
- $stdout.puts 'Sign into your CloudApp account.'
11
+ # Taken from the heroku gem.
12
+ # https://github.com/heroku/heroku/blob/master/lib/heroku/auth.rb
13
+ require 'netrc'
23
14
 
24
- email = HighLine.new.ask('Email: ')
25
- password = HighLine.new.ask('Password: ') {|q| q.echo = false }
26
- config.token = CloudApp::Token.for_account email, password
27
- end
15
+ class Credentials
16
+ def self.token
17
+ new.credentials.last
18
+ end
28
19
 
29
- def log(*args)
30
- return unless File.exists?('log/curses.txt')
31
- File.open('log/curses.txt', 'ab+') do |file|
32
- file.puts args.inspect
20
+ def netrc_path
21
+ default = Netrc.default_path
22
+ encrypted = default + ".gpg"
23
+ if File.exists?(encrypted)
24
+ encrypted
25
+ else
26
+ default
27
+ end
33
28
  end
34
- end
35
29
 
30
+ def netrc
31
+ @netrc ||= begin
32
+ File.exists?(netrc_path) && Netrc.read(netrc_path)
33
+ rescue => error
34
+ if error.message =~ /^Permission bits for/
35
+ perm = File.stat(netrc_path).mode & 0777
36
+ abort("Permissions #{perm} for '#{netrc_path}' are too open. You should run `chmod 0600 #{netrc_path}` so that your credentials are NOT accessible by others.")
37
+ else
38
+ raise error
39
+ end
40
+ end
41
+ end
36
42
 
37
- def draw_drops_window(drops)
38
- # 1 column wider than necessary to prevent wrapping also accounting for
39
- # selection indicator.
40
- width = drops.map {|drop| drop.name.size }.max + 3
41
- height = drops.size * 3
42
- col = (COLS() - width) / 2 - 1
43
- row = (LINES() - height) / 2 - 1
43
+ def credentials=(credentials) @credentials = credentials end
44
+ def credentials()
45
+ (@credentials ||= read_credentials) || ask_for_and_save_credentials
46
+ end
44
47
 
45
- wrap = newwin height + 2, width + 2, row, col
46
- box wrap, 0, 0
47
- wrefresh wrap
48
+ def read_credentials
49
+ # TODO: convert legacy credentials to netrc
50
+ # if File.exists?(legacy_credentials_path)
51
+ # @api, @client = nil
52
+ # @credentials = File.read(legacy_credentials_path).split("\n")
53
+ # write_credentials
54
+ # FileUtils.rm_f(legacy_credentials_path)
55
+ # end
56
+
57
+ # read netrc credentials if they exist
58
+ self.credentials = netrc['api.getcloudapp.com'] if netrc
59
+ end
48
60
 
49
- win = derwin wrap, height, width, 1, 1
61
+ def write_credentials
62
+ FileUtils.mkdir_p(File.dirname(netrc_path))
63
+ FileUtils.touch(netrc_path)
64
+ FileUtils.chmod(0600, netrc_path)
65
+ netrc['api.getcloudapp.com'] = credentials
66
+ netrc.save
67
+ end
50
68
 
51
- drops.each do |drop|
52
- drop_lines(drop).each do |line|
53
- waddstr win, ' '
54
- waddstr win, line
55
- waddstr win, "\n"
69
+ def delete_credentials
70
+ # TODO: delete legacy credentials
71
+ # if File.exists?(legacy_credentials_path)
72
+ # FileUtils.rm_f(legacy_credentials_path)
73
+ # end
74
+ if netrc
75
+ netrc.delete('api.getcloudapp.com')
76
+ netrc.save
56
77
  end
57
- waddstr win, "\n"
78
+ self.credentials = nil
58
79
  end
59
- wrefresh win
60
80
 
61
- # Enabling the keypad allows the use of the arrow keys. I don't know why. With
62
- # the keypad either enabled or disabled the the would-be arrow keys on some
63
- # keyboard keypads don't work as arrow keys (8=up, 2=down, etc).
64
- keypad win, true
81
+ def ask_for_and_save_credentials
82
+ self.credentials = ask_for_credentials
83
+ write_credentials
84
+ credentials
85
+ end
65
86
 
66
- [ win, wrap ]
67
- end
87
+ def ask_for_credentials
88
+ puts "Enter your CloudApp credentials."
68
89
 
69
- def drop_lines(drop)
70
- details = " #{ pretty_date(drop.created) } (#{ drop.views })"
71
- [ drop.name, details ]
72
- end
90
+ print "Email: "
91
+ email = ask
73
92
 
74
- def select_drop(win, selected_drop, drops)
75
- # Stay within bounds.
76
- selected_drop = [ 0,
77
- [ drops.size - 1, selected_drop ].min
78
- ].max
93
+ print "Password (typing will be hidden): "
94
+ password = ask_for_password
79
95
 
80
- line = selected_drop * 3
81
- mvwaddch win, line, 0, ?>.ord
82
- wmove win, line, 0
83
-
84
- selected_drop
85
- end
96
+ token = CloudApp::Service.token_for_account email, password
97
+ unless token
98
+ puts "Incorrect email or password."
99
+ puts
100
+ delete_credentials
101
+ return ask_for_credentials
102
+ end
86
103
 
87
- def pretty_date(date)
88
- diff = (Time.now - date.to_time).to_i
89
- case diff
90
- when 0 then 'just now'
91
- when 1 then 'a second ago'
92
- when 2..59 then diff.to_s+' seconds ago'
93
- when 60..119 then 'a minute ago' #120 = 2 minutes
94
- when 120..3540 then (diff/60).to_i.to_s+' minutes ago'
95
- when 3541..7100 then 'an hour ago' # 3600 = 1 hour
96
- when 7101..82800 then ((diff+99)/3600).to_i.to_s+' hours ago'
97
- when 82801..172000 then 'a day ago' # 86400 = 1 day
98
- when 172001..518400 then ((diff+800)/(60*60*24)).to_i.to_s+' days ago'
99
- when 518400..1036800 then 'a week ago'
100
- else ((diff+180000)/(60*60*24*7)).to_i.to_s+' weeks ago'
104
+ [ email, token ]
101
105
  end
102
- end
103
106
 
104
- def popup_window(parent, text)
105
- text_width = text.lines.map{ |x| x.size }.max
106
- text_height = text.lines.to_a.size
107
- rows, cols = !parent.nil? ? getmaxyx(parent) : [ LINES(), COLS() ]
108
- width = text_width + 4
109
- height = text_height + 4
110
- col = (cols - width) / 2
111
- row = (rows - height) / 2
112
-
113
- if parent
114
- frame = derwin parent, height, width, row, col
115
- else
116
- frame = newwin height, width, row, col
107
+ def ask() $stdin.gets.to_s.strip end
108
+ def ask_for_password
109
+ echo_off
110
+ password = ask
111
+ puts
112
+ echo_on
113
+ return password
117
114
  end
118
115
 
119
- werase frame
120
- box frame, 0, 0
121
-
122
- win = derwin frame, text_height, text_width, 2, 2
123
- wmove win, 0, 0
124
- waddstr win, text
125
-
126
- wrefresh frame
127
- wrefresh win
128
-
129
- if block_given?
116
+ def echo_on() with_tty { system "stty echo" } end
117
+ def echo_off() with_tty { system "stty -echo" } end
118
+ def with_tty(&block)
119
+ return unless $stdin.isatty
130
120
  yield
131
- else
132
- ch = wgetch win
133
- flushinp
134
- ungetch ch
121
+ rescue
122
+ # fails on windows
135
123
  end
136
-
137
- delwin win
138
- delwin frame
139
124
  end
140
125
 
141
- def show_help(win)
142
- help = <<-HELP.chomp
143
- j/k = Move down/up
144
- d/p = Next/previous page
145
-
146
- c = Copy share link
147
- C = Copy embed link
148
- D = Copy download link
149
- t = Copy thumbnail link
150
- HELP
151
- popup_window win, help
152
- ch = wgetch win
153
- ungetch ch unless ch == ??.ord
126
+ def service
127
+ CloudApp::Service.using_token Credentials.token
154
128
  end
155
129
 
156
- require_credentials
157
-
158
- begin
159
- initscr
160
- noecho
161
- curs_set 0
162
-
163
- drops = nil
164
- popup_window nil, 'Loading...' do
165
- drops = account.drops limit: 10
130
+ case ARGV.shift
131
+ when 'bookmark'
132
+ raise ArgumentError, 'URL missing' if ARGV.empty?
133
+ url = ARGV.shift
134
+ unless url =~ URI.regexp
135
+ raise ArgumentError, "#{ url } doesn't look like a valid URL"
166
136
  end
167
137
 
168
- win, wrap = draw_drops_window drops
169
- selected_drop = select_drop win, 0, drops
170
-
171
- while c = wgetch(win)
172
- case c
173
- when ?q.ord
174
- break
175
- when ??.ord
176
- show_help win
177
-
178
- when ?j.ord, KEY_DOWN
179
- selected_drop += 1
180
- when ?k.ord, KEY_UP
181
- selected_drop -= 1
182
-
183
- when ?d.ord
184
- next unless drops.link('next') { nil }
185
- popup_window win, 'Loading...' do
186
- drops = account.drops href: drops.link('next').href
187
- end
188
- wclear wrap
189
- wrefresh wrap
190
- when ?p.ord
191
- next unless drops.link('previous') { nil }
192
- popup_window win, 'Loading...' do
193
- drops = account.drops href: drops.link('previous').href
194
- end
195
- wclear wrap
196
- wrefresh wrap
197
-
198
- when ?c.ord, KEY_RETURN
199
- link = drops[selected_drop].share_url
200
- Clipboard.copy link
201
- popup_window win, 'Copied share link.'
202
- when ?C.ord
203
- link = drops[selected_drop].embed_url
204
- Clipboard.copy link
205
- popup_window win, 'Copied embed link.'
206
- when ?D.ord
207
- link = drops[selected_drop].download_url
208
- Clipboard.copy link
209
- popup_window win, 'Copied download link.'
210
- when ?t.ord
211
- link = drops[selected_drop].thumbnail_url
212
- Clipboard.copy link
213
- popup_window win, 'Copied thumbnail link.'
214
- end
138
+ bookmark = service.bookmark(url).first
139
+ puts bookmark.share_url
215
140
 
216
- delwin win
217
- delwin wrap
218
- win, wrap = draw_drops_window drops
219
- selected_drop = select_drop win, selected_drop, drops
220
- end
141
+ when 'upload'
142
+ raise ArgumentError, 'File missing' if ARGV.empty?
221
143
 
222
- delwin win
223
- delwin wrap
144
+ file = service.upload(ARGF.file).first
145
+ puts file.share_url
224
146
 
225
- rescue => e
226
- endwin
227
- raise
228
- ensure
229
- endwin
147
+ else
148
+ puts <<EOS
149
+ Usage:
150
+ cloudapp bookmark http://getcloudapp.com
151
+ cloudapp upload screenshot.png
152
+ EOS
230
153
  end
data/cloudapp-cli.gemspec CHANGED
@@ -13,8 +13,8 @@ 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-cli'
16
- s.version = '1.0.0.beta.6'
17
- s.date = '2012-08-20'
16
+ s.version = '1.0.0.beta.7'
17
+ s.date = '2012-10-06'
18
18
  s.rubyforge_project = 'cloudapp-cli'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  ## a custom homepage, consider using your GitHub URL or the like.
28
28
  s.authors = ["Larry Marburger"]
29
29
  s.email = 'larry@marburger.cc'
30
- s.homepage = 'https://github.com/cloudapp/cloudapp-cli'
30
+ s.homepage = 'https://github.com/cloudapp/cli'
31
31
 
32
32
  ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
33
  ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
@@ -43,27 +43,18 @@ Gem::Specification.new do |s|
43
43
 
44
44
  ## List your runtime dependencies here. Runtime dependencies are those
45
45
  ## that are needed for an end user to actually USE your code.
46
- s.add_dependency 'cloudapp', '~> 2.0.0.beta.1'
47
- s.add_dependency 'clipboard'
48
- s.add_dependency 'ffi-ncurses'
49
- s.add_dependency 'highline'
50
-
51
- # Needed for Highline echo=false support as per
52
- # https://github.com/JEG2/highline/issues/39
53
- s.add_dependency 'ruby-termios'
46
+ s.add_dependency 'cloudapp', '~> 2.0.0.beta.4'
47
+ s.add_dependency 'netrc', '~> 0.7.7'
54
48
 
55
49
  ## List your development dependencies here. Development dependencies are
56
50
  ## those that are only needed during development
57
51
  s.add_development_dependency 'rake'
58
- s.add_development_dependency 'ronn'
59
- s.add_development_dependency 'rspec'
60
52
 
61
53
  ## Leave this section as-is. It will be automatically generated from the
62
54
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
63
55
  ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
64
56
  # = MANIFEST =
65
57
  s.files = %w[
66
- CHANGELOG.md
67
58
  Gemfile
68
59
  Gemfile.lock
69
60
  MIT-LICENSE
@@ -72,9 +63,6 @@ Gem::Specification.new do |s|
72
63
  bin/cloudapp
73
64
  cloudapp-cli.gemspec
74
65
  lib/cloudapp/cli.rb
75
- lib/cloudapp/cli/config.rb
76
- spec/cloudapp/cli/config_spec.rb
77
- spec/helper.rb
78
66
  ]
79
67
  # = MANIFEST =
80
68
 
data/lib/cloudapp/cli.rb CHANGED
@@ -1,8 +1,5 @@
1
- require 'cloudapp'
2
- require 'cloudapp/cli/config'
3
-
4
1
  module CloudApp
5
2
  module CLI
6
- VERSION = '1.0.0.beta.6'
3
+ VERSION = '1.0.0.beta.7'
7
4
  end
8
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudapp-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.6
4
+ version: 1.0.0.beta.7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cloudapp
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0.beta.1
21
+ version: 2.0.0.beta.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,71 +26,23 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.0.0.beta.1
29
+ version: 2.0.0.beta.4
30
30
  - !ruby/object:Gem::Dependency
31
- name: clipboard
31
+ name: netrc
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: ffi-ncurses
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: highline
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: ruby-termios
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
35
+ - - ~>
84
36
  - !ruby/object:Gem::Version
85
- version: '0'
37
+ version: 0.7.7
86
38
  type: :runtime
87
39
  prerelease: false
88
40
  version_requirements: !ruby/object:Gem::Requirement
89
41
  none: false
90
42
  requirements:
91
- - - ! '>='
43
+ - - ~>
92
44
  - !ruby/object:Gem::Version
93
- version: '0'
45
+ version: 0.7.7
94
46
  - !ruby/object:Gem::Dependency
95
47
  name: rake
96
48
  requirement: !ruby/object:Gem::Requirement
@@ -107,38 +59,6 @@ dependencies:
107
59
  - - ! '>='
108
60
  - !ruby/object:Gem::Version
109
61
  version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: ronn
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
62
  description: Experience all the pleasures of sharing with CloudApp now in your terminal.
143
63
  email: larry@marburger.cc
144
64
  executables:
@@ -148,7 +68,6 @@ extra_rdoc_files:
148
68
  - README.md
149
69
  - MIT-LICENSE
150
70
  files:
151
- - CHANGELOG.md
152
71
  - Gemfile
153
72
  - Gemfile.lock
154
73
  - MIT-LICENSE
@@ -157,10 +76,7 @@ files:
157
76
  - bin/cloudapp
158
77
  - cloudapp-cli.gemspec
159
78
  - lib/cloudapp/cli.rb
160
- - lib/cloudapp/cli/config.rb
161
- - spec/cloudapp/cli/config_spec.rb
162
- - spec/helper.rb
163
- homepage: https://github.com/cloudapp/cloudapp-cli
79
+ homepage: https://github.com/cloudapp/cli
164
80
  licenses: []
165
81
  post_install_message:
166
82
  rdoc_options:
data/CHANGELOG.md DELETED
@@ -1,11 +0,0 @@
1
- # Change Log
2
-
3
- Below is a listing of the high-level changes for each revision of
4
- `cloudapp-cli`.
5
-
6
- ## In Progress
7
-
8
- - Create curses client.
9
- - Extract CLI from [cloudapp][] gem.
10
-
11
- [cloudapp]: https://github.com/cloudapp/cloudapp
@@ -1,41 +0,0 @@
1
- require 'pathname'
2
- require 'singleton'
3
- require 'yaml'
4
-
5
- module CloudApp
6
- module CLI
7
- class Config
8
- def initialize(path = File.expand_path('~/.cloudapprc'))
9
- @path = path
10
- @config = read_config
11
- end
12
-
13
- def token
14
- @config[:token]
15
- end
16
-
17
- def token=(token)
18
- if token
19
- @config[:token] = token
20
- else
21
- @config.delete :token
22
- end
23
-
24
- write_config
25
- end
26
-
27
- private
28
-
29
- def read_config
30
- return {} unless File.exist?(@path)
31
- File.open(@path) {|file| YAML.load(file) }
32
- end
33
-
34
- def write_config
35
- File.open(@path, 'w', 0600) {|file|
36
- YAML.dump @config, file
37
- }
38
- end
39
- end
40
- end
41
- end
@@ -1,62 +0,0 @@
1
- require 'helper'
2
- require 'tempfile'
3
-
4
- require 'cloudapp/cli/config'
5
-
6
- describe CloudApp::CLI::Config do
7
- let(:config) { {} }
8
- let(:content) { YAML.dump(config) }
9
- let(:path) { config_file.path }
10
- let(:config_file) {
11
- Tempfile.new('cloudapprc', '.').tap do |file|
12
- file << content
13
- file.flush
14
- file.close
15
- end
16
- }
17
-
18
- after do config_file.unlink end
19
-
20
- describe '#new' do
21
- subject { CloudApp::CLI::Config.new path }
22
-
23
- describe 'an existing config file' do
24
- let(:config) {{ token: 'token' }}
25
-
26
- it 'reads the content' do
27
- subject.token.should eq(config[:token])
28
- end
29
-
30
- it 'updates a key' do
31
- new_token = 'new token'
32
- subject.token = new_token
33
- expected = YAML.dump token: new_token
34
-
35
- content = File.open(path) {|file| file.read }
36
- content.should eq(expected)
37
- end
38
-
39
- it 'clears a key' do
40
- subject.token = nil
41
- expected = YAML.dump({})
42
-
43
- content = File.open(path) {|file| file.read }
44
- content.should eq(expected)
45
- end
46
- end
47
-
48
- describe 'an empty config file' do
49
- it 'returns nil' do
50
- subject.token.should be_nil
51
- end
52
- end
53
-
54
- describe 'a nonexistent config file' do
55
- let(:path) { 'nonexistent' }
56
-
57
- it 'returns nil' do
58
- subject.token.should be_nil
59
- end
60
- end
61
- end
62
- end
data/spec/helper.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'English'
2
-
3
- root = File.expand_path('../..', __FILE__)
4
- $LOAD_PATH.unshift(File.expand_path('lib', root))