ackintosh-tiny_progressbar 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/ackintosh-tiny_progressbar.gemspec +17 -0
- data/lib/ackintosh-tiny_progressbar.rb +35 -0
- data/lib/ackintosh-tiny_progressbar/version.rb +5 -0
- data/test/test_ackintosh-tiny_progressbar.rb +28 -0
- metadata +55 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Akihito Nakano
|
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,34 @@
|
|
1
|
+
# Ackintosh::TinyProgressbar
|
2
|
+
|
3
|
+
My simple gem
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ackintosh-tiny_progressbar'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ackintosh-tiny_progressbar
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
atp = Ackintosh::TinyProgressbar.new(100)
|
22
|
+
100.times do
|
23
|
+
atp.scceed
|
24
|
+
sleep 0.1
|
25
|
+
end
|
26
|
+
atp.clear
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/ackintosh-tiny_progressbar/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Akihito Nakano"]
|
6
|
+
gem.email = ["sora.akatsuki@gmail.com"]
|
7
|
+
gem.description = %q{my first gem}
|
8
|
+
gem.summary = %q{my first gem}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "ackintosh-tiny_progressbar"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Ackintosh::TinyProgressbar::VERSION
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "ackintosh-tiny_progressbar/version"
|
2
|
+
|
3
|
+
module Ackintosh
|
4
|
+
class TinyProgressbar
|
5
|
+
# Your code goes here...
|
6
|
+
CR = "\r"
|
7
|
+
FORMAT = "[%-30s] (%03d/%03d done)"
|
8
|
+
|
9
|
+
def initialize(goal)
|
10
|
+
@goal = goal
|
11
|
+
@now = 0
|
12
|
+
display
|
13
|
+
end
|
14
|
+
attr_reader :goal, :now
|
15
|
+
|
16
|
+
def succeed
|
17
|
+
@now += 1
|
18
|
+
back_cursor
|
19
|
+
display
|
20
|
+
end
|
21
|
+
|
22
|
+
def clear
|
23
|
+
print CR + " " * 100 + CR
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def back_cursor
|
28
|
+
print CR
|
29
|
+
end
|
30
|
+
|
31
|
+
def display
|
32
|
+
print FORMAT % [("=" * (30 * @now / @goal)), @now, @goal]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'ackintosh-tiny_progressbar'
|
3
|
+
MiniTest::Unit.autorun
|
4
|
+
|
5
|
+
class TestAckintoshTinyProgressbar < MiniTest::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
# このテストには不要なので標準出力を抑える
|
8
|
+
$stdout, @orig_stdout = open('/dev/null', 'w'), $stdout
|
9
|
+
@progressbar = Ackintosh::TinyProgressbar.new 100
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
$stdout = @orig_stdout
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_goal_set_100
|
17
|
+
assert_equal @progressbar.goal, 100
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_now_set_0_on_init
|
21
|
+
assert_equal @progressbar.now, 0
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_now_succeeds
|
25
|
+
@progressbar.succeed
|
26
|
+
assert_equal @progressbar.now, 1
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ackintosh-tiny_progressbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Akihito Nakano
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: my first gem
|
15
|
+
email:
|
16
|
+
- sora.akatsuki@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- ackintosh-tiny_progressbar.gemspec
|
27
|
+
- lib/ackintosh-tiny_progressbar.rb
|
28
|
+
- lib/ackintosh-tiny_progressbar/version.rb
|
29
|
+
- test/test_ackintosh-tiny_progressbar.rb
|
30
|
+
homepage: ''
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.8.23
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: my first gem
|
54
|
+
test_files:
|
55
|
+
- test/test_ackintosh-tiny_progressbar.rb
|