bee 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/bee_console.rb +11 -2
- data/lib/bee_task_default.rb +214 -14
- metadata +12 -2
data/README
CHANGED
data/lib/bee_console.rb
CHANGED
@@ -52,6 +52,8 @@ targets Targets to run (default target if omitted).'
|
|
52
52
|
EXIT_BUILD_ERROR = 2
|
53
53
|
# Exit value on unknown error
|
54
54
|
EXIT_UNKNOWN_ERROR = 3
|
55
|
+
# Exit value on user interruption
|
56
|
+
EXIT_INTERRUPT_ERROR = 4
|
55
57
|
# Bee options environment variable.
|
56
58
|
BEE_OPT_ENV = 'BEEOPT'
|
57
59
|
# Bee text logo (generated with http://www.network-science.de/ascii/)
|
@@ -60,7 +62,7 @@ targets Targets to run (default target if omitted).'
|
|
60
62
|
| |__ ___ ___
|
61
63
|
____ | '_ \ / _ \/ _ \ _____ _____ _____ _____ _____ _____ _____ _____ _____
|
62
64
|
|____| | |_) | __/ __/ |_____|_____|_____|_____|_____|_____|_____|_____|_____|
|
63
|
-
|_.__/ \___|\___| 0.8.
|
65
|
+
|_.__/ \___|\___| 0.8.1 http://bee.rubyforge.org
|
64
66
|
|
65
67
|
EOF
|
66
68
|
|
@@ -210,6 +212,10 @@ EOF
|
|
210
212
|
puts "#{formatter.format_error('ERROR')}: #{$!}"
|
211
213
|
puts e.backtrace.join("\n") if verbose
|
212
214
|
exit(EXIT_BUILD_ERROR)
|
215
|
+
rescue Interrupt => e
|
216
|
+
puts "#{formatter.format_error('ERROR')}: Build was interrupted!"
|
217
|
+
puts e.backtrace.join("\n") if verbose
|
218
|
+
exit(EXIT_INTERRUPT_ERROR)
|
213
219
|
rescue Exception => e
|
214
220
|
puts "#{formatter.format_error('ERROR')}: #{$!}"
|
215
221
|
puts e.backtrace.join("\n")
|
@@ -562,6 +568,8 @@ EOF
|
|
562
568
|
attr_reader :last_target
|
563
569
|
# Last task met.
|
564
570
|
attr_reader :last_task
|
571
|
+
# Minimum duration to print on console even if not verbose (in seconds)
|
572
|
+
AUTO_DURATION = 60
|
565
573
|
|
566
574
|
# Constructor.
|
567
575
|
# - formatter: the formatter to use to output on console.
|
@@ -650,7 +658,8 @@ EOF
|
|
650
658
|
def duration
|
651
659
|
@end_time = Time.now
|
652
660
|
@duration = @end_time - @start_time
|
653
|
-
|
661
|
+
@duration = (@duration * 1000).round / 1000
|
662
|
+
puts "Built in #{@duration} s" if @verbose or @duration >= AUTO_DURATION
|
654
663
|
end
|
655
664
|
|
656
665
|
end
|
data/lib/bee_task_default.rb
CHANGED
@@ -19,6 +19,8 @@ require 'bee_util'
|
|
19
19
|
require 'erb'
|
20
20
|
require 'fileutils'
|
21
21
|
require 'net/smtp'
|
22
|
+
require 'highline/import'
|
23
|
+
require 'net/ftp'
|
22
24
|
|
23
25
|
module Bee
|
24
26
|
|
@@ -82,6 +84,8 @@ module Bee
|
|
82
84
|
# - error: the error message to print when pattern is not matched.
|
83
85
|
# - attempts: number of allowed attempts. Optional, defaults to 0, which
|
84
86
|
# means an unlimited number of attempts.
|
87
|
+
# - echo: the character to echo while typing. Useful for passwords,
|
88
|
+
# echoing '*' for instance.
|
85
89
|
#
|
86
90
|
# Example
|
87
91
|
#
|
@@ -99,7 +103,9 @@ module Bee
|
|
99
103
|
:pattern => { :mandatory => false, :type => :string },
|
100
104
|
:error => { :mandatory => false, :type => :string },
|
101
105
|
:attempts => { :mandatory => false, :type => :integer,
|
102
|
-
:default => 0 }
|
106
|
+
:default => 0 },
|
107
|
+
:echo => { :mandatory => false, :type => :string,
|
108
|
+
:default => false }
|
103
109
|
}
|
104
110
|
check_parameters(params, params_desc)
|
105
111
|
message = params[:message]
|
@@ -108,13 +114,17 @@ module Bee
|
|
108
114
|
pattern = params[:pattern]
|
109
115
|
error = params[:error]
|
110
116
|
attempts = params[:attempts]
|
117
|
+
echo_char = params[:echo]
|
111
118
|
message << " [#{default}]" if default
|
112
|
-
message << ':'
|
119
|
+
message << ': '
|
113
120
|
ok = false
|
114
121
|
nb_attempts = 1
|
115
122
|
while not (ok or (nb_attempts > attempts and attempts != 0))
|
116
|
-
|
117
|
-
|
123
|
+
if echo_char
|
124
|
+
value = ask(message) {|q| q.echo=echo_char}
|
125
|
+
else
|
126
|
+
value = ask(message)
|
127
|
+
end
|
118
128
|
value = default if default and value.length == 0
|
119
129
|
if pattern
|
120
130
|
if value =~ /#{pattern}/
|
@@ -210,6 +220,7 @@ module Bee
|
|
210
220
|
# - subject: The subject of the email.
|
211
221
|
# - message: The body of the email.
|
212
222
|
# - smtp: The address of the SMTP server.
|
223
|
+
# - encoding: The message encoding. Defaults to ASCII.
|
213
224
|
#
|
214
225
|
# Example
|
215
226
|
#
|
@@ -221,19 +232,24 @@ module Bee
|
|
221
232
|
# smtp: "smtp.bee.com"
|
222
233
|
def mail(parameters)
|
223
234
|
params_desc = {
|
224
|
-
:from
|
225
|
-
:to
|
226
|
-
:subject
|
227
|
-
:message
|
228
|
-
:smtp
|
235
|
+
:from => { :mandatory => true, :type => :string },
|
236
|
+
:to => { :mandatory => true, :type => :string_or_array },
|
237
|
+
:subject => { :mandatory => true, :type => :string },
|
238
|
+
:message => { :mandatory => true, :type => :string },
|
239
|
+
:smtp => { :mandatory => true, :type => :string },
|
240
|
+
:encoding => { :mandatory => false, :type => :string,
|
241
|
+
:default => 'UTF-8'}
|
229
242
|
}
|
230
243
|
check_parameters(parameters, params_desc)
|
231
|
-
from
|
232
|
-
to
|
233
|
-
subject
|
234
|
-
message
|
235
|
-
smtp
|
244
|
+
from = parameters[:from]
|
245
|
+
to = Array(parameters[:to])
|
246
|
+
subject = parameters[:subject]
|
247
|
+
message = parameters[:message]
|
248
|
+
smtp = parameters[:smtp]
|
249
|
+
encoding = parameters[:encoding]
|
236
250
|
body = <<EOF
|
251
|
+
MIME-Version: 1.0
|
252
|
+
Content-Type: text/plain; charset=#{encoding}
|
237
253
|
From: #{from}
|
238
254
|
To: #{to.join(', ')}
|
239
255
|
Subject: #{subject}
|
@@ -1509,6 +1525,189 @@ EOF
|
|
1509
1525
|
end
|
1510
1526
|
end
|
1511
1527
|
|
1528
|
+
######################################################################
|
1529
|
+
# FTP TASKS #
|
1530
|
+
######################################################################
|
1531
|
+
|
1532
|
+
# Login to a remote FTP site. Useful to test a connection. Raises a
|
1533
|
+
# build error if connection fails. Parameter is a hash with following
|
1534
|
+
# entries:
|
1535
|
+
#
|
1536
|
+
# - username: the username to connect to FTP. Defaults to anonymous.
|
1537
|
+
# - password: the password to connect to FTP. Defaults to no password.
|
1538
|
+
# - host: the hostname to connect to.
|
1539
|
+
#
|
1540
|
+
# Example
|
1541
|
+
#
|
1542
|
+
# - ftp_login:
|
1543
|
+
# username: foo
|
1544
|
+
# password: bar
|
1545
|
+
# host: example.com
|
1546
|
+
def ftp_login(params)
|
1547
|
+
params_desc = {
|
1548
|
+
:username => { :mandatory => false, :type => :string },
|
1549
|
+
:password => { :mandatory => false, :type => :string },
|
1550
|
+
:host => { :mandatory => true, :type => :string }
|
1551
|
+
}
|
1552
|
+
check_parameters(params, params_desc)
|
1553
|
+
username = params[:username]
|
1554
|
+
password = params[:password]
|
1555
|
+
host = params[:host]
|
1556
|
+
begin
|
1557
|
+
Net::FTP.open(host) do |ftp|
|
1558
|
+
ftp.login(username, password)
|
1559
|
+
ftp.close
|
1560
|
+
end
|
1561
|
+
puts "Connection to FTP host '#{host}' sucessful"
|
1562
|
+
rescue
|
1563
|
+
error "Error connecting to FTP host: #{$!}"
|
1564
|
+
end
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
# Get a file from a remote FTP site. Raises a build error this operation
|
1568
|
+
# fails. Parameter is a hash with following entries:
|
1569
|
+
#
|
1570
|
+
# - username: the username to connect to FTP. Defaults to anonymous.
|
1571
|
+
# - password: the password to connect to FTP. Defaults to no password.
|
1572
|
+
# - host: the hostname to connect to.
|
1573
|
+
# - file: the FTP path to remote file to get.
|
1574
|
+
# - output: the local path to file to write. Defaults to same file name
|
1575
|
+
# in current directory.
|
1576
|
+
# - binary: sets the binary mode for download. Defaults to true.
|
1577
|
+
#
|
1578
|
+
# Example:
|
1579
|
+
#
|
1580
|
+
# - ftp_get:
|
1581
|
+
# username: foo
|
1582
|
+
# password: bar
|
1583
|
+
# host: foo
|
1584
|
+
# file: test.txt
|
1585
|
+
def ftp_get(params)
|
1586
|
+
params_desc = {
|
1587
|
+
:username => { :mandatory => false, :type => :string },
|
1588
|
+
:password => { :mandatory => false, :type => :string },
|
1589
|
+
:host => { :mandatory => true, :type => :string },
|
1590
|
+
:file => { :mandatory => true, :type => :string },
|
1591
|
+
:output => { :mandatory => false, :type => :string },
|
1592
|
+
:binary => { :mandatory => false, :type => :boolean,
|
1593
|
+
:default => true }
|
1594
|
+
}
|
1595
|
+
check_parameters(params, params_desc)
|
1596
|
+
username = params[:username]
|
1597
|
+
password = params[:password]
|
1598
|
+
host = params[:host]
|
1599
|
+
file = params[:file]
|
1600
|
+
output = params[:output]||File.basename(file)
|
1601
|
+
binary = params[:binary]
|
1602
|
+
basename = File.basename(file)
|
1603
|
+
puts "Getting file '#{basename}'..."
|
1604
|
+
begin
|
1605
|
+
Net::FTP.open(host) do |ftp|
|
1606
|
+
ftp.login(username, password)
|
1607
|
+
if binary
|
1608
|
+
ftp.getbinaryfile(file, output)
|
1609
|
+
else
|
1610
|
+
ftp.gettextfile(file, output)
|
1611
|
+
end
|
1612
|
+
ftp.close
|
1613
|
+
end
|
1614
|
+
rescue
|
1615
|
+
error "Error getting file '#{basename}': #{$!}"
|
1616
|
+
end
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
# Put a file to a remote FTP site. Raises a build error this operation
|
1620
|
+
# fails. Parameter is a hash with following entries:
|
1621
|
+
#
|
1622
|
+
# - username: the username to connect to FTP. Defaults to anonymous.
|
1623
|
+
# - password: the password to connect to FTP. Defaults to no password.
|
1624
|
+
# - host: the hostname to connect to.
|
1625
|
+
# - file: locale file to send.
|
1626
|
+
# - tofile: remote file to write on remote server. Defaults to base name
|
1627
|
+
# of local file.
|
1628
|
+
# - binary: sets the binary mode for upload. Defaults to true.
|
1629
|
+
#
|
1630
|
+
# Example:
|
1631
|
+
#
|
1632
|
+
# - ftp_put:
|
1633
|
+
# username: foo
|
1634
|
+
# password: bar
|
1635
|
+
# host: foo
|
1636
|
+
# file: test.txt
|
1637
|
+
def ftp_put(params)
|
1638
|
+
params_desc = {
|
1639
|
+
:username => { :mandatory => false, :type => :string },
|
1640
|
+
:password => { :mandatory => false, :type => :string },
|
1641
|
+
:host => { :mandatory => true, :type => :string },
|
1642
|
+
:file => { :mandatory => true, :type => :string },
|
1643
|
+
:tofile => { :mandatory => false, :type => :string },
|
1644
|
+
:binary => { :mandatory => false, :type => :boolean,
|
1645
|
+
:default => true }
|
1646
|
+
}
|
1647
|
+
check_parameters(params, params_desc)
|
1648
|
+
username = params[:username]
|
1649
|
+
password = params[:password]
|
1650
|
+
host = params[:host]
|
1651
|
+
file = params[:file]
|
1652
|
+
tofile = params[:tofile]
|
1653
|
+
binary = params[:binary]
|
1654
|
+
basename = File.basename(file)
|
1655
|
+
puts "Putting file '#{basename}'..."
|
1656
|
+
begin
|
1657
|
+
Net::FTP.open(host) do |ftp|
|
1658
|
+
ftp.login(username, password)
|
1659
|
+
if binary
|
1660
|
+
ftp.putbinaryfile(file, tofile)
|
1661
|
+
else
|
1662
|
+
ftp.puttextfile(file, tofile)
|
1663
|
+
end
|
1664
|
+
ftp.close
|
1665
|
+
end
|
1666
|
+
rescue
|
1667
|
+
error "Error putting file '#{basename}': #{$!}"
|
1668
|
+
end
|
1669
|
+
end
|
1670
|
+
|
1671
|
+
# Make a directory on a remote FTP site. Raises a build error this
|
1672
|
+
# operation fails. Parameter is a hash with following entries:
|
1673
|
+
#
|
1674
|
+
# - username: the username to connect to FTP. Defaults to anonymous.
|
1675
|
+
# - password: the password to connect to FTP. Defaults to no password.
|
1676
|
+
# - host: the hostname to connect to.
|
1677
|
+
# - dir: the path of the remote directory to create.
|
1678
|
+
#
|
1679
|
+
# Example:
|
1680
|
+
#
|
1681
|
+
# - ftp_mkdir:
|
1682
|
+
# username: foo
|
1683
|
+
# password: bar
|
1684
|
+
# host: foo
|
1685
|
+
# dir: test
|
1686
|
+
def ftp_mkdir(params)
|
1687
|
+
params_desc = {
|
1688
|
+
:username => { :mandatory => false, :type => :string },
|
1689
|
+
:password => { :mandatory => false, :type => :string },
|
1690
|
+
:host => { :mandatory => true, :type => :string },
|
1691
|
+
:dir => { :mandatory => true, :type => :string }
|
1692
|
+
}
|
1693
|
+
check_parameters(params, params_desc)
|
1694
|
+
username = params[:username]
|
1695
|
+
password = params[:password]
|
1696
|
+
host = params[:host]
|
1697
|
+
dir = params[:dir]
|
1698
|
+
basename = File.basename(dir)
|
1699
|
+
puts "Making directory '#{basename}'..."
|
1700
|
+
begin
|
1701
|
+
Net::FTP.open(host) do |ftp|
|
1702
|
+
ftp.login(username, password)
|
1703
|
+
ftp.mkdir(dir)
|
1704
|
+
ftp.close
|
1705
|
+
end
|
1706
|
+
rescue
|
1707
|
+
error "Error making directory '#{basename}': #{$!}"
|
1708
|
+
end
|
1709
|
+
end
|
1710
|
+
|
1512
1711
|
######################################################################
|
1513
1712
|
# CONSTRUCTS #
|
1514
1713
|
######################################################################
|
@@ -1602,3 +1801,4 @@ EOF
|
|
1602
1801
|
end
|
1603
1802
|
|
1604
1803
|
end
|
1804
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Casabianca & Contributors
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-16 00:00:00 +02:00
|
13
13
|
default_executable: bee
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.5.1
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: highline
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.2
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: rubyzip
|
27
37
|
type: :runtime
|