rubyhelper 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5cf099d86522c427851c185b11ecef4a78459fb
4
- data.tar.gz: 81414e718403f9f634c524413f9822f38538fd7e
3
+ metadata.gz: ad26aad4e19650c436656640d87daf49439a26e0
4
+ data.tar.gz: 181537485327ea18811bc6939173359c57c15e07
5
5
  SHA512:
6
- metadata.gz: afe47aab45899ff445f568fa6ceb707ca84125178056bd95d43059dae650ed4fb381c15da91d0a89154fec1ec0d0b2be7148cd5d28af23a2db1aad3ca91ac1fe
7
- data.tar.gz: d1455d1adba3d32e8e76ccd8093bb5f6fd5f79e85e16c29cf7ebadddc7c98f1cc56b5007ba308d238ff6bd47e0df562ae7f210be291af45531010783ec8c3735
6
+ metadata.gz: 2991bef981598be1edea094817568d38022b9ca2171732faf6fd87f620fcc3dd7346839012c9336b302e19d57db1f52b19a103c158087c338e8e368d038c151a
7
+ data.tar.gz: 44177c3803f4905ddf5059cce17d41806735291e391287808ddcb1431486f8be26bc461500b1b01b0c06c375e91fda2b51bb8bdfb0d1dc8a3ff0de79e73cc8e8
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # rubyhelper
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/rubyhelper.svg)](http://badge.fury.io/rb/rubyhelper)
4
+
5
+ You can see the documentation here : https://www.omniref.com/ruby/gems/rubyhelper
6
+
7
+ ## Wtf ?
8
+ This gem is my own creation. It is a compilation of shortcuts, improvement,
9
+ helpers about the basic classes, String, Array, ... to make your work easier.
10
+ I hope too help you with this gem.
11
+
12
+
13
+ ## My favorites functions from this gem
14
+ - String.new.static(n) => String
15
+ Render a cool string with a static size. Few cool options tested and validated
16
+ - String.new.get_float => String
17
+ Usefull to extract a Numerical value from a stupid String
18
+ - Array.new.average /averagef
19
+ Simple and usefull integer/float average
20
+ - Array.new.sumf / sum
21
+ Simple and usefull float/integer sum
22
+
23
+
24
+ ## Notes about the source code
25
+ The following sources code is not only my stuff, but also an implementation of idea found on stackoverflow, ...
26
+
27
+
28
+ # TODO
29
+ - Benchmark Hash.except with
30
+ ```
31
+ h.delete_if{|k| [:a].include? k}
32
+ ```
33
+ - Improve documentation
34
+ - Prepare the v1.0
35
+ - Improve VersionHelper tests
36
+
37
+ # Contributors
38
+ - poulet_a : Creator and main developper. Feel free to ask me a question by email.
39
+ email : arthur.poulet AT cryptolab.net
40
+ OpenPGP : 0x6D9EA34A
41
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ module RubyHelper
2
+ VERSION = "0.6.5"
3
+ #LAST_VERSION = `gem list rubyhelper`.split(",").first.gsub(/[^\d\.]/, "")
4
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "lib/rubyhelper/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'rubyhelper'
5
+ s.version = RubyHelper::VERSION
6
+ s.date = Time.now.getgm.to_s.split.first
7
+ s.summary = "add tests and readme to gemspec"
8
+ s.description = "A list of utils for the basic Class of ruby."
9
+ s.authors = [
10
+ "poulet_a"
11
+ ]
12
+ s.email = "poulet_a@epitech.eu",
13
+ s.files = [
14
+ "lib/rubyhelper.rb",
15
+ "lib/rubyhelper/version.rb",
16
+ "lib/rubyhelper/integerhelper.rb",
17
+ "lib/rubyhelper/numerichelper.rb",
18
+ "lib/rubyhelper/stringhelper.rb",
19
+ "lib/rubyhelper/arrayhelper.rb",
20
+ "lib/rubyhelper/timehelper.rb",
21
+ "lib/rubyhelper/hashhelper.rb",
22
+ "lib/rubyhelper/versionhelper.rb",
23
+ "README.md",
24
+ "Rakefile",
25
+ "rubyhelper.gemspec",
26
+ "test/test_arrayhelper.rb",
27
+ "test/test_hashhelper.rb",
28
+ "test/test_numerichelper.rb",
29
+ "test/test_stringhelper.rb",
30
+ "test/test_versionhelper.rb",
31
+ ]
32
+ s.homepage = "https://gitlab.com/Sopheny/rubyhelper"
33
+ s.license = "GNU/GPLv3"
34
+ end
@@ -0,0 +1,42 @@
1
+ #encoding: utf-8
2
+ require 'minitest/autorun'
3
+ require_relative '../lib/rubyhelper'
4
+
5
+ class ArrayHelperTest < Minitest::Test
6
+
7
+ def test_joini
8
+ assert_equal("s,S.s", ["s","S","s"].joini([",", "."]))
9
+ assert_equal("s,S.s.S", ["s","S","s","S"].joini([",", ".", "."]))
10
+ end
11
+
12
+ def test_sum
13
+ assert_equal(12, [1,2,9].sum)
14
+ assert_equal(0, [].sum)
15
+ end
16
+
17
+ def test_sumf
18
+ assert_equal(12.0, [1,2, 9].sumf)
19
+ assert_equal(0.1, [0.01, 0.09, -0, -1, 1.1, -0.1].sumf.round(2))
20
+ assert_equal(0.0, [].sumf)
21
+ end
22
+
23
+ def test_average
24
+ assert_equal(2, [1,2,3].average)
25
+ end
26
+
27
+ def test_averagef
28
+ assert_equal(2.5, [2,3].averagef)
29
+ end
30
+
31
+ def test_maxs
32
+ assert_equal([44], [2,3,1,14,44,-1,1,2].maxs(0))
33
+ assert_equal([44], [2,3,1,14,44,-1,1,2].maxs(1))
34
+ assert_equal([14,44], [2,3,1,14,44,-1,1,2].maxs(2))
35
+ assert_equal([-1,1,1,2,2,3,14,44], [2,3,1,14,44,-1,1,2].maxs(100))
36
+ end
37
+
38
+ def test_compacti
39
+ assert_equal([" "], ["", " ", nil].compacti)
40
+ end
41
+
42
+ end
@@ -0,0 +1,17 @@
1
+ #encoding: utf-8
2
+ require 'minitest/autorun'
3
+ require_relative '../lib/rubyhelper'
4
+
5
+ class ArrayHelperTest < Minitest::Test
6
+
7
+ def test_joini
8
+ assert_equal({ :data => :a, :datb => :b },
9
+ {
10
+ :datx => :x,
11
+ :data => :a,
12
+ :datb => :b,
13
+ :datc => :c,
14
+ }.except!(:datx, :datc))
15
+ end
16
+
17
+ end
@@ -0,0 +1,24 @@
1
+ require 'minitest/autorun'
2
+ require 'rubyhelper'
3
+
4
+ class NumericHelperTest < Minitest::Test
5
+
6
+ def test_min
7
+ assert_equal(2, 1.min(2))
8
+ assert_equal(1, 1.min(1))
9
+ assert_equal(1, 1.min(0))
10
+ assert_equal(0, (-1).min(0))
11
+ assert_equal(1, 0.min(1))
12
+ assert_equal(1.1, 1.min(1.1))
13
+ end
14
+
15
+ def test_max
16
+ assert_equal(1, 1.max(2))
17
+ assert_equal(1, 1.max(1))
18
+ assert_equal(0, 1.max(0))
19
+ assert_equal(-1, (-1).max(0))
20
+ assert_equal(0, 0.max(1))
21
+ assert_equal(1, (2.2).max(1))
22
+ end
23
+
24
+ end
@@ -0,0 +1,103 @@
1
+ #encoding: utf-8
2
+ require 'minitest/autorun'
3
+ require_relative '../lib/rubyhelper'
4
+
5
+ class StringHelperTest < Minitest::Test
6
+
7
+ def test_to_plain
8
+ assert_equal("bonjour".to_plain, "bonjour")
9
+ assert_equal("bonjouré".to_plain, "bonjoure")
10
+ assert_equal("bonjo\\AAAur".to_plain, "bonjo\\AAAur")
11
+ end
12
+
13
+ def test_p
14
+ assert_equal("bonjour".p, "bonjour")
15
+ assert_equal("bonjouré".p, "bonjoure")
16
+ assert_equal("bonjo\\AAAur".p, "bonjo\\AAAur")
17
+ end
18
+
19
+ def test_p!
20
+ assert_equal("bonjour".p!, "bonjour")
21
+ assert_equal("bonjouré".p!, "bonjoure")
22
+ assert_equal("bonjo\\AAAur".p!, "bonjo\\AAAur")
23
+ end
24
+
25
+ def test_to_case
26
+ assert_equal("bonjour".to_case(:downcase), "bonjour")
27
+ assert_equal("bonJour".to_case(:upcase), "BONJOUR")
28
+ assert_equal("bonJour".to_case(:capitalize), "Bonjour")
29
+ end
30
+
31
+ def test_to_case!
32
+ assert_equal("bonjour".to_case!(:downcase), "bonjour")
33
+ assert_equal("bonJour".to_case!(:upcase), "BONJOUR")
34
+ assert_equal("bonJour".to_case!(:capitalize), "Bonjour")
35
+ end
36
+
37
+ def test_to_ascii
38
+ assert_equal("bonjoure".to_ascii(""), "bonjoure")
39
+ assert_equal("bonjouré".to_ascii(""), "bonjoure")
40
+ assert_equal("bonjouré".to_ascii("."), "bonjoure")
41
+ assert_equal("bonjour€".to_ascii(""), "bonjour")
42
+ assert_equal("bonjour€".to_ascii("."), "bonjour.")
43
+ end
44
+
45
+ def test_to_f
46
+ assert_equal("bonjour".to_f, 0.0)
47
+ assert_equal("bonj1our".to_f, 0.0)
48
+ assert_equal("1.1.1".to_f, 1.1)
49
+ assert_equal("1.1".to_f, 1.1)
50
+ assert_equal("1,1".to_f, 1.1)
51
+ assert_equal(",1,1".to_f, 0.1)
52
+ end
53
+
54
+ def test_to_ii
55
+ assert_equal("1 1".to_ii(), 11)
56
+ assert_equal("06.08.68".to_ii("."), 60868)
57
+ assert_equal("06.08.68".to_ii("\. \t\-"), 60868)
58
+ end
59
+
60
+ def test_to_t
61
+ assert_equal("true".to_t, true)
62
+ assert_equal("false".to_t, false)
63
+ assert_equal("truex".to_t, nil)
64
+ assert_equal("xfalsex".to_t, nil)
65
+ assert_equal("".to_t, nil)
66
+ end
67
+
68
+ def test_static
69
+ assert_equal("r", "bonjour".static(1, " "))
70
+ assert_equal("our", "bonjour".static(3, " "))
71
+ assert_equal("bonjour ", "bonjour".static(10, " "))
72
+ assert_equal("b", "bonjour".static(1, " ", :front))
73
+ assert_equal("bon", "bonjour".static(3, " ", :front))
74
+ assert_equal(" bonjour", "bonjour".static(10, " ", :front))
75
+ assert_equal("j", "bonjour".static(1, " ", :center))
76
+ assert_equal("jo", "bonjour".static(2, " ", :center))
77
+ assert_equal("njo", "bonjour".static(3, " ", :center))
78
+ assert_equal("njou", "bonjour".static(4, " ", :center))
79
+ assert_equal("bonjour ", "bonjour".static(8, " ", :center))
80
+ assert_equal(" bonjour ", "bonjour".static(9, " ", :center))
81
+ assert_equal(" bonjour ", "bonjour".static(10, " ", :center))
82
+ assert_equal(" bonjour ", "bonjour".static(11, " ", :center))
83
+ end
84
+
85
+ def test_get_int
86
+ assert_equal("1312".get_int(), "1312")
87
+ assert_equal("ea -ze 13e12 à nnazdaz d".get_int(), "-1312")
88
+ assert_equal("ea\n ze +13\n12\n à nnazdaz\n\t\n\r d".get_int(), "+1312")
89
+ end
90
+
91
+ def test_get_int
92
+ assert_equal("13,12".get_float(), "13,12")
93
+ assert_equal("ea -ze 13e.12 à nnazdaz d".get_float(), "-13.12")
94
+ assert_equal("ea\n ze +13\n.12\n à nnazdaz\n\t\n\r d".get_float(), "+13.12")
95
+ end
96
+
97
+ def test_scapitalize
98
+ assert_equal("Bonjour Monsieur", "Bonjour Monsieur".scapitalize)
99
+ assert_equal("Bonjour M A D & A", "BONJOUR M A D & A".scapitalize)
100
+ assert_equal("1 And 1 Sontdesvoleurs", "1 and 1 sontdesvoleurs".scapitalize)
101
+ end
102
+
103
+ end
@@ -0,0 +1,58 @@
1
+ require 'minitest/autorun'
2
+ require 'rubyhelper'
3
+
4
+ class VersionHelperTest < Minitest::Test
5
+
6
+ def test_new
7
+ v1 = VersionHelper::Version.new 1
8
+ v2 = VersionHelper::Version.new [1,2]
9
+ v3 = VersionHelper::Version.new "v1,2.3"
10
+ v4 = VersionHelper::Version.new 123
11
+ end
12
+
13
+ def test_incr!
14
+ v1 = VersionHelper::Version.new 1
15
+ v2 = VersionHelper::Version.new 1,2
16
+ v3 = VersionHelper::Version.new 1,2,3
17
+ v1.incr!
18
+ v2.incr!
19
+ v3.incr!
20
+ end
21
+
22
+ def test_decr!
23
+ v1 = VersionHelper::Version.new 1
24
+ v2 = VersionHelper::Version.new 1,2
25
+ v3 = VersionHelper::Version.new 1,2,3
26
+ v1.decr!
27
+ v2.decr!
28
+ v3.decr!
29
+ end
30
+
31
+ def test_to_i
32
+ v1 = VersionHelper::Version.new 1
33
+ v2 = VersionHelper::Version.new 1,2
34
+ v3 = VersionHelper::Version.new 1,2,3
35
+ assert_equal(1, v1.to_i)
36
+ assert_equal(12, v2.to_i)
37
+ assert_equal(123, v3.to_i)
38
+ end
39
+
40
+ def test_to_s
41
+ v1 = VersionHelper::Version.new 1
42
+ v2 = VersionHelper::Version.new 1,2
43
+ v3 = VersionHelper::Version.new 1,2,3
44
+ assert_equal("1", v1.to_s)
45
+ assert_equal("1.2", v2.to_s)
46
+ assert_equal("1.2.3", v3.to_s)
47
+ end
48
+
49
+ def test_to_a
50
+ v1 = VersionHelper::Version.new 1
51
+ v2 = VersionHelper::Version.new 1,2
52
+ v3 = VersionHelper::Version.new 1,2,3
53
+ assert_equal([1], v1.to_a)
54
+ assert_equal([1,2], v2.to_a)
55
+ assert_equal([1,2,3], v3.to_a)
56
+ end
57
+
58
+ end
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyhelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - poulet_a
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A list of utils for the basic Class of ruby.
14
14
  email:
15
15
  - poulet_a@epitech.eu
16
16
  - - lib/rubyhelper.rb
17
+ - lib/rubyhelper/version.rb
17
18
  - lib/rubyhelper/integerhelper.rb
18
19
  - lib/rubyhelper/numerichelper.rb
19
20
  - lib/rubyhelper/stringhelper.rb
@@ -21,10 +22,20 @@ email:
21
22
  - lib/rubyhelper/timehelper.rb
22
23
  - lib/rubyhelper/hashhelper.rb
23
24
  - lib/rubyhelper/versionhelper.rb
25
+ - README.md
26
+ - Rakefile
27
+ - rubyhelper.gemspec
28
+ - test/test_arrayhelper.rb
29
+ - test/test_hashhelper.rb
30
+ - test/test_numerichelper.rb
31
+ - test/test_stringhelper.rb
32
+ - test/test_versionhelper.rb
24
33
  executables: []
25
34
  extensions: []
26
35
  extra_rdoc_files: []
27
36
  files:
37
+ - README.md
38
+ - Rakefile
28
39
  - lib/rubyhelper.rb
29
40
  - lib/rubyhelper/arrayhelper.rb
30
41
  - lib/rubyhelper/hashhelper.rb
@@ -32,7 +43,14 @@ files:
32
43
  - lib/rubyhelper/numerichelper.rb
33
44
  - lib/rubyhelper/stringhelper.rb
34
45
  - lib/rubyhelper/timehelper.rb
46
+ - lib/rubyhelper/version.rb
35
47
  - lib/rubyhelper/versionhelper.rb
48
+ - rubyhelper.gemspec
49
+ - test/test_arrayhelper.rb
50
+ - test/test_hashhelper.rb
51
+ - test/test_numerichelper.rb
52
+ - test/test_stringhelper.rb
53
+ - test/test_versionhelper.rb
36
54
  homepage: https://gitlab.com/Sopheny/rubyhelper
37
55
  licenses:
38
56
  - GNU/GPLv3
@@ -56,6 +74,6 @@ rubyforge_project:
56
74
  rubygems_version: 2.4.1
57
75
  signing_key:
58
76
  specification_version: 4
59
- summary: add versionhelper
77
+ summary: add tests and readme to gemspec
60
78
  test_files: []
61
79
  has_rdoc: