tagen 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Gemfile +5 -4
- data/Gemfile.lock +2 -0
- data/Rakefile +24 -13
- data/lib/tagen/core.rb +3 -1
- data/lib/tagen/core/kernel.rb +2 -2
- data/lib/tagen/core/symbol.rb +5 -6
- data/lib/tagen/core/time.rb +45 -3
- data/lib/tagen/date.rb +80 -0
- data/lib/tagen/socket.rb +76 -18
- data/lib/tagen/version.rb +1 -1
- data/spec/spec_helper.rb +39 -1
- data/spec/tagen/core/symbol_spec.rb +2 -1
- data/spec/tagen/core/time_spec.rb +64 -0
- data/spec/tagen/core_spec.rb +6 -0
- data/spec/tagen/date_spec.rb +146 -0
- data/spec/tagen/socket_spec.rb +28 -0
- data/tagen.gemspec +10 -9
- metadata +20 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -1,32 +1,43 @@
|
|
1
|
+
sudo = Process.pid==0 ? "" : "sudo"
|
2
|
+
|
1
3
|
desc "build a gem file"
|
2
4
|
task :release do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
run "gem build tagen.gemspec"
|
6
|
+
run "gem push *.gem"
|
7
|
+
run "#{sudo} gem install *.gem"
|
8
|
+
run "rm *.gem"
|
7
9
|
end
|
8
10
|
|
9
|
-
desc "install a gem"
|
11
|
+
desc "install a gem file"
|
10
12
|
task :install do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sh "rm *.gem"
|
13
|
+
run "gem build tagen.gemspec"
|
14
|
+
run "#{sudo} gem install *.gem"
|
15
|
+
run "rm *.gem"
|
15
16
|
end
|
16
17
|
|
17
18
|
desc "autotest with watchr"
|
18
19
|
task :test do
|
19
|
-
|
20
|
+
run "watchr tagen.watchr"
|
20
21
|
end
|
21
22
|
|
23
|
+
desc "testing the libraray"
|
22
24
|
namespace :test do
|
23
|
-
desc "testing the whole library"
|
24
25
|
task :all do
|
25
|
-
|
26
|
+
run "rspec spec"
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
+
desc "run yard server --reload"
|
31
|
+
task :doc do
|
32
|
+
run "yard server --reload"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "clean up"
|
36
|
+
task :clean do
|
37
|
+
run "rm *.gem"
|
38
|
+
end
|
39
|
+
|
40
|
+
def run cmd
|
30
41
|
puts cmd
|
31
42
|
system cmd
|
32
43
|
end
|
data/lib/tagen/core.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
core/enumerator
|
9
9
|
core/numeric
|
10
10
|
core/string
|
11
|
-
core/symbol
|
12
11
|
core/array
|
13
12
|
core/hash
|
14
13
|
core/extend_hash
|
@@ -20,3 +19,6 @@
|
|
20
19
|
|
21
20
|
core/open_option
|
22
21
|
).each {|n| require_relative n }
|
22
|
+
|
23
|
+
# from active_support
|
24
|
+
require "active_support/core_ext"
|
data/lib/tagen/core/kernel.rb
CHANGED
@@ -50,7 +50,7 @@ private
|
|
50
50
|
# RUBY_PLATFORM is "i686-linux" "i386-migw32"
|
51
51
|
#
|
52
52
|
# @return [Boolean]
|
53
|
-
def linux?
|
53
|
+
def linux?
|
54
54
|
RUBY_PLATFORM =~ /linux/
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@ private
|
|
58
58
|
#
|
59
59
|
# @return [Boolean]
|
60
60
|
# @see {#linux?}
|
61
|
-
def win32?
|
61
|
+
def win32?
|
62
62
|
RUBY_PLATFORM =~ /mingw32|mswin/
|
63
63
|
end
|
64
64
|
end # module Kernel
|
data/lib/tagen/core/symbol.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
class Symbol
|
2
|
-
|
2
|
+
# confict with active_support/core
|
3
3
|
# goes to String, return Symbol
|
4
|
-
def method_missing name, *args
|
5
|
-
ret = to_s.send name, *args
|
6
|
-
String===ret ? ret.to_sym : ret
|
7
|
-
end
|
8
|
-
|
4
|
+
#def method_missing name, *args
|
5
|
+
#ret = to_s.send name, *args
|
6
|
+
#String===ret ? ret.to_sym : ret
|
7
|
+
#end
|
9
8
|
end
|
data/lib/tagen/core/time.rb
CHANGED
@@ -1,8 +1,50 @@
|
|
1
1
|
class Time
|
2
|
-
# return a float of
|
2
|
+
# return a float of time since linux epoch
|
3
3
|
#
|
4
4
|
# #=> 1295953427.0005338
|
5
5
|
#
|
6
6
|
# @return [Float]
|
7
|
-
def self.time
|
8
|
-
|
7
|
+
def self.time
|
8
|
+
now.to_f
|
9
|
+
end
|
10
|
+
|
11
|
+
class Deta
|
12
|
+
class <<self
|
13
|
+
# @param [Time] from
|
14
|
+
# @param [Time] to
|
15
|
+
# @return [Time::Deta] deta
|
16
|
+
def deta(from, to)
|
17
|
+
seconds = (from-to).to_i
|
18
|
+
self.new(seconds)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :years, :months, :days, :hours, :minutes, :seconds
|
23
|
+
|
24
|
+
def initialize(seconds)
|
25
|
+
deta = seconds
|
26
|
+
deta, @seconds = deta.divmod(60)
|
27
|
+
deta, @minutes = deta.divmod(60)
|
28
|
+
deta, @hours = deta.divmod(24)
|
29
|
+
deta, @days = deta.divmod(30)
|
30
|
+
@years, @months = deta.divmod(12)
|
31
|
+
end
|
32
|
+
|
33
|
+
def display(include_seconds=true)
|
34
|
+
ret = ""
|
35
|
+
ret << "#{years} years " unless years == 0
|
36
|
+
ret << "#{months} months " unless months == 0
|
37
|
+
ret << "#{days} days " unless days==0
|
38
|
+
ret << "#{hours} hours " unless hours == 0
|
39
|
+
ret << "#{minutes} minutes " unless minutes == 0
|
40
|
+
ret << "#{seconds} seconds" if include_seconds
|
41
|
+
|
42
|
+
ret
|
43
|
+
end
|
44
|
+
|
45
|
+
# to [years, months, days, hours minutes seconds]
|
46
|
+
def to_a
|
47
|
+
[ years, months, days, hours, minutes, seconds ]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/tagen/date.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
class Date # ::Deta
|
4
|
+
class Deta
|
5
|
+
class <<self
|
6
|
+
# @param [Date] from
|
7
|
+
# @param [Date] to
|
8
|
+
# @return [Date::Deta] deta
|
9
|
+
def deta(from, to)
|
10
|
+
days = (from-to).to_i
|
11
|
+
self.new(days)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :years, :months, :days
|
16
|
+
|
17
|
+
def initialize(days)
|
18
|
+
deta = days
|
19
|
+
deta, @days = deta.divmod(30)
|
20
|
+
@years, @months = deta.divmod(12)
|
21
|
+
end
|
22
|
+
|
23
|
+
def display(include_days=true)
|
24
|
+
ret = ""
|
25
|
+
ret << "#{years} years " unless years == 0
|
26
|
+
ret << "#{months} months " unless months == 0
|
27
|
+
ret << "#{days} days" unless (!include_days && days==0)
|
28
|
+
|
29
|
+
ret
|
30
|
+
end
|
31
|
+
|
32
|
+
# to [years months days]
|
33
|
+
def to_a
|
34
|
+
[ years, months, days ]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
class DateTime # ::Deta
|
41
|
+
class Deta
|
42
|
+
class <<self
|
43
|
+
# @param [DateTime] from
|
44
|
+
# @param [DateTime] to
|
45
|
+
# @return [DateTime::Deta] deta
|
46
|
+
def deta(from, to)
|
47
|
+
seconds = (from-to)*24*3600.to_i
|
48
|
+
self.new(seconds)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
attr_reader :years, :months, :days, :hours, :minutes, :seconds
|
53
|
+
|
54
|
+
def initialize(seconds)
|
55
|
+
deta = seconds
|
56
|
+
deta, @seconds = deta.divmod(60)
|
57
|
+
deta, @minutes = deta.divmod(60)
|
58
|
+
deta, @hours = deta.divmod(24)
|
59
|
+
deta, @days = deta.divmod(30)
|
60
|
+
@years, @months = deta.divmod(12)
|
61
|
+
end
|
62
|
+
|
63
|
+
def display(include_seconds=true)
|
64
|
+
ret = ""
|
65
|
+
ret << "#{years} years " unless years == 0
|
66
|
+
ret << "#{months} months " unless months == 0
|
67
|
+
ret << "#{days} days " unless days==0
|
68
|
+
ret << "#{hours} hours " unless hours == 0
|
69
|
+
ret << "#{minutes} minutes " unless minutes == 0
|
70
|
+
ret << "#{seconds} seconds" if include_seconds
|
71
|
+
|
72
|
+
ret
|
73
|
+
end
|
74
|
+
|
75
|
+
# to [years, months, days, hours, minutes, seconds]
|
76
|
+
def to_a
|
77
|
+
[ years, months, days, hours, minutes, seconds ]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/tagen/socket.rb
CHANGED
@@ -1,22 +1,80 @@
|
|
1
1
|
require "socket"
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
3
|
+
class BasicSocket
|
4
|
+
MessageLengthError = Class.new(StandardError)
|
5
|
+
MessageUnderflow = Class.new(StandardError)
|
6
|
+
|
7
|
+
MAXLEN = 65535
|
8
|
+
LEN_LEN = [0].pack("N").size
|
9
|
+
|
10
|
+
# Send a message over the socket. The message is like a datagram rather
|
11
|
+
# than a stream of data.
|
12
|
+
def send2(message)
|
13
|
+
len = message.length
|
14
|
+
if len > MAXLEN
|
15
|
+
raise MessageLengthError, "MAXLEN exceeded: #{len} > #{MAXLEN}"
|
16
|
+
end
|
17
|
+
send([len].pack("N"), 0)
|
18
|
+
send(message, 0)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Receive a message from the socket. Returns +""+ when there are no
|
22
|
+
# more messages (the writer has closed its end of the socket).
|
23
|
+
# Yields each time more data is received, even if partial. This can
|
24
|
+
# be used for a progress indicator.
|
25
|
+
def recv2
|
26
|
+
if (data = recv(LEN_LEN))
|
27
|
+
if data.empty?
|
28
|
+
""
|
29
|
+
else
|
30
|
+
len = data.unpack("N")[0]
|
31
|
+
if len > MAXLEN
|
32
|
+
raise MessageLengthError, "MAXLEN exceeded: #{len} > #{MAXLEN}"
|
33
|
+
end
|
34
|
+
|
35
|
+
msg = ""
|
36
|
+
part = nil
|
37
|
+
while (delta = len - msg.length) > 0 and (part = recv(delta))
|
38
|
+
if part.length == 0
|
39
|
+
raise MessageUnderflow,
|
40
|
+
"Peer closed socket before finishing message --" +
|
41
|
+
" received #{msg.length} of #{len} bytes:\n" +
|
42
|
+
msg[0..99].unpack("H*")[0] + "..."
|
43
|
+
end
|
44
|
+
yield part if block_given?
|
45
|
+
msg << part
|
46
|
+
end
|
47
|
+
msg.empty? ? nil : msg
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_obj(obj)
|
53
|
+
send2 Marshal.dump(obj)
|
54
|
+
end
|
55
|
+
|
56
|
+
def recv_obj
|
57
|
+
Marshal.load recv2
|
58
|
+
end
|
21
59
|
end
|
60
|
+
|
61
|
+
class Socket
|
62
|
+
class <<self
|
63
|
+
# pack human-readable address to Socket address
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# addr("192.168.1.1") #=> "\xC0\xA8\x01\x01"
|
67
|
+
#
|
68
|
+
# @return [String] address used by Socket
|
69
|
+
# @see unaddr
|
70
|
+
def addr(str) str.split(".").map{|v|v.to_i}.pack("CCCC") end
|
71
|
+
|
72
|
+
# unpack to humna-readable address from Socket address
|
73
|
+
#
|
74
|
+
# @example
|
75
|
+
# unaddr("\xC0\xA8\x01\x01") #=> "192.168.1.1"
|
76
|
+
#
|
77
|
+
# @return [String] human readable address
|
78
|
+
def unaddr(str) str.unpack("CCCC").join(".") end
|
79
|
+
end
|
22
80
|
end
|
data/lib/tagen/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "tagen/core"
|
2
2
|
|
3
|
-
|
4
3
|
class Dir
|
5
4
|
class << self
|
6
5
|
def empty? path
|
@@ -8,3 +7,42 @@ class Dir
|
|
8
7
|
end
|
9
8
|
end
|
10
9
|
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
def capture(stream)
|
13
|
+
begin
|
14
|
+
stream = stream.to_s
|
15
|
+
eval "$#{stream} = StringIO.new"
|
16
|
+
yield
|
17
|
+
result = eval("$#{stream}").string
|
18
|
+
ensure
|
19
|
+
eval("$#{stream} = #{stream.upcase}")
|
20
|
+
end
|
21
|
+
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
alias :silence :capture
|
26
|
+
end
|
27
|
+
|
28
|
+
module Kernel
|
29
|
+
private
|
30
|
+
|
31
|
+
def xdescribe(*args, &blk)
|
32
|
+
describe *args do
|
33
|
+
pending "xxxxxxxxx"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def xcontext(*args, &blk)
|
38
|
+
context *args do
|
39
|
+
pending "xxxxxxxxx"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def xit(*args, &blk)
|
44
|
+
it *args do
|
45
|
+
pending "xxxxxxxx"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
=begin
|
3
4
|
describe Symbol do
|
4
5
|
describe "#method_missing" do
|
5
6
|
it "#sub. returns a symbol" do
|
@@ -9,6 +10,6 @@ describe Symbol do
|
|
9
10
|
it "#chars. return a enumerator" do
|
10
11
|
:_foo.chars.should be_an_instance_of Enumerator
|
11
12
|
end
|
12
|
-
|
13
13
|
end
|
14
14
|
end
|
15
|
+
=end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Time do
|
4
|
+
describe ".time" do
|
5
|
+
it "works" do
|
6
|
+
Time.stub_chain("now.to_f") { 1 }
|
7
|
+
Time.time.should == 1
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Deta = Time::Deta
|
13
|
+
describe Deta do
|
14
|
+
describe "#initialize" do
|
15
|
+
it "works for 36561906 seconds" do
|
16
|
+
d = Deta.new(36561906)
|
17
|
+
|
18
|
+
d.years.should == 1
|
19
|
+
d.months.should == 2
|
20
|
+
d.days.should == 3
|
21
|
+
d.hours.should == 4
|
22
|
+
d.minutes.should == 5
|
23
|
+
d.seconds.should == 6
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#display" do
|
28
|
+
it "works for 1 years 2 months 3 days 4 hours 5 minutes 6 seconds" do
|
29
|
+
d = Deta.new(36561906)
|
30
|
+
|
31
|
+
d.display.should == "1 years 2 months 3 days 4 hours 5 minutes 6 seconds"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "works for 0 second" do
|
35
|
+
d = Deta.new(0)
|
36
|
+
|
37
|
+
d.display.should == "0 seconds"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#to_a" do
|
42
|
+
it "works" do
|
43
|
+
d = Deta.new(1)
|
44
|
+
d.stub(:years) { 1 }
|
45
|
+
d.stub(:months) { 2 }
|
46
|
+
d.stub(:days) { 3 }
|
47
|
+
d.stub(:hours) { 4 }
|
48
|
+
d.stub(:minutes) { 5 }
|
49
|
+
d.stub(:seconds) { 6 }
|
50
|
+
|
51
|
+
|
52
|
+
d.to_a.should == [ 1, 2, 3, 4, 5, 6 ]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".deta" do
|
57
|
+
it "works" do
|
58
|
+
a = Deta.deta(Time.new(2011, 1, 1, 1, 1, 2), Time.new(2011, 1, 1, 1, 1, 1)).to_a
|
59
|
+
b = [ 0, 0, 0, 0, 0, 1 ]
|
60
|
+
|
61
|
+
a.should == b
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "tagen/date"
|
3
|
+
|
4
|
+
describe Date::Deta do
|
5
|
+
before :all do
|
6
|
+
Deta = Date::Deta
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#initialize" do
|
10
|
+
it "works for 423 days" do
|
11
|
+
d = Deta.new(423)
|
12
|
+
d.years.should == 1
|
13
|
+
d.months.should == 2
|
14
|
+
d.days.should == 3
|
15
|
+
end
|
16
|
+
|
17
|
+
it "works for 32 days" do
|
18
|
+
d = Deta.new(32)
|
19
|
+
d.years.should == 0
|
20
|
+
d.months.should == 1
|
21
|
+
d.days.should == 2
|
22
|
+
end
|
23
|
+
|
24
|
+
it "works for 1 day" do
|
25
|
+
d = Deta.new(1)
|
26
|
+
d.years.should == 0
|
27
|
+
d.months.should == 0
|
28
|
+
d.days.should == 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#display" do
|
33
|
+
it "works for 1 years 2 months 3 days" do
|
34
|
+
d = Deta.new(1)
|
35
|
+
d.stub(:years) { 1 }
|
36
|
+
d.stub(:months) { 2 }
|
37
|
+
d.stub(:days) { 3 }
|
38
|
+
|
39
|
+
d.display.should == "1 years 2 months 3 days"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "works for 2 months 3 days" do
|
43
|
+
d = Deta.new(1)
|
44
|
+
d.stub(:years) { 0 }
|
45
|
+
d.stub(:months) { 2 }
|
46
|
+
d.stub(:days) { 3 }
|
47
|
+
|
48
|
+
d.display.should == "2 months 3 days"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "works for 0 days" do
|
52
|
+
d = Deta.new(1)
|
53
|
+
d.stub(:years) { 0 }
|
54
|
+
d.stub(:months) { 0 }
|
55
|
+
d.stub(:days) { 0 }
|
56
|
+
|
57
|
+
d.display.should == "0 days"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "works for 0 days with :include_days => false" do
|
61
|
+
d = Deta.new(1)
|
62
|
+
d.stub(:years) { 0 }
|
63
|
+
d.stub(:months) { 0 }
|
64
|
+
d.stub(:days) { 0 }
|
65
|
+
|
66
|
+
d.display(false).should == ""
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#to_a" do
|
71
|
+
it "works" do
|
72
|
+
d = Deta.new(1)
|
73
|
+
d.stub(:years) { 1 }
|
74
|
+
d.stub(:months) { 2 }
|
75
|
+
d.stub(:days) { 3 }
|
76
|
+
|
77
|
+
d.to_a.should == [ 1, 2, 3 ]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe ".deta" do
|
82
|
+
it "works" do
|
83
|
+
a = Deta.deta(Date.new(2011, 1, 2), Date.new(2011, 1, 1)).to_a
|
84
|
+
b = [ 0, 0, 1 ]
|
85
|
+
|
86
|
+
a.should == b
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe DateTime::Deta do
|
92
|
+
before :all do
|
93
|
+
Deta = DateTime::Deta
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#initialize" do
|
97
|
+
it "works for 36561906 seconds" do
|
98
|
+
d = Deta.new(36561906)
|
99
|
+
|
100
|
+
d.years.should == 1
|
101
|
+
d.months.should == 2
|
102
|
+
d.days.should == 3
|
103
|
+
d.hours.should == 4
|
104
|
+
d.minutes.should == 5
|
105
|
+
d.seconds.should == 6
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#display" do
|
110
|
+
it "works for 1 years 2 months 3 days 4 hours 5 minutes 6 seconds" do
|
111
|
+
d = Deta.new(36561906)
|
112
|
+
|
113
|
+
d.display.should == "1 years 2 months 3 days 4 hours 5 minutes 6 seconds"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "works for 0 second" do
|
117
|
+
d = Deta.new(0)
|
118
|
+
|
119
|
+
d.display.should == "0 seconds"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#to_a" do
|
124
|
+
it "works" do
|
125
|
+
d = Deta.new(1)
|
126
|
+
d.stub(:years) { 1 }
|
127
|
+
d.stub(:months) { 2 }
|
128
|
+
d.stub(:days) { 3 }
|
129
|
+
d.stub(:hours) { 4 }
|
130
|
+
d.stub(:minutes) { 5 }
|
131
|
+
d.stub(:seconds) { 6 }
|
132
|
+
|
133
|
+
|
134
|
+
d.to_a.should == [ 1, 2, 3, 4, 5, 6 ]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe ".deta" do
|
139
|
+
it "works" do
|
140
|
+
a = Deta.deta(DateTime.new(2011, 1, 1, 1, 1, 2), DateTime.new(2011, 1, 1, 1, 1, 1)).to_a
|
141
|
+
b = [ 0, 0, 0, 0, 0, 1 ]
|
142
|
+
|
143
|
+
a.should == b
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "tagen/socket"
|
3
|
+
|
4
|
+
describe BasicSocket do
|
5
|
+
describe "#send2 and #recv2" do
|
6
|
+
it "works" do
|
7
|
+
s = TCPServer.open("127.0.0.1", 0)
|
8
|
+
af, port, host, addr = s.addr
|
9
|
+
c = TCPSocket.open(host, port)
|
10
|
+
s = s.accept
|
11
|
+
c.send2("guten")
|
12
|
+
c.send2("tag")
|
13
|
+
s.recv2.should == "guten"
|
14
|
+
s.recv2.should == "tag"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#send_obj and #recv_obj" do
|
19
|
+
it "works" do
|
20
|
+
s = TCPServer.open("127.0.0.1", 0)
|
21
|
+
af, port, host, addr = s.addr
|
22
|
+
c = TCPSocket.open(host, port)
|
23
|
+
s = s.accept
|
24
|
+
c.send_obj([1,2])
|
25
|
+
s.recv_obj.should == [1,2]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/tagen.gemspec
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
$: << File.expand_path(
|
2
|
-
require
|
1
|
+
$: << File.expand_path("../lib", __FILE__)
|
2
|
+
require "tagen/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = "tagen"
|
6
6
|
s.version = Tagen::VERSION
|
7
|
-
s.summary =
|
7
|
+
s.summary = "a core and extra extension to ruby library"
|
8
8
|
s.description = <<-EOF
|
9
9
|
a core and extra extension to ruby library.
|
10
10
|
EOF
|
11
11
|
|
12
|
-
s.author =
|
13
|
-
s.email =
|
14
|
-
s.homepage =
|
15
|
-
s.rubyforge_project =
|
12
|
+
s.author = "Guten"
|
13
|
+
s.email = "ywzhaifei@gmail.com"
|
14
|
+
s.homepage = "http://github.com/GutenYe/tagen"
|
15
|
+
s.rubyforge_project = "xx"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
|
19
|
-
s.add_dependency
|
19
|
+
s.add_dependency "activesupport", "~>3.1.0"
|
20
|
+
s.add_dependency "i18n"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &19935160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19935160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &19934120 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *19934120
|
25
36
|
description: ! "a core and extra extension to ruby library. \n"
|
26
37
|
email: ywzhaifei@gmail.com
|
27
38
|
executables: []
|
@@ -62,6 +73,7 @@ files:
|
|
62
73
|
- lib/tagen/core/string/pyformat.rb
|
63
74
|
- lib/tagen/core/symbol.rb
|
64
75
|
- lib/tagen/core/time.rb
|
76
|
+
- lib/tagen/date.rb
|
65
77
|
- lib/tagen/erb.rb
|
66
78
|
- lib/tagen/gdk_pixbuf2.rb
|
67
79
|
- lib/tagen/gtk2.rb
|
@@ -88,7 +100,11 @@ files:
|
|
88
100
|
- spec/tagen/core/open_option_spec.rb
|
89
101
|
- spec/tagen/core/string/pyformat_spec.rb
|
90
102
|
- spec/tagen/core/symbol_spec.rb
|
103
|
+
- spec/tagen/core/time_spec.rb
|
104
|
+
- spec/tagen/core_spec.rb
|
105
|
+
- spec/tagen/date_spec.rb
|
91
106
|
- spec/tagen/erb_spec.rb
|
107
|
+
- spec/tagen/socket_spec.rb
|
92
108
|
- tagen.gemspec
|
93
109
|
- tagen.watchr
|
94
110
|
homepage: http://github.com/GutenYe/tagen
|