rbtclk 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.rb +24 -0
- data/lib/rbtclk.rb +32 -5
- data/lib/rbtclk/version.rb +1 -1
- data/spec/rbtclk_spec.rb +35 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17fc4da29cb43bc63ccbf700de720b9996ec3f01
|
4
|
+
data.tar.gz: c5032087f6b07e91ca96feb74f0a7dd72589ae53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ac089abae20f02e34767571df0cae822c6e40ac0316b5f9578e335abc494f0fc5021d3838600833b2b100df9df77474bd901abf63ea34c3b1306a184756225
|
7
|
+
data.tar.gz: 6d317ba43f872d80fbf61d1742e1404b2e04d26a11ab37fecd2b04c43904b5b203bef70ad0674f3abb640f66022a5c1e00cff99907c59c8068a362bf20ecfac6
|
data/config/default.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# rbtclk sample configuration file
|
2
|
+
# Copyright (c) 2014 Moza USANE
|
3
|
+
# This software is released under the MIT License.
|
4
|
+
# http://opensource.org/licenses/mit-license.php
|
5
|
+
|
6
|
+
Rbtclk.configure do |c|
|
7
|
+
# clock, countup and countdown are available.
|
8
|
+
c.mode = "timer"
|
9
|
+
|
10
|
+
# Font setting depends on Artii library.
|
11
|
+
# https://github.com/miketierney/artii/tree/master/lib/figlet/fonts
|
12
|
+
# You can use a lot of font types.
|
13
|
+
c.font = "clb8x8"
|
14
|
+
|
15
|
+
# You can use Ruby's Date#strftime style.
|
16
|
+
# It is compatible with strftime(3) of standard C library.
|
17
|
+
c.format = "%X"
|
18
|
+
|
19
|
+
# black, red, green, yellow, blue, magenta, cyan and white are available.
|
20
|
+
c.color = "black"
|
21
|
+
|
22
|
+
# You can specify limit time as seconds in countdown timer.
|
23
|
+
c.time = "180"
|
24
|
+
end
|
data/lib/rbtclk.rb
CHANGED
@@ -56,15 +56,42 @@ module Rbtclk
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def fill(params)
|
59
|
-
{mode: params[:mode] ||
|
60
|
-
font: params[:font] ||
|
61
|
-
format: params[:format] ||
|
62
|
-
color: params[:color] ||
|
63
|
-
time: params[:time] ||
|
59
|
+
{mode: params[:mode] || MODE,
|
60
|
+
font: params[:font] || FONT,
|
61
|
+
format: params[:format] || FORMAT,
|
62
|
+
color: params[:color] || COLOR,
|
63
|
+
time: params[:time] || TIME}
|
64
64
|
end
|
65
65
|
|
66
66
|
def remove_extra_params(params)
|
67
67
|
params.delete(:mode)
|
68
|
+
|
69
|
+
if params[:mode] != "countdown"
|
70
|
+
params.delete(:time)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def load_config
|
75
|
+
dot_rbtclk_in_home = File.expand_path(".rbtclk", "~")
|
76
|
+
|
77
|
+
if File.exist?(dot_rbtclk_in_home)
|
78
|
+
load dot_rbtclk_in_home
|
79
|
+
else
|
80
|
+
load File.expand_path("../../config/default.rb", __FILE__)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Methods for configuration DSL
|
85
|
+
def configure(&block)
|
86
|
+
Rbtclk.instance_eval(&block)
|
87
|
+
end
|
88
|
+
|
89
|
+
%w(mode font format color time).each do |attr|
|
90
|
+
define_method "#{attr}=" do |value|
|
91
|
+
const_set attr.to_s.upcase, value
|
92
|
+
end
|
68
93
|
end
|
69
94
|
end
|
95
|
+
|
96
|
+
load_config
|
70
97
|
end
|
data/lib/rbtclk/version.rb
CHANGED
data/spec/rbtclk_spec.rb
CHANGED
@@ -31,6 +31,14 @@ RSpec.describe Rbtclk do
|
|
31
31
|
time: "180"}
|
32
32
|
end
|
33
33
|
|
34
|
+
before do
|
35
|
+
filled_params.each do |attribute, value|
|
36
|
+
const_name = attribute.to_s.upcase
|
37
|
+
Rbtclk.send(:remove_const, const_name)
|
38
|
+
Rbtclk.const_set(const_name, value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
describe "#fill" do
|
35
43
|
context "there are no blank elements in the argument" do
|
36
44
|
subject { Rbtclk.fill(filled_params) }
|
@@ -50,15 +58,34 @@ RSpec.describe Rbtclk do
|
|
50
58
|
end
|
51
59
|
|
52
60
|
describe "#remove_extra_params" do
|
53
|
-
let(:params_that_has_no_mode) do
|
54
|
-
filled_params.delete(:mode)
|
55
|
-
filled_params
|
56
|
-
end
|
57
|
-
|
58
61
|
context "params contains :mode value" do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
let(:params_that_has_no_mode) do
|
63
|
+
filled_params.delete(:mode)
|
64
|
+
filled_params
|
65
|
+
end
|
66
|
+
|
67
|
+
let(:params_that_has_no_mode_and_no_time) do
|
68
|
+
params_that_has_no_mode.delete(:time)
|
69
|
+
params_that_has_no_mode
|
70
|
+
end
|
71
|
+
|
72
|
+
context "mode is clock" do
|
73
|
+
specify ":mode and :time values are removed" do
|
74
|
+
Rbtclk.remove_extra_params(filled_params)
|
75
|
+
expect(filled_params).to eq params_that_has_no_mode_and_no_time
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "mode is countdown" do
|
80
|
+
let(:filled_params_whose_mode_is_clock) do
|
81
|
+
filled_params[:mode] = "countdown"
|
82
|
+
filled_params
|
83
|
+
end
|
84
|
+
|
85
|
+
specify ":mode and :time values are removed" do
|
86
|
+
Rbtclk.remove_extra_params(filled_params)
|
87
|
+
expect(filled_params_whose_mode_is_clock).to eq params_that_has_no_mode
|
88
|
+
end
|
62
89
|
end
|
63
90
|
end
|
64
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtclk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moza USANE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
126
|
- bin/rbtclk
|
127
|
+
- config/default.rb
|
127
128
|
- lib/rbtclk.rb
|
128
129
|
- lib/rbtclk/clock.rb
|
129
130
|
- lib/rbtclk/color_code.rb
|