place 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/place.rb +32 -19
- data/place.gemspec +3 -3
- data/test/test_place.rb +8 -7
- metadata +6 -6
data/lib/place.rb
CHANGED
@@ -5,7 +5,6 @@ require 'nokogiri'
|
|
5
5
|
require 'json'
|
6
6
|
require 'logger'
|
7
7
|
|
8
|
-
|
9
8
|
require File.join(File.dirname(__FILE__), 'place', 'project')
|
10
9
|
require File.join(File.dirname(__FILE__), 'place', 'time_point')
|
11
10
|
require File.join(File.dirname(__FILE__), 'place', 'user')
|
@@ -17,7 +16,7 @@ require File.join(File.dirname(__FILE__), 'place', 'participation')
|
|
17
16
|
|
18
17
|
|
19
18
|
module Place
|
20
|
-
VERSION = '0.1.
|
19
|
+
VERSION = '0.1.1'
|
21
20
|
|
22
21
|
@conf = {}
|
23
22
|
|
@@ -89,24 +88,38 @@ module Place
|
|
89
88
|
# from duration to number of hours (1d == 8h)
|
90
89
|
def to_hours(duration)
|
91
90
|
return nil if duration.nil?
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
elsif duration =~ /(\d+)h/
|
104
|
-
days, hours = 0, $1.to_f
|
91
|
+
|
92
|
+
case duration
|
93
|
+
when /([\d\/\s]*)d\s*([\d\/\s]*)h/
|
94
|
+
days = normalize($1)
|
95
|
+
hours = normalize($2)
|
96
|
+
when /([\d\/\s]*)d/
|
97
|
+
days = normalize($1)
|
98
|
+
hours = 0.0
|
99
|
+
when /([\d\/\s]*)h/
|
100
|
+
days = 0.0
|
101
|
+
hours = normalize($1)
|
105
102
|
else
|
106
|
-
|
103
|
+
days = 0
|
104
|
+
hours = 0
|
107
105
|
end
|
108
|
-
|
109
|
-
|
106
|
+
|
107
|
+
8*days.to_f + hours.to_f
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def normalize(e)
|
113
|
+
case e
|
114
|
+
when /(\d+)\s+(\d+)\/(\d+)/
|
115
|
+
# 1 1/2 -> 1.5
|
116
|
+
$1.to_f + $2.to_f / $3.to_f
|
117
|
+
when /(\d+)\/(\d+)/
|
118
|
+
# 1/2 -> 0.5
|
119
|
+
$1.to_f / $2.to_f
|
120
|
+
when /(\d+)/
|
121
|
+
# 3 -> 3
|
122
|
+
$1.to_f
|
123
|
+
end
|
110
124
|
end
|
111
|
-
|
112
125
|
end
|
data/place.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "place"
|
4
|
-
s.version = "0.1.
|
5
|
-
s.summary = "Polarion
|
4
|
+
s.version = "0.1.1"
|
5
|
+
s.summary = "Polarion Lace: Polarion items access in Ruby"
|
6
6
|
s.description = <<-EOF
|
7
7
|
Extract information from Polarion and turns it into easy manageable ruby objects.
|
8
8
|
|
9
9
|
Those objects are stored via Redis.
|
10
10
|
EOF
|
11
11
|
s.authors = ["Carlo Pecchia"]
|
12
|
-
s.email = ["
|
12
|
+
s.email = ["c.pecchia@gmail.com"]
|
13
13
|
s.homepage = "http://github.com/carlopecchia/place"
|
14
14
|
s.add_dependency('json')
|
15
15
|
s.add_dependency('ohm')
|
data/test/test_place.rb
CHANGED
@@ -17,12 +17,13 @@ class PlaceTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_duration
|
20
|
-
assert_equal
|
21
|
-
assert_equal
|
22
|
-
assert_equal
|
23
|
-
assert_equal
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
20
|
+
assert_equal 11, to_hours('1d 3h')
|
21
|
+
assert_equal 16, to_hours('2d')
|
22
|
+
assert_equal 3, to_hours('3h')
|
23
|
+
assert_equal 0.5, to_hours('1/2h')
|
24
|
+
assert_equal 4, to_hours('1/2d')
|
25
|
+
assert_equal 9.5, to_hours('1d 1 1/2h')
|
26
|
+
assert_equal 0, to_hours('')
|
27
|
+
assert_equal nil, to_hours(nil)
|
27
28
|
end
|
28
29
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: place
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Carlo Pecchia
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-29 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,7 @@ description: " Extract information from Polarion and turns it into easy manag
|
|
64
64
|
\t\n\
|
65
65
|
\tThose objects are stored via Redis.\n"
|
66
66
|
email:
|
67
|
-
-
|
67
|
+
- c.pecchia@gmail.com
|
68
68
|
executables: []
|
69
69
|
|
70
70
|
extensions: []
|
@@ -128,6 +128,6 @@ rubyforge_project:
|
|
128
128
|
rubygems_version: 1.3.7
|
129
129
|
signing_key:
|
130
130
|
specification_version: 3
|
131
|
-
summary: "Polarion
|
131
|
+
summary: "Polarion Lace: Polarion items access in Ruby"
|
132
132
|
test_files: []
|
133
133
|
|