rbtclk 0.3.3 → 0.3.4

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: c6661922698b33c02330b03905086dc86a0ce5d2
4
- data.tar.gz: 650d0735a0989ee71069ccbd3b7b1ca98fb58bf8
3
+ metadata.gz: a0fc07db46af23f24380a963fa37722a3ff6bb7a
4
+ data.tar.gz: eebf1b0c316d18cdd75d26feae2043491858178e
5
5
  SHA512:
6
- metadata.gz: 7b509b6c7ccc437f2e2cc521e03c534b98d13230ed8697bca696f958ea2e7f4c36c4b942c3385287ad7bc56445cf9113ba7711a46c8dbe2e0131d9d0f739ef20
7
- data.tar.gz: 7a6a4ea38332996fcd790f88a305645c7c6d76dd82c9166bd122f4bc6a86139aefd5a73d1342c28d75689f1b607f091d39c00268edbf0e0641f6843e98303e65
6
+ metadata.gz: bba36b861bb79b97bb5e022e7b4401c191a9bb63a7af1f8037e2be552aa143141f7c93c93ad6e8cc6c41aff224298aa17c94bd24db67f09dbfb9d3fbf13ae6e9
7
+ data.tar.gz: a4eccd625012d44a89b8f6f0f94dd0d6c515338cced9da1e1ca6e5904217f6ea20190fd1363bdda4b0b059689fc2746fb7630c08e42ab8b99e1ba601ea30f434
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --color
data/README.md CHANGED
@@ -165,7 +165,7 @@ $ rbtclk --color magenta
165
165
 
166
166
  ## Configuration by .rbtclk file
167
167
 
168
- The default bhavior can be changed by `~/.rbtclk` file.
168
+ The default behavior can be changed by `~/.rbtclk` file.
169
169
  Sample config file is in `RBTCLK_ROOT/config/default.rb`.
170
170
 
171
171
  ```ruby
@@ -0,0 +1,31 @@
1
+ # Rbtclk
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
+ require "rbtclk"
7
+
8
+ module Rbtclk
9
+ module ConfigLoader
10
+ def load_config
11
+ dot_rbtclk_in_home = File.expand_path(".rbtclk", "~")
12
+
13
+ if File.exist?(dot_rbtclk_in_home)
14
+ load dot_rbtclk_in_home
15
+ else
16
+ load File.expand_path("../../../config/default.rb", __FILE__)
17
+ end
18
+ end
19
+
20
+ # Methods for configuration DSL
21
+ def configure(&block)
22
+ self.instance_eval(&block)
23
+ end
24
+
25
+ %w(mode font format color time).each do |attr|
26
+ define_method "#{attr}=" do |value|
27
+ const_set attr.to_s.upcase, value
28
+ end
29
+ end
30
+ end
31
+ end
@@ -4,5 +4,5 @@
4
4
  # http://opensource.org/licenses/mit-license.php
5
5
 
6
6
  module Rbtclk
7
- VERSION = "0.3.3"
7
+ VERSION = "0.3.4"
8
8
  end
data/lib/rbtclk.rb CHANGED
@@ -5,11 +5,14 @@
5
5
 
6
6
  require "optparse"
7
7
  require "rbtclk/version"
8
+ require "rbtclk/config_loader"
8
9
  require "rbtclk/clock"
9
10
  require "rbtclk/countup_timer"
10
11
  require "rbtclk/countdown_timer"
11
12
 
12
13
  module Rbtclk
14
+ extend ConfigLoader
15
+
13
16
  class << self
14
17
  def run(args)
15
18
  params = {}
@@ -70,27 +73,6 @@ module Rbtclk
70
73
  params.delete(:time)
71
74
  end
72
75
  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
93
- end
94
76
  end
95
77
 
96
78
  load_config
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Rbtclk::ConfigLoader do
4
+ let(:target_klass) do
5
+ class Dummy
6
+ constants.each do |c|
7
+ remove_const c
8
+ end
9
+ end
10
+
11
+ Dummy.extend Rbtclk::ConfigLoader
12
+ end
13
+
14
+ describe ".configure" do
15
+ before do
16
+ target_klass.configure do |c|
17
+ c.mode = "Alice"
18
+ c.font = "white-rabbit"
19
+ c.format = "cheshire-cat"
20
+ c.color = "queen-of-hearts"
21
+ c.time = "march-hare"
22
+ end
23
+ end
24
+
25
+ it { expect(target_klass::MODE).to eq "Alice" }
26
+ it { expect(target_klass::FONT).to eq "white-rabbit" }
27
+ it { expect(target_klass::FORMAT).to eq "cheshire-cat" }
28
+ it { expect(target_klass::COLOR).to eq "queen-of-hearts" }
29
+ it { expect(target_klass::TIME).to eq "march-hare" }
30
+ end
31
+
32
+ describe ".mode" do
33
+ before { target_klass.mode = "Alice" }
34
+ it { expect(target_klass::MODE).to eq "Alice" }
35
+ end
36
+
37
+ describe ".font" do
38
+ before { target_klass.font = "white-rabbit" }
39
+ it { expect(target_klass::FONT).to eq "white-rabbit" }
40
+ end
41
+
42
+ describe ".format" do
43
+ before { target_klass.format = "cheshire-cat" }
44
+ it { expect(target_klass::FORMAT).to eq "cheshire-cat" }
45
+ end
46
+
47
+ describe ".color" do
48
+ before { target_klass.color = "queen-of-hearts" }
49
+ it { expect(target_klass::COLOR).to eq "queen-of-hearts" }
50
+ end
51
+
52
+ describe ".time" do
53
+ before { target_klass.time = "march-hare" }
54
+ it { expect(target_klass::TIME).to eq "march-hare" }
55
+ end
56
+ 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.3
4
+ version: 0.3.4
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-30 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,11 +128,13 @@ files:
128
128
  - lib/rbtclk.rb
129
129
  - lib/rbtclk/clock.rb
130
130
  - lib/rbtclk/color_code.rb
131
+ - lib/rbtclk/config_loader.rb
131
132
  - lib/rbtclk/countdown_timer.rb
132
133
  - lib/rbtclk/countup_timer.rb
133
134
  - lib/rbtclk/version.rb
134
135
  - rbtclk.gemspec
135
136
  - spec/rbtclk/color_code_spec.rb
137
+ - spec/rbtclk/config_loader_spec.rb
136
138
  - spec/rbtclk_spec.rb
137
139
  - spec/spec_helper.rb
138
140
  homepage: http://quellencode.org/
@@ -161,5 +163,6 @@ specification_version: 4
161
163
  summary: A light-weight timer application that can run in terminal emulators.
162
164
  test_files:
163
165
  - spec/rbtclk/color_code_spec.rb
166
+ - spec/rbtclk/config_loader_spec.rb
164
167
  - spec/rbtclk_spec.rb
165
168
  - spec/spec_helper.rb