silw 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/silw/helpers.rb +13 -12
- data/lib/silw/version.rb +1 -1
- data/spec/silw_spec.rb +10 -0
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775cb479d00b33c23dec30356cb9ff0e2545709b
|
4
|
+
data.tar.gz: ea67eca91454c19caeea52318dbd5e9ba9ad57cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f8cf4def76fdbf0d60ff1eea89084078bb0c929cda4ba0a35d41ccdd09cd73bc2d3d93f11308f1e3c09afec67f93e700d5056aa7212501e05985eade4afd09
|
7
|
+
data.tar.gz: 8fe6509d09b605a23c69d834fdb9dcb811e89e87682b3cc266acdcbe46b8720ff5f603a2e2de800cfb65deae5a6339bda5160fa2672e272ce7b8a20d1de3d751
|
data/lib/silw/helpers.rb
CHANGED
@@ -14,10 +14,12 @@ module Silw
|
|
14
14
|
|
15
15
|
def partial(thing, locals = {})
|
16
16
|
name = case thing
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
when String then
|
18
|
+
thing
|
19
|
+
else
|
20
|
+
thing.class.to_s.demodulize.underscore
|
21
|
+
end
|
22
|
+
haml :"partials/_#{name}", :locals => {name.to_sym => thing}.merge(locals)
|
21
23
|
end
|
22
24
|
|
23
25
|
def url_for(thing, options = {})
|
@@ -40,15 +42,14 @@ module Silw
|
|
40
42
|
[:method, :confirm].each { |a| options[:data][a] = options.delete(a) }
|
41
43
|
haml "%a#{options} #{title}"
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
def like_filesize(nr)
|
45
|
-
{
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}.each_pair{|e, s| return "#{(nr.to_f / (s / 1024)).round(2)}#{e}" if nr < s }
|
47
|
+
{'bytes' => 1024 ** 1,
|
48
|
+
'KB' => 1024 ** 2,
|
49
|
+
'MB' => 1024 ** 3,
|
50
|
+
'GB' => 1024 ** 4,
|
51
|
+
'TB' => 1024 ** 5,
|
52
|
+
}.each_pair { |e, s| return "#{(nr.to_f / (s / 1024)).round(2)}#{e}" if nr < s }
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
data/lib/silw/version.rb
CHANGED
data/spec/silw_spec.rb
CHANGED
@@ -55,5 +55,15 @@ module Silw
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
describe "Human-readable conversions" do
|
60
|
+
it "should display readable numbers" do
|
61
|
+
expect(like_filesize(1_024 ** 0)).to eq "1.0bytes"
|
62
|
+
expect(like_filesize(1_024 ** 1)).to eq "1.0KB"
|
63
|
+
expect(like_filesize(1_024 ** 2)).to eq "1.0MB"
|
64
|
+
expect(like_filesize(1_024 ** 3)).to eq "1.0GB"
|
65
|
+
expect(like_filesize(1_024 ** 4)).to eq "1.0TB"
|
66
|
+
end
|
67
|
+
end
|
58
68
|
end
|
59
69
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silw
|
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
|
- Florin T.PATRASCU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|