rubiojr-iorb 0.3.3 → 0.3.96

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.
@@ -9,3 +9,9 @@
9
9
  * list drop assets
10
10
  * add files to drops
11
11
 
12
+ === 0.4 / 2009-04-22
13
+
14
+ * cli improvements
15
+ * listing assets from drops now support filtering (regexp)
16
+ * destroy assets matching a given filter
17
+ * implemented info command
@@ -2,10 +2,20 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ THANKS.txt
5
6
  bin/iorb
7
+ dropio-ruby-api-examples/add_files.rb
6
8
  dropio-ruby-api-examples/basic_client.rb
9
+ dropio-ruby-api-examples/destroy_drop.rb
7
10
  dropio-ruby-api-examples/find_drop.rb
8
11
  dropio-ruby-api-examples/find_my_drop.rb
12
+ dropio-ruby-api-examples/list_files.rb
9
13
  iorb.gemspec
10
14
  lib/iorb.rb
15
+ lib/iorb/commands/add.rb
16
+ lib/iorb/commands/create.rb
17
+ lib/iorb/commands/destroy.rb
18
+ lib/iorb/commands/info.rb
19
+ lib/iorb/commands/list.rb
20
+ lib/iorb/commands/mydrops.rb
11
21
  scripts/newrelease
data/README.txt CHANGED
@@ -14,22 +14,48 @@ You will need a drop.io API key. Get it at http://api.drop.io
14
14
 
15
15
  == SYNOPSIS:
16
16
 
17
- iorb --create [drop_name]
18
- iorb --drop-name <drop_name> --add-files file1 file2 ...
19
- iorb --list <drop_name>
20
- iorb --destroy <drop_name>
21
- ...
22
- iorb -h
17
+ === Creating drops
18
+ iorb create [drop_name]
19
+
20
+ === Adding assets to a drop
21
+ * Add files to an existing drop
22
+ iorb add --drop-name <drop_name> file1 file2 ...
23
+
24
+ * create a random drop and add files to it
25
+ iorb add file1 file2 ...
26
+
27
+ === Listing assets
28
+ * list all assets from a drop
29
+ iorb list <drop_name>
30
+ * list assets matching regex
31
+ iorb list <drop_name> --filter '-(mov|mp3)'
32
+ * list assets matching type
33
+ iorb list <drop_name> --filter type:audio
34
+
35
+ === Destroying drops/assets
36
+ * destroy a drop
37
+ iorb destroy <drop_name>
38
+ * destroy all assets matching pattern from drop 'test_drop'
39
+ iorb destroy test_drop:/-(mp3|avi)/
40
+ * destroy all assets from test_drop
41
+ iorb destroy test_drop:/.*/
23
42
 
24
43
  == REQUIREMENTS:
25
44
 
26
45
  * dropio ruby library from Jake Good:
27
46
  http://github.com/whoisjake/dropio_api_ruby/tree/master
47
+ * highline from James Edward Gray II:
48
+ http://rubyforge.org/projects/highline
49
+ * commander from TJ Holowaych:
50
+ http://github.com/visionmedia/commander
28
51
 
29
52
  == INSTALL:
30
53
 
31
54
  1. gem source -a http://gems.github.com
32
- 2. gem install rubiojr-iorb
55
+ 2. gem source -a http://iorb.netcorex.org (stable release)
56
+ OR
57
+ gem source -a http://dev.netcorex.org (unstable release)
58
+ 3. gem install iorb
33
59
 
34
60
  == LICENSE:
35
61
 
data/Rakefile CHANGED
@@ -12,7 +12,11 @@ Hoe.new('iorb', IORB::VERSION) do |p|
12
12
  p.url = "http://github.com/rubiojr/iorb"
13
13
  p.remote_rdoc_dir = '' # Release to root
14
14
  p.extra_deps << [ "dropio",">= 0.9" ]
15
- p.extra_deps << [ "highline",">= 1.0" ]
16
- p.extra_deps << [ "choice",">= 0.1" ]
15
+ p.extra_deps << [ "visionmedia-commander",">= 3.2" ]
17
16
  p.developer('Sergio Rubio', 'sergio@rubio.name')
18
17
  end
18
+
19
+ task :publish_dev_gem do
20
+ `scp pkg/*.gem dev.netcorex.org:/srv/www/dev.netcorex.org/gems/`
21
+ `ssh dev.netcorex.org /opt/ruby/bin/gem generate_index -d /srv/www/dev.netcorex.org/`
22
+ end
data/bin/iorb CHANGED
@@ -1,219 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
- # API Docs http://groups.google.com/group/dropio-api/web/full-api-documentation
3
- require 'rubygems'
4
- require 'dropio'
5
- require 'choice'
6
2
  begin
7
3
  require "#{File.join(File.dirname(__FILE__), '../lib/iorb.rb')}"
8
4
  rescue LoadError
9
5
  require 'iorb'
10
6
  end
11
- include Dropio
12
7
 
8
+ include Dropio
13
9
  IORB::Config.check
14
-
15
- Choice.options do
16
- header ''
17
- header 'Available options:'
18
-
19
- option :version do
20
- long '--version'
21
- short '-v'
22
- desc 'Show iorb version'
23
- action do
24
- puts "iorb version #{IORB::VERSION}"
25
- exit
26
- end
27
- end
28
- option :no_save do
29
- long '--no-save'
30
- end
31
-
32
- option :find_drop do
33
- short '-f'
34
- long '--find=NAME'
35
- desc 'Find a drop matching NAME'
36
- end
37
-
38
- option :list do
39
- short '-l'
40
- long '--list=NAME'
41
- desc 'List assets in drop NAME'
42
- end
43
-
44
- option :create do
45
- short '-c'
46
- long '--create=[NAME]'
47
- desc 'Create a drop'
48
- end
49
-
50
- option :expiration_length do
51
- short '-e'
52
- long '--expiration-length LENGTH'
53
- desc 'Drop expiration length. (1 week by default)'
54
- default '1_WEEK_FROM_NOW'
55
- end
56
-
57
- option :mydrops do
58
- long '--mydrops'
59
- desc 'Print the drops I have created'
60
- end
61
-
62
- option :save_details do
63
- long '--save-details'
64
- short '-s'
65
- desc 'Save drop details (Needed to admin the drop later)'
66
- end
67
-
68
- option :destroy do
69
- long '--destroy NAME'
70
- short '-d'
71
- desc 'Destroy a drop (needs to be defined in the config file)'
72
- end
73
-
74
- option :drop_name do
75
- long '--drop-name NAME'
76
- desc 'Drop name'
77
- end
78
-
79
- option :add_files do
80
- long '--add-files *FILES'
81
- desc 'Add files to a drop (if --drop-name not specified, it will create a new drop)'
82
- end
83
-
84
- end
85
-
86
10
  if IORB::Config.api_key.nil?
87
11
  $stderr.puts "Invalid API key in #{API_KEY_FILE}"
88
12
  exit
89
13
  end
90
-
91
14
  Dropio.api_key = IORB::Config.api_key
92
15
 
93
- if Choice.choices.create
94
- name = Choice.choices.create
95
- options = {
96
- :expiration_length => Choice.choices.expiration_length,
97
- :guests_can_add => false,
98
- :guests_can_comment => false
99
- }
100
- if name.is_a? String
101
- options.merge!({ :name => name.strip.chomp })
102
- end
103
- drop = Drop.create(options)
104
-
105
- puts "\nDrop created.\n\n"
16
+ require 'commander'
17
+ Dir["#{File.dirname(__FILE__)}" + '/../lib/iorb/commands/*.rb'].each do |f|
18
+ require f
19
+ end
20
+
21
+ program :name, 'iorb'
22
+ program :version, IORB::VERSION
23
+ program :description, 'drop.io command line interface'
24
+ default_command :help
25
+
26
+ # API Docs http://groups.google.com/group/dropio-api/web/full-api-documentation
106
27
 
107
- details = IORB::DropDetails.build_from(drop)
108
- details.print
109
- details.save if not Choice.choices.no_save
110
28
 
111
- if PLATFORM =~ /.*darwin*/
112
- IORB::Util::MacClipboard.write "http://drop.io/#{drop.name}"
113
- puts "\nPublic URL copied to the clipboard."
114
- end
115
- elsif Choice.choices.destroy
116
- begin
117
- drop_name = Choice.choices.destroy
118
- drop_details = IORB::DropManager.find(drop_name)
119
- if drop_details.nil? or drop_details['admin-token'].nil?
120
- $stderr.puts "Drop details or admin-token not found in #{IORB::Config.file}"
121
- exit 1
122
- end
123
- token = nil
124
- token = drop_details['admin-token']
125
- drop = Drop.find(drop_name, token)
126
- drop.destroy
127
- drop_details['destroyed'] = true
128
- drop_details.save
129
- rescue Dropio::MissingResourceError
130
- $stderr.puts "Drop '#{Choice.choices.destroy}' does not exist"
131
- rescue Dropio::AuthorizationError
132
- $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
133
- end
134
29
 
135
- elsif Choice.choices.find_drop
136
- begin
137
- drop_name = Choice.choices.find_drop
138
- drop_details = IORB::DropManager.find(drop_name)
139
- token = nil
140
- token = drop_details['admin-token'] if drop_details
141
- drop = Drop.find(drop_name, token)
142
- new_details = IORB::DropDetails.build_from(drop)
143
- new_details.print
144
- if Choice.choices.save_details
145
- puts "\nSaving drop details."
146
- new_details.save
147
- end
148
- rescue Dropio::MissingResourceError
149
- $stderr.puts "Drop '#{Choice.choices.find_drop}' does not exist"
150
- rescue Dropio::AuthorizationError
151
- $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
152
- end
153
- elsif Choice.choices.add_files
154
- drop_name = Choice.choices.drop_name
155
- if drop_name
156
- drop_details = IORB::DropManager.find(drop_name)
157
- drop = nil
158
- # Add files as a guest
159
- if drop_details.nil? or drop_details['admin-token'].nil?
160
- drop = Drop.find(drop_name)
161
- else
162
- drop = Drop.find(drop_name, drop_details['admin-token'])
163
- end
164
- Choice.choices.add_files.each do |f|
165
- if File.exist?(f)
166
- drop.add_file(f)
167
- puts "File #{f} added."
168
- else
169
- $stderr.puts "File #{f} not found, skipping."
170
- end
171
- end
172
- else
173
- options = {
174
- :expiration_length => Choice.choices.expiration_length,
175
- :guests_can_add => false,
176
- :guests_can_comment => false
177
- }
178
- drop = Drop.create(options)
179
- IORB::DropDetails.build_from(drop).save if not Choice.choices.no_save
180
- puts "\nDrop #{drop.name} created.\n\n"
181
30
 
182
- Choice.choices.add_files.each do |f|
183
- if File.exist?(f)
184
- drop.add_file(f)
185
- puts "File #{f} added."
186
- else
187
- $stderr.puts "File #{f} not found, skipping."
188
- end
189
- end
190
- end
191
- elsif Choice.choices.mydrops
192
- IORB::DropManager.each do |d|
193
- puts d['name']
194
- end
195
- elsif Choice.choices.list
196
- drop_name = Choice.choices.list
197
- drop_details = IORB::DropManager.find(drop_name)
198
- token = nil
199
- token = drop_details['admin-token'] if drop_details
200
- begin
201
- drop = Drop.find(drop_name, token)
202
- drop.assets.each do |a|
203
- puts "Asset name: #{a.name}"
204
- puts "Title: #{a.title}"
205
- puts "Created at: #{a.created_at}"
206
- puts "Type: #{a.type}"
207
- puts "File Size: #{a.filesize}"
208
- puts "URL: http://drop.io/#{drop_name}/asset/#{a.name}"
209
- puts "\n"
210
- end
211
- rescue Dropio::MissingResourceError
212
- $stderr.puts "Drop '#{drop_name}' does not exist"
213
- rescue Dropio::AuthorizationError
214
- $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
215
- end
216
- else
217
- $stderr.puts "\nInvalid command. Either --add, --find or --list are mandatory.\n\n"
218
- puts Choice.help
219
- end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'dropio'
4
+ include Dropio
5
+
6
+ #
7
+ # Create a new drop and add files to it
8
+ #
9
+
10
+ #
11
+ # get your API key @ http://api.drop.io
12
+ #
13
+ Dropio.api_key = 'your_api_key_here'
14
+ admin_token = '0000000000'
15
+ drop_name = 'mydropname'
16
+
17
+ begin
18
+
19
+ #
20
+ # Drop can be named, or unnamed. The drop name
21
+ # will be randomly generated by drop.io if :name option
22
+ # is not specified
23
+ #
24
+ drop = Drop.create(
25
+ { :expiration_length => '1_DAY_FROM_NOW',
26
+ :guests_can_add => false,
27
+ :guests_can_comment => false,
28
+ }
29
+ )
30
+ drop.add_file('file_somewhere')
31
+
32
+ rescue Dropio::MissingResourceError
33
+ puts 'Drop does not exist.'
34
+ rescue Dropio::AuthorizationError # no permissions to read the drop
35
+ puts 'Not authorized.'
36
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'dropio'
4
+ include Dropio
5
+
6
+ #
7
+ # Find a drop you have created (got admin token)
8
+ # and destroy it
9
+ #
10
+
11
+ #
12
+ # get your API key @ http://api.drop.io
13
+ #
14
+ Dropio.api_key = 'your_api_key_here'
15
+ admin_token = '0000000000'
16
+ drop_name = 'mydropname'
17
+
18
+ begin
19
+
20
+ drop = Drop.find(drop_name, admin_token)
21
+ drop.destroy # that's all!
22
+
23
+ rescue Dropio::MissingResourceError
24
+ puts 'Drop does not exist.'
25
+ rescue Dropio::AuthorizationError # no permissions to read the drop
26
+ puts 'Not authorized.'
27
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'dropio'
4
+ include Dropio
5
+
6
+ #
7
+ # List assets from a drop
8
+ #
9
+
10
+ #
11
+ # get your API key @ http://api.drop.io
12
+ #
13
+ Dropio.api_key = 'your_api_key_here'
14
+ admin_token = '0000000000'
15
+ drop_name = 'a_drop_name'
16
+
17
+ begin
18
+
19
+ #
20
+ # admin_token is optional.
21
+ # if the drop is public you don't need it
22
+ #
23
+ # drop = Drop.find(drop_name)
24
+ drop = Drop.find(drop_name, admin_token)
25
+ drop.assets.each do |a|
26
+ puts "Asset found: #{a.name}"
27
+ end
28
+
29
+ rescue Dropio::MissingResourceError
30
+ puts 'Drop does not exist.'
31
+ rescue Dropio::AuthorizationError # no permissions to read the drop
32
+ puts 'Not authorized.'
33
+ end
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{iorb}
3
- s.version = "0.3.3"
3
+ s.version = "0.3.96"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Sergio RubioSergio Rubio"]
7
- s.date = %q{2009-04-22}
7
+ s.date = %q{2009-04-23}
8
8
  s.default_executable = %q{iorb}
9
9
  s.description = %q{drop.io CLI interface}
10
10
  s.email = %q{sergio@rubio.namesergio@rubio.name}
11
11
  s.executables = ["iorb"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
- s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/iorb", "dropio-ruby-api-examples/basic_client.rb", "dropio-ruby-api-examples/find_drop.rb", "dropio-ruby-api-examples/find_my_drop.rb", "iorb.gemspec", "lib/iorb.rb", "scripts/newrelease"]
13
+ s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/iorb", "dropio-ruby-api-examples/add_files.rb", "dropio-ruby-api-examples/basic_client.rb", "dropio-ruby-api-examples/destroy_drop.rb", "dropio-ruby-api-examples/find_drop.rb", "dropio-ruby-api-examples/find_my_drop.rb", "dropio-ruby-api-examples/list_files.rb", "iorb.gemspec", "lib/iorb.rb", "lib/iorb/commands/add.rb", "lib/iorb/commands/create.rb", "lib/iorb/commands/destroy.rb", "lib/iorb/commands/info.rb", "lib/iorb/commands/list.rb", "lib/iorb/commands/mydrops.rb", "scripts/newrelease"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/rubiojr/iorb}
16
16
  s.rdoc_options = ["--main", "README.txt"]
@@ -25,19 +25,16 @@ Gem::Specification.new do |s|
25
25
 
26
26
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
27
  s.add_runtime_dependency(%q<dropio>, [">= 0.9"])
28
- s.add_runtime_dependency(%q<highline>, [">= 1.0"])
29
- s.add_runtime_dependency(%q<choice>, [">= 0.1"])
28
+ s.add_runtime_dependency(%q<visionmedia-commander>, [">= 3.2"])
30
29
  s.add_development_dependency(%q<hoe>, [">= 1.12.1"])
31
30
  else
32
31
  s.add_dependency(%q<dropio>, [">= 0.9"])
33
- s.add_dependency(%q<highline>, [">= 1.0"])
34
- s.add_dependency(%q<choice>, [">= 0.1"])
32
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.2"])
35
33
  s.add_dependency(%q<hoe>, [">= 1.12.1"])
36
34
  end
37
35
  else
38
36
  s.add_dependency(%q<dropio>, [">= 0.9"])
39
- s.add_dependency(%q<highline>, [">= 1.0"])
40
- s.add_dependency(%q<choice>, [">= 0.1"])
37
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.2"])
41
38
  s.add_dependency(%q<hoe>, [">= 1.12.1"])
42
39
  end
43
40
  end
@@ -1,7 +1,21 @@
1
+ require 'rubygems'
1
2
  require 'highline/import'
3
+ require 'dropio'
4
+ require 'json'
5
+ require 'yaml'
2
6
 
7
+ class Dropio::Asset
8
+ def print_details
9
+ puts "Asset name: #{self.name}"
10
+ puts "Title: #{self.title}"
11
+ puts "Created at: #{self.created_at}"
12
+ puts "Type: #{self.type}"
13
+ puts "File Size: #{self.filesize}"
14
+ puts "URL: http://drop.io/#{self.drop.name}/asset/#{self.name}"
15
+ end
16
+ end
3
17
  module IORB
4
- VERSION = "0.3.3"
18
+ VERSION = "0.3.96"
5
19
  module Util
6
20
  # Code stolen from:
7
21
  # http://evan.tiggerpalace.com/2008/04/26/pastie-from-the-mac-clipboard/
@@ -64,6 +78,10 @@ module IORB
64
78
 
65
79
  class DropDetails < Hash
66
80
 
81
+ def method_missing(id, *args)
82
+ self[id.to_s.gsub('_', '-')] || super
83
+ end
84
+
67
85
  def self.build_from(drop)
68
86
  details = DropDetails.new
69
87
  if drop.is_a? Dropio::Drop
@@ -0,0 +1,45 @@
1
+ command :add do |c|
2
+ c.description = 'Add files to a drop'
3
+ c.option '--drop-name NAME', String, 'The target drop name'
4
+ c.when_called do |args, options|
5
+ if options.drop_name.nil?
6
+ # add files to a new, unnamed drop
7
+ drop_options = {
8
+ :expiration_length => '1_WEEK_FROM_NOW'
9
+ }
10
+ print "Creating a new drop... "
11
+ drop = Drop.create(drop_options)
12
+ puts 'done'
13
+ details = IORB::DropDetails.build_from(drop)
14
+ drop_name = drop.name
15
+ details.print
16
+ details.save
17
+ puts
18
+ else
19
+ # let's see if the manager knows the drop
20
+ drop_name = options.drop_name
21
+ details = IORB::DropManager.find(drop_name)
22
+ end
23
+ begin
24
+ if details.nil?
25
+ drop = Drop.find(drop_name)
26
+ else
27
+ drop = Drop.find(drop_name, details.admin_token)
28
+ end
29
+ args.each do |f|
30
+ if File.exist?(f)
31
+ drop.add_file(f)
32
+ puts "File #{f} added."
33
+ else
34
+ $stderr.puts "File #{f} not found, skipping."
35
+ end
36
+ end
37
+ rescue Dropio::MissingResourceError
38
+ $stderr.puts "Drop/Asset does not exist"
39
+ rescue Dropio::AuthorizationError
40
+ $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
41
+ rescue JSON::ParserError
42
+ $stderr.puts "Cannot add asset to the specified drop. Guest uploads not allowed."
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ command :create do |c|
2
+ c.description = 'Create a new drop'
3
+ c.option '--expiration-length LENGTH', String, 'Drop expiration length'
4
+ c.option '--save YES/NO', TrueClass, 'Save the drop info to the config file (defaut: yes)'
5
+ c.option '--guest-can-comment YES/NO', TrueClass, 'Guest can add comments (defaut: yes)'
6
+ c.option '--guest-can-add YES/NO', TrueClass, 'Guest can add to this drop (defaut: yes)'
7
+ c.when_called do |args, options|
8
+ drop_name = args.first
9
+ options.default(
10
+ :expiration_length => '1_WEEK_FROM_LAST_VIEW',
11
+ :save => true,
12
+ :guest_can_comment => true,
13
+ :guest_can_add => false,
14
+ :guest_can_delete => false
15
+ )
16
+ drop_options = {
17
+ :name => drop_name,
18
+ :expiration_length => options.expiration_length,
19
+ :guests_can_add => options.guest_can_add,
20
+ :guests_can_comment => options.guest_can_comment
21
+ }
22
+ begin
23
+ drop = Drop.create(drop_options)
24
+ details = IORB::DropDetails.build_from(drop)
25
+ puts details.class
26
+ details.print
27
+ details.save if options.save
28
+ rescue Dropio::AuthorizationError
29
+ $stderr.puts 'Error creating drop.'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,83 @@
1
+ def delete_asset(drop_name, asset_name, force = false)
2
+ HighLine.track_eof = false
3
+ $stdout.sync = true
4
+ details = IORB::DropManager.find(drop_name)
5
+ regex = false
6
+ if asset_name =~ /^\/.*\/$/
7
+ regex = true
8
+ asset_name = Regexp.new(asset_name[1..-2])
9
+ end
10
+ begin
11
+ if details.nil?
12
+ drop = Drop.find(drop_name)
13
+ else
14
+ drop = Drop.find(drop_name, details.admin_token)
15
+ end
16
+ to_delete = []
17
+ drop.assets.each do |a|
18
+ if regex
19
+ (to_delete << a) if a.name =~ asset_name
20
+ else
21
+ (to_delete << a) if a.name == asset_name
22
+ end
23
+ end
24
+ to_delete.each do |a|
25
+ if force
26
+ print "Deleting #{a.name}... "
27
+ a.destroy!
28
+ puts "done"
29
+ else
30
+ if agree("#{drop_name}:#{a.name} will be deleted, sure? (y/n) ")
31
+ print "Deleting #{a.name}... "
32
+ a.destroy!
33
+ puts "done"
34
+ end
35
+ end
36
+ end
37
+ puts "\nNo matching asset found in drop #{drop_name}\n\n" if to_delete.empty?
38
+ rescue Dropio::MissingResourceError
39
+ $stderr.puts "Drop/Asset does not exist"
40
+ rescue Dropio::AuthorizationError
41
+ $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
42
+ end
43
+ end
44
+
45
+ def delete_drop(drop_name)
46
+ HighLine.track_eof = false
47
+ begin
48
+ details = IORB::DropManager.find(drop_name)
49
+ if details
50
+ drop = Drop.find(drop_name, details.admin_token)
51
+ if ask("Deleting #{drop_name}, sure? (y/n) ")
52
+ drop.destroy
53
+ details['destroyed'] = true
54
+ details.save
55
+ puts 'Destroyed.'
56
+ end
57
+ else
58
+ $stderr.puts "No admin-token for #{drop_name}. I can't destroy it"
59
+ end
60
+ rescue Dropio::MissingResourceError
61
+ $stderr.puts "Drop/Asset does not exist"
62
+ rescue Dropio::AuthorizationError
63
+ $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
64
+ end
65
+ end
66
+
67
+ command :destroy do |c|
68
+ c.description = 'Destroy an existing drop/asset'
69
+ c.option '--force', 'Do not ask for confirmation before destroying'
70
+ c.when_called do |args, options|
71
+ options.default :force => false
72
+ param = args.first
73
+ drop_name = nil
74
+ asset = nil
75
+ if param =~ /^\w+:.*/
76
+ drop_name, asset = param.split(':')
77
+ delete_asset(drop_name, asset, options.force)
78
+ else
79
+ drop_name = param
80
+ delete_drop(drop_name)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,23 @@
1
+ command :info do |c|
2
+ c.description = 'display drop/asset info'
3
+ c.when_called do |args, options|
4
+ if args.empty?
5
+ $stderr.puts 'Needs drop name as an argument.'
6
+ else
7
+ begin
8
+ drop_name = args.first
9
+ details = IORB::DropManager.find(drop_name)
10
+ if details
11
+ details.print
12
+ else
13
+ drop = Drop.find(args.first)
14
+ IORB::DropDetails.build_from(drop).print
15
+ end
16
+ rescue Dropio::MissingResourceError
17
+ $stderr.puts "Drop/Asset does not exist"
18
+ rescue Dropio::AuthorizationError
19
+ $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ command :list do |c|
2
+ c.description = 'list drop assets'
3
+ c.option '--filter REGEX', String, 'Display only matched assets'
4
+ c.option '--detailed', 'Display extra info'
5
+ c.when_called do |args, options|
6
+ filter = options.filter || '.*'
7
+ drop_name = args[0]
8
+ details = IORB::DropManager.find(drop_name)
9
+ begin
10
+ if details
11
+ drop = Drop.find(drop_name, details.admin_token)
12
+ else
13
+ drop = Drop.find(drop_name)
14
+ end
15
+ assets = drop.assets
16
+ if assets.empty?
17
+ puts "No assets in #{drop_name}"
18
+ else
19
+ found = []
20
+ drop.assets.each do |a|
21
+ if filter =~ /^type:.*$/
22
+ (found << a) if a.type == (filter.split(':').last || '')
23
+ else
24
+ (found << a) if a.name =~ Regexp.new(filter)
25
+ end
26
+ end
27
+ found.each do |a|
28
+ if options.detailed
29
+ a.print_details
30
+ puts
31
+ else
32
+ puts a.name
33
+ end
34
+ end
35
+ end
36
+ rescue Dropio::MissingResourceError
37
+ $stderr.puts "Drop/Asset does not exist"
38
+ rescue Dropio::AuthorizationError
39
+ $stderr.puts "Authorization error. This drop is private or the admin token is invalid."
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ command :mydrops do |c|
2
+ c.description = 'List managed drops'
3
+ c.when_called do
4
+ IORB::DropManager.each do |d|
5
+ puts d['name']
6
+ end
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubiojr-iorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio RubioSergio Rubio
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-22 00:00:00 -07:00
12
+ date: 2009-04-23 00:00:00 -07:00
13
13
  default_executable: iorb
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -23,24 +23,14 @@ dependencies:
23
23
  version: "0.9"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: highline
26
+ name: visionmedia-commander
27
27
  type: :runtime
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: "1.0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: choice
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0.1"
33
+ version: "3.2"
44
34
  version:
45
35
  - !ruby/object:Gem::Dependency
46
36
  name: hoe
@@ -68,11 +58,20 @@ files:
68
58
  - README.txt
69
59
  - Rakefile
70
60
  - bin/iorb
61
+ - dropio-ruby-api-examples/add_files.rb
71
62
  - dropio-ruby-api-examples/basic_client.rb
63
+ - dropio-ruby-api-examples/destroy_drop.rb
72
64
  - dropio-ruby-api-examples/find_drop.rb
73
65
  - dropio-ruby-api-examples/find_my_drop.rb
66
+ - dropio-ruby-api-examples/list_files.rb
74
67
  - iorb.gemspec
75
68
  - lib/iorb.rb
69
+ - lib/iorb/commands/add.rb
70
+ - lib/iorb/commands/create.rb
71
+ - lib/iorb/commands/destroy.rb
72
+ - lib/iorb/commands/info.rb
73
+ - lib/iorb/commands/list.rb
74
+ - lib/iorb/commands/mydrops.rb
76
75
  - scripts/newrelease
77
76
  has_rdoc: true
78
77
  homepage: http://github.com/rubiojr/iorb