hyde 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -9
- data/Rakefile +6 -4
- data/bin/hyde +8 -0
- data/lib/hyde.rb +26 -1
- data/test/hyde_test.rb +8 -0
- metadata +4 -3
data/README
CHANGED
@@ -4,12 +4,7 @@
|
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
7
|
-
|
8
|
-
== Installation
|
9
|
-
|
10
|
-
=== Archive Installation
|
11
|
-
|
12
|
-
rake install
|
7
|
+
Convert unit 'hyde' to SI metre.
|
13
8
|
|
14
9
|
=== Gem Installation
|
15
10
|
|
@@ -18,12 +13,23 @@
|
|
18
13
|
|
19
14
|
== Features/Problems
|
20
15
|
|
16
|
+
* The argument metre is not 'cm' but 'm'.
|
17
|
+
* 'hyde' command.
|
18
|
+
|
21
19
|
|
22
20
|
== Synopsis
|
23
21
|
|
22
|
+
require "hyde"
|
23
|
+
p 1.56.in_hyde
|
24
|
+
p Hyde.m_to_hyde(1.56)
|
25
|
+
|
26
|
+
command:
|
27
|
+
|
28
|
+
$ hyde 156cm
|
29
|
+
156cm: 1.0hyde
|
24
30
|
|
25
31
|
== Copyright
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
License:: Public Domain
|
34
|
+
|
35
|
+
|
data/Rakefile
CHANGED
@@ -16,8 +16,8 @@ EMAIL = "cho45@lowreal.net"
|
|
16
16
|
DESCRIPTION = "unit converter of hyde"
|
17
17
|
RUBYFORGE_PROJECT = "lowreal"
|
18
18
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
19
|
-
BIN_FILES = %w(
|
20
|
-
VERS = "0.0.
|
19
|
+
BIN_FILES = %w( hyde )
|
20
|
+
VERS = "0.0.2"
|
21
21
|
|
22
22
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
23
23
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
@@ -102,8 +102,10 @@ end
|
|
102
102
|
|
103
103
|
desc "Publish to RubyForge"
|
104
104
|
task :rubyforge => [:rdoc, :package] do
|
105
|
-
|
106
|
-
|
105
|
+
@local_dir = "html"
|
106
|
+
@host = "cho45@rubyforge.org"
|
107
|
+
@remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{NAME}"
|
108
|
+
sh %{rsync -r --delete --verbose #{@local_dir}/ #{@host}:#{@remote_dir}}
|
107
109
|
end
|
108
110
|
|
109
111
|
desc 'Package and upload the release to rubyforge.'
|
data/bin/hyde
ADDED
data/lib/hyde.rb
CHANGED
@@ -14,11 +14,36 @@ module Hyde
|
|
14
14
|
module_function :m_to_hyde
|
15
15
|
|
16
16
|
module NumericExtension
|
17
|
-
# convert to
|
17
|
+
# convert to hyde taking self as m
|
18
18
|
def in_hyde
|
19
19
|
Hyde.m_to_hyde(self)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
class HydeCommand
|
24
|
+
def run(argv)
|
25
|
+
@argv = argv.dup
|
26
|
+
@argv.each do |a|
|
27
|
+
puts "%s: %s" % [a, convert(a)]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def convert(a)
|
32
|
+
_, num, unit = */([\d.]+)([ck]?m|hyde)/.match(a)
|
33
|
+
num = num.to_f
|
34
|
+
case unit
|
35
|
+
when "m"
|
36
|
+
"#{Hyde.m_to_hyde(num)}hyde"
|
37
|
+
when "cm"
|
38
|
+
"#{Hyde.m_to_hyde(num / 100)}hyde"
|
39
|
+
when "km"
|
40
|
+
"#{Hyde.m_to_hyde(num * 1000)}hyde"
|
41
|
+
when "hyde"
|
42
|
+
"#{Hyde.hyde_to_m(num) * 100}cm"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
22
47
|
end
|
23
48
|
|
24
49
|
|
data/test/hyde_test.rb
CHANGED
@@ -10,4 +10,12 @@ class HydeTest < Test::Unit::TestCase
|
|
10
10
|
def test_coreextension
|
11
11
|
assert_equal 1, 1.56.in_hyde
|
12
12
|
end
|
13
|
+
|
14
|
+
def test_command
|
15
|
+
c = Hyde::HydeCommand.new
|
16
|
+
assert_equal "156.0cm", c.convert("1hyde")
|
17
|
+
assert_equal "1.0hyde", c.convert("156cm")
|
18
|
+
assert_equal "1.0hyde", c.convert("1.56m")
|
19
|
+
assert_equal "1.0hyde", c.convert("0.00156km")
|
20
|
+
end
|
13
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cho45
|
@@ -15,8 +15,8 @@ dependencies: []
|
|
15
15
|
|
16
16
|
description: unit converter of hyde
|
17
17
|
email: cho45@lowreal.net
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- hyde
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- README
|
27
27
|
- ChangeLog
|
28
28
|
- Rakefile
|
29
|
+
- bin/hyde
|
29
30
|
- test/hyde_test.rb
|
30
31
|
- test/test_helper.rb
|
31
32
|
- lib/hyde.rb
|