rubiojr-iorb 0.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +3 -0
- data/bin/iorb +1 -1
- data/iorb.gemspec +3 -3
- data/lib/iorb.rb +1 -1
- data/lib/iorb/commands/mail.rb +55 -0
- data/lib/iorb/commands/send_to_drop.rb +53 -0
- data/lib/iorb/commands/update.rb +52 -0
- metadata +5 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -17,5 +17,8 @@ lib/iorb/commands/create.rb
|
|
17
17
|
lib/iorb/commands/destroy.rb
|
18
18
|
lib/iorb/commands/info.rb
|
19
19
|
lib/iorb/commands/list.rb
|
20
|
+
lib/iorb/commands/mail.rb
|
20
21
|
lib/iorb/commands/mydrops.rb
|
22
|
+
lib/iorb/commands/send_to_drop.rb
|
23
|
+
lib/iorb/commands/update.rb
|
21
24
|
scripts/newrelease
|
data/bin/iorb
CHANGED
data/iorb.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{iorb}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.5.1"
|
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
|
7
|
+
s.date = %q{2009-05-04}
|
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", "THANKS.txt"]
|
13
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "THANKS.txt", "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"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "THANKS.txt", "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/mail.rb", "lib/iorb/commands/mydrops.rb", "lib/iorb/commands/send_to_drop.rb", "lib/iorb/commands/update.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"]
|
data/lib/iorb.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
def mail_asset(drop_name, asset_name, emails, message = nil)
|
2
|
+
details = IORB::DropManager.find(drop_name)
|
3
|
+
regex = false
|
4
|
+
if asset_name =~ /^\/.*\/$/
|
5
|
+
regex = true
|
6
|
+
asset_name = Regexp.new(asset_name[1..-2])
|
7
|
+
end
|
8
|
+
begin
|
9
|
+
if details.nil?
|
10
|
+
drop = Drop.find(drop_name)
|
11
|
+
else
|
12
|
+
drop = Drop.find(drop_name, details.admin_token)
|
13
|
+
end
|
14
|
+
to_mail = []
|
15
|
+
drop.assets.each do |a|
|
16
|
+
if regex
|
17
|
+
(to_mail << a) if a.name =~ asset_name
|
18
|
+
else
|
19
|
+
(to_mail << a) if a.name == asset_name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
to_mail.each do |a|
|
23
|
+
print "Emailing #{a.name}... "
|
24
|
+
a.send_to_emails(emails, message)
|
25
|
+
puts "done"
|
26
|
+
end
|
27
|
+
puts "\nNo matching asset found in drop #{drop_name}\n\n" if to_mail.empty?
|
28
|
+
rescue Dropio::MissingResourceError
|
29
|
+
$stderr.puts "Drop/Asset does not exist"
|
30
|
+
rescue Dropio::AuthorizationError
|
31
|
+
$stderr.puts "Authorization error. This drop is private or the admin token is invalid."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
command :mail do |c|
|
36
|
+
c.description = 'Email an asset'
|
37
|
+
c.option '--addresses ADDRESSES', 'Destination email addresses (separated by comma)'
|
38
|
+
c.option '--message MESSAGE', 'Optional message'
|
39
|
+
c.when_called do |args, options|
|
40
|
+
if options.addresses.nil?
|
41
|
+
$stderr.puts 'No email specified. --addresses is required'
|
42
|
+
abort
|
43
|
+
end
|
44
|
+
param = args.first
|
45
|
+
drop_name = nil
|
46
|
+
asset = nil
|
47
|
+
if param =~ /^\w+:.*/
|
48
|
+
drop_name, asset = param.split(':')
|
49
|
+
emails = options.addresses.split(',')
|
50
|
+
mail_asset(drop_name, asset, emails, options.message)
|
51
|
+
else
|
52
|
+
$stderr.puts 'Invalid drop/asset.'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
def send_to_drop(drop_name, asset_name, target_drop)
|
2
|
+
details = IORB::DropManager.find(drop_name)
|
3
|
+
regex = false
|
4
|
+
if asset_name =~ /^\/.*\/$/
|
5
|
+
regex = true
|
6
|
+
asset_name = Regexp.new(asset_name[1..-2])
|
7
|
+
end
|
8
|
+
begin
|
9
|
+
if details.nil?
|
10
|
+
drop = Drop.find(drop_name)
|
11
|
+
else
|
12
|
+
drop = Drop.find(drop_name, details.admin_token)
|
13
|
+
end
|
14
|
+
to_copy = []
|
15
|
+
drop.assets.each do |a|
|
16
|
+
if regex
|
17
|
+
(to_copy << a) if a.name =~ asset_name
|
18
|
+
else
|
19
|
+
(to_copy << a) if a.name == asset_name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
to_copy.each do |a|
|
23
|
+
print "Copying #{a.name}... "
|
24
|
+
a.send_to_drop(target_drop)
|
25
|
+
puts "done"
|
26
|
+
end
|
27
|
+
puts "\nNo matching asset found in drop #{drop_name}\n\n" if to_copy.empty?
|
28
|
+
rescue Dropio::MissingResourceError
|
29
|
+
$stderr.puts "Drop/Asset does not exist"
|
30
|
+
rescue Dropio::AuthorizationError
|
31
|
+
$stderr.puts "Authorization error. This drop is private or the admin token is invalid."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
command :send_to_drop do |c|
|
36
|
+
c.description = 'Sends an asset to another drop'
|
37
|
+
c.option '--target-drop NAME', 'Target drop name (must accept files from guests)'
|
38
|
+
c.when_called do |args, options|
|
39
|
+
param = args.first
|
40
|
+
drop_name = nil
|
41
|
+
asset = nil
|
42
|
+
if options.target_drop.nil?
|
43
|
+
$stderr.puts '--target-drop not specified'
|
44
|
+
break
|
45
|
+
end
|
46
|
+
if param =~ /^\w+:.*/
|
47
|
+
drop_name, asset = param.split(':')
|
48
|
+
send_to_drop(drop_name, asset, options.target_drop)
|
49
|
+
else
|
50
|
+
$stderr.puts 'Invalid drop/asset.'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
command :update do |c|
|
2
|
+
c.description = 'Update drop attributes'
|
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 '--guests-can-comment YES/NO', String, 'Guest can add comments (defaut: yes)'
|
6
|
+
c.option '--guests-can-add YES/NO', String, 'Guest can add to this drop (defaut: yes)'
|
7
|
+
c.option '--guests-can-delete YES/NO', String, 'Guest can delete assets in this drop (defaut: yes)'
|
8
|
+
c.option '--admin-password PASSWORD', String, 'Admin password to manage this drop (defaut: none)'
|
9
|
+
c.option '--password PASSWORD', String, 'Password to access this drop (defaut: none)'
|
10
|
+
c.option '--premium-code CODE', String, 'Premium code to apply to the drop (defaut: none)'
|
11
|
+
c.when_called do |args, drop_options|
|
12
|
+
drop_name = args.first
|
13
|
+
begin
|
14
|
+
details = IORB::DropManager.find(drop_name)
|
15
|
+
drop = Drop.find(drop_name, details.admin_token )
|
16
|
+
if drop_options.expiration_length
|
17
|
+
drop.expiration_length = drop_options.expiration_length
|
18
|
+
end
|
19
|
+
if drop_options.guests_can_delete
|
20
|
+
drop.guests_can_delete = (drop_options.guests_can_delete =~ /^yes|y$/ ? true : false)
|
21
|
+
end
|
22
|
+
if drop_options.guests_can_comment
|
23
|
+
drop.guests_can_comment = (drop_options.guests_can_comment =~ /^yes|y$/ ? true : false)
|
24
|
+
end
|
25
|
+
if drop_options.guests_can_add
|
26
|
+
drop.guests_can_add = (drop_options.guests_can_add =~ /^yes|y$/ ? true : false)
|
27
|
+
end
|
28
|
+
if drop_options.admin
|
29
|
+
drop.admin_password = drop_options.admin_password
|
30
|
+
end
|
31
|
+
if drop_options.password
|
32
|
+
if drop_options.password.chomp.strip.eql?('no')
|
33
|
+
drop.password = nil
|
34
|
+
else
|
35
|
+
drop.password = drop_options.password
|
36
|
+
end
|
37
|
+
end
|
38
|
+
if drop_options.premium
|
39
|
+
drop.premium_code = drop_options.premium_code
|
40
|
+
end
|
41
|
+
drop.save
|
42
|
+
details = IORB::DropDetails.build_from(drop)
|
43
|
+
details.print
|
44
|
+
details.save if drop_options.save
|
45
|
+
rescue Dropio::MissingResourceError
|
46
|
+
$stderr.puts "Drop/Asset does not exist"
|
47
|
+
rescue Dropio::AuthorizationError => e
|
48
|
+
$stderr.puts e.message
|
49
|
+
$stderr.puts 'Error updating drop.'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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:
|
4
|
+
version: 0.5.1
|
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
|
12
|
+
date: 2009-05-04 00:00:00 -07:00
|
13
13
|
default_executable: iorb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,10 @@ files:
|
|
73
73
|
- lib/iorb/commands/destroy.rb
|
74
74
|
- lib/iorb/commands/info.rb
|
75
75
|
- lib/iorb/commands/list.rb
|
76
|
+
- lib/iorb/commands/mail.rb
|
76
77
|
- lib/iorb/commands/mydrops.rb
|
78
|
+
- lib/iorb/commands/send_to_drop.rb
|
79
|
+
- lib/iorb/commands/update.rb
|
77
80
|
- scripts/newrelease
|
78
81
|
has_rdoc: true
|
79
82
|
homepage: http://github.com/rubiojr/iorb
|