bytes_converter 0.0.5 → 0.0.6

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d724809620fd4377ac324f4d164b1854de4e0aa
4
+ data.tar.gz: f37e1c42cd6a8e1f73f7116361250338d61d8713
5
+ SHA512:
6
+ metadata.gz: ccb9dca1293e640a794b1df6205d76b55d3d35942ad7ef6e10aae6eda52ad8acef8d7b7c0e458593bb4e044b70f59f2b38644c55566853ab5edd79c2429ae771
7
+ data.tar.gz: 1d4020f38fc20c722d7020c480ad017cf324e9cd554fc38e61bb21529001439866d3a9efc47b212ba5c12c294968408cd9b682dca4187b79e016084d71bf6d8a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ sudo: false
4
+ rvm:
5
+ - 2.2
@@ -0,0 +1,5 @@
1
+ FROM ruby:2.2
2
+ COPY . /usr/src/app
3
+ WORKDIR /usr/src/app
4
+ RUN bundle install
5
+ CMD ["bundle", "exec", "rake"]
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rake'
4
+ gem 'rspec'
5
+
3
6
  # Specify your gem's dependencies in bytes_converter.gemspec
4
7
  gemspec
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # BytesConverter
2
+ [![Build Status](https://travis-ci.org/wasilak/bytes_converter.svg?branch=master)](https://travis-ci.org/wasilak/bytes_converter) [![Gem Version](https://badge.fury.io/rb/bytes_converter.svg)](http://badge.fury.io/rb/bytes_converter) [![Code Climate](https://codeclimate.com/github/wasilak/bytes_converter/badges/gpa.svg)](https://codeclimate.com/github/wasilak/bytes_converter)
2
3
 
3
4
  Gem converting Kilobytes, Megabytes and Gigabytes into bytes.
4
5
 
@@ -21,13 +22,13 @@ Or install it yourself as:
21
22
  first:
22
23
 
23
24
  ```ruby
24
- require "bytes_converter"
25
+ require "bytes_converter"
25
26
  ```
26
27
 
27
28
  Converting strings to bytes:
28
29
 
29
30
  ```ruby
30
- BytesConverter::convert "some string" # --> Float
31
+ BytesConverter::convert "some string" # --> Float
31
32
  ```
32
33
 
33
34
  where "some string" can be anything like in these examples:
@@ -35,32 +36,32 @@ where "some string" can be anything like in these examples:
35
36
  ```ruby
36
37
  BytesConverter::convert "12.3M" # --> 12897484.8
37
38
  BytesConverter::convert "12.3" # --> 12.3 (no unit means bytes)
38
- BytesConverter::convert "12.3 kilo bytes" # --> 12595.2
39
- BytesConverter::convert "12.3 Megabytes" # --> 12897484.8
40
- BytesConverter::convert "12.3 m" # --> 12897484.8
41
- BytesConverter::convert "12.3 k" # --> 12595.2
42
- BytesConverter::convert "12.3 bk" # --> 0.0 (b is not recognized)
43
- BytesConverter::convert "12,3m" # --> 12897484.8
44
- BytesConverter::convert "123" # --> 123
39
+ BytesConverter::convert "12.3 kilo bytes" # --> 12595.2
40
+ BytesConverter::convert "12.3 Megabytes" # --> 12897484.8
41
+ BytesConverter::convert "12.3 m" # --> 12897484.8
42
+ BytesConverter::convert "12.3 k" # --> 12595.2
43
+ BytesConverter::convert "12.3 bk" # --> 0.0 (b is not recognized)
44
+ BytesConverter::convert "12,3m" # --> 12897484.8
45
+ BytesConverter::convert "123" # --> 123
45
46
  ```
46
47
 
47
48
  You can add new unit as a hash. Let's say you want OrangeBytes unit:
48
49
 
49
50
  ```ruby
50
- orange = {"o" => 2}
51
- BytesConverter::add_unit orange
51
+ orange = {"o" => 2}
52
+ BytesConverter::add_unit orange
52
53
  ```
53
54
 
54
55
  ... and remove it with:
55
56
 
56
57
  ```ruby
57
- BytesConverter::remove_unit "o"
58
+ BytesConverter::remove_unit "o"
58
59
  ```
59
60
 
60
61
  To get all available units:
61
62
 
62
63
  ```ruby
63
- BytesConverter::get_units # --> Hash
64
+ BytesConverter::get_units # --> Hash
64
65
  ```
65
66
 
66
67
  ## Contributing
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
@@ -6,7 +6,9 @@ module BytesConverter
6
6
  @sizes = {
7
7
  "k" => 1024,
8
8
  "m" => 1024*1024,
9
- "g" => 1024*1024*1024
9
+ "g" => 1024*1024*1024,
10
+ "t" => 1024*1024*1024*1024,
11
+ "p" => 1024*1024*1024*1024*1024
10
12
  }
11
13
 
12
14
  # method converting size into bytes
@@ -1,3 +1,3 @@
1
1
  module BytesConverter
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require 'bytes_converter'
3
+
4
+ describe BytesConverter do
5
+ context "when getting list" do
6
+ it "should return hash" do
7
+ list = BytesConverter::get_units
8
+ list.should be_kind_of Hash
9
+ end
10
+ end
11
+
12
+ context "when adding unit" do
13
+ it "should increase list size by one" do
14
+ list = BytesConverter::get_units
15
+ before = list.size
16
+
17
+ new_unit = {'o' => 2}
18
+ BytesConverter::add_unit new_unit
19
+
20
+ list = BytesConverter::get_units
21
+ after = list.size
22
+
23
+ after.should be before+1
24
+ end
25
+ end
26
+
27
+ context "when removing unit" do
28
+ it "should decrease list size by one" do
29
+ list = BytesConverter::get_units
30
+ before = list.size
31
+
32
+ BytesConverter::remove_unit "m"
33
+
34
+ list = BytesConverter::get_units
35
+ after = list.size
36
+
37
+ after.should be before-1
38
+ end
39
+ end
40
+
41
+ context "when converting size" do
42
+ it "should return float" do
43
+ out = BytesConverter::convert "120,3 Megabytes"
44
+ out.should be_kind_of Float
45
+ end
46
+ end
47
+
48
+ context "when converting not existant unit" do
49
+ it "should return zero" do
50
+ out = BytesConverter::convert "4 squirtles"
51
+ out.should eq(0)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+
17
+ config.mock_with :rspec do |c|
18
+ c.syntax = [:should, :expect]
19
+ end
20
+ config.expect_with :rspec do |c|
21
+ c.syntax = [:should, :expect]
22
+ end
23
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bytes_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Piotr Wasilewski
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
11
+ date: 2017-07-01 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Gem converting Kilobytes, Megabytes and Gigabytes to bytes
15
14
  email:
@@ -18,7 +17,10 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - .gitignore
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - Dockerfile
22
24
  - Gemfile
23
25
  - LICENSE.txt
24
26
  - README.md
@@ -26,28 +28,31 @@ files:
26
28
  - bytes_converter.gemspec
27
29
  - lib/bytes_converter.rb
28
30
  - lib/bytes_converter/version.rb
31
+ - spec/bytes_converter_spec.rb
32
+ - spec/spec_helper.rb
29
33
  homepage: https://github.com/wasilak/bytes_converter
30
34
  licenses: []
35
+ metadata: {}
31
36
  post_install_message:
32
37
  rdoc_options: []
33
38
  require_paths:
34
39
  - lib
35
40
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
41
  requirements:
38
- - - ! '>='
42
+ - - ">="
39
43
  - !ruby/object:Gem::Version
40
44
  version: '0'
41
45
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
46
  requirements:
44
- - - ! '>='
47
+ - - ">="
45
48
  - !ruby/object:Gem::Version
46
49
  version: '0'
47
50
  requirements: []
48
51
  rubyforge_project:
49
- rubygems_version: 1.8.24
52
+ rubygems_version: 2.6.12
50
53
  signing_key:
51
- specification_version: 3
54
+ specification_version: 4
52
55
  summary: kB, MB, GB to bytes converter
53
- test_files: []
56
+ test_files:
57
+ - spec/bytes_converter_spec.rb
58
+ - spec/spec_helper.rb