torden 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +25 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/Rakefile.backup +13 -0
- data/lib/torden/animation.rb +18 -0
- data/lib/torden/progress_bar.rb +39 -0
- data/lib/torden/version.rb +3 -0
- data/lib/torden.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/animation_spec.rb +12 -0
- data/spec/unit/progress_bar_spec.rb +14 -0
- data/torden.gemspec +23 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: adab7fcac0ff2a8bcb54d4f48a2e7a46be305503
|
4
|
+
data.tar.gz: aa11ef453f7472e6ef4050b9834828d8a73b8b71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9fe2c0b87b6a2b3bb9189bfc4e2213f4f63b11bb43db5a90120c96d76ca9cf79abfb8a658cc7ca4ad26d175ef3b48ce2524a0cc0c3d851ac083151637e2ff94
|
7
|
+
data.tar.gz: fabf16d4f883971b7ac0b54b7cb0834fbe6452abb6f4b1faa389e8ee42ddb8a56e65aac2df3a8885f5b94e289aec975040cc3ba1b3eb47e18ba8a6484c296fbd
|
data/.autotest
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "autotest/restart"
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.testlib = "minitest/unit"
|
7
|
+
#
|
8
|
+
# at.extra_files << "../some/external/dependency.rb"
|
9
|
+
#
|
10
|
+
# at.libs << ":../some/external"
|
11
|
+
#
|
12
|
+
# at.add_exception "vendor"
|
13
|
+
#
|
14
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
15
|
+
# at.files_matching(/test_.*rb$/)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# %w(TestA TestB).each do |klass|
|
19
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
24
|
+
# system "rake build"
|
25
|
+
# end
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ragmaanir
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Torden
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'torden'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install torden
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/torden/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/Rakefile.backup
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Torden
|
2
|
+
class ProgressBar
|
3
|
+
|
4
|
+
attr_reader :progress, :inner_length, :space_char, :progress_char
|
5
|
+
|
6
|
+
def initialize(length: 100, space_char: ' ', progress_char: '#')
|
7
|
+
@length = length
|
8
|
+
@inner_length = @length - 2
|
9
|
+
raise ArgumentError if inner_length <= 0
|
10
|
+
raise ArgumentError if space_char.length != 1
|
11
|
+
raise ArgumentError if progress_char.length != 1
|
12
|
+
@space_char = space_char
|
13
|
+
@progress_char = progress_char
|
14
|
+
@progress = 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def update(progress)
|
18
|
+
raise unless (0.0..1.0).cover?(progress)
|
19
|
+
@progress = progress
|
20
|
+
to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
"[#{bar}#{space}]"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def space
|
30
|
+
#' ' * (inner_length - bar.length)
|
31
|
+
space_char * (inner_length * (1.0 - progress))
|
32
|
+
end
|
33
|
+
|
34
|
+
def bar
|
35
|
+
progress_char * (@progress*@inner_length).to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/torden.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Torden::Animation do
|
2
|
+
subject { described_class.new }
|
3
|
+
it 'play the default animation' do
|
4
|
+
expect(subject.to_s).to eq('-')
|
5
|
+
subject.update
|
6
|
+
expect(subject.to_s).to eq('\\')
|
7
|
+
subject.update
|
8
|
+
expect(subject.to_s).to eq('|')
|
9
|
+
subject.update
|
10
|
+
expect(subject.to_s).to eq('/')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe Torden::ProgressBar do
|
2
|
+
subject { described_class.new(length: 6) }
|
3
|
+
it 'play the default animation' do
|
4
|
+
expect(subject.to_s).to eq('[ ]')
|
5
|
+
subject.update(0.25)
|
6
|
+
expect(subject.to_s).to eq('[# ]')
|
7
|
+
subject.update(0.5)
|
8
|
+
expect(subject.to_s).to eq('[## ]')
|
9
|
+
subject.update(0.75)
|
10
|
+
expect(subject.to_s).to eq('[### ]')
|
11
|
+
subject.update(1.0)
|
12
|
+
expect(subject.to_s).to eq('[####]')
|
13
|
+
end
|
14
|
+
end
|
data/torden.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'torden/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "torden"
|
8
|
+
spec.version = Torden::VERSION
|
9
|
+
spec.authors = ["ragmaanir"]
|
10
|
+
spec.email = ["ragmaanir@gmail.com"]
|
11
|
+
spec.summary = %q{Some helper classes for command line interfaces}
|
12
|
+
#spec.description = %q{TODO: Write a longer description. Optional.}
|
13
|
+
spec.homepage = "http://ragmaanir.mypresident.de"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", '~> 10'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: torden
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ragmaanir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- ragmaanir@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".autotest"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".ruby-version"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- Rakefile.backup
|
57
|
+
- lib/torden.rb
|
58
|
+
- lib/torden/animation.rb
|
59
|
+
- lib/torden/progress_bar.rb
|
60
|
+
- lib/torden/version.rb
|
61
|
+
- spec/spec_helper.rb
|
62
|
+
- spec/unit/animation_spec.rb
|
63
|
+
- spec/unit/progress_bar_spec.rb
|
64
|
+
- torden.gemspec
|
65
|
+
homepage: http://ragmaanir.mypresident.de
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.3.0
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Some helper classes for command line interfaces
|
89
|
+
test_files:
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/unit/animation_spec.rb
|
92
|
+
- spec/unit/progress_bar_spec.rb
|
93
|
+
has_rdoc:
|