danno_ball_clock 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 490bcfa18da3ea07e32bfb3907bf213898e707e6
4
- data.tar.gz: 9c8e42b0f737d9b33d24bb2a8d10fd7a92ef0159
3
+ metadata.gz: b85435c789cde6ab20f43e5b2bc2a5be4b7c6bd7
4
+ data.tar.gz: 4821fd02b596d49bdde40d045336379bc518ac68
5
5
  SHA512:
6
- metadata.gz: ec8e7476e9e2abb05d486e62de25d5f8138af99fafea5c7bac5bf9bc8cfd2cac9a1f4f9a2ed9fe46ea8b6f94081a09f3c7a4d7e6ab4e91b003916f080e883fcb
7
- data.tar.gz: 5faf2433c90b3906c59be94b1547eab1d4a11a9b1a1d5bdc55f5808487747491c92c2bbb8ab9da5579eb1dcb08fba5f40b8a1dedc228226342e87f11126da6da
6
+ metadata.gz: 447aa427c232fa11b0d5ba80509f58bb60a6499b5e8f278f63fd274b097b93f0f4254731c88d05bbb111c567f31e3f1ae92bb529511eb442a80bda2ca2f5f932
7
+ data.tar.gz: 312f886e21cdb6b28ea7eed1c8781a52db5a6cc7e52a9883d8aa814a567cd93636be3005c6097e61c5ed413c260ce05e5387edac6ccb7235b89dc1dd8eac9d0d
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ cache: bundler
2
+
3
+ language: ruby
4
+
5
+ rvm:
6
+ - 2.2.3
7
+ - 2.2.0
8
+ install:
9
+ - "travis_retry bin/setup"
10
+
11
+ script:
12
+ - "bundle exec rake"
13
+
14
+ branches:
15
+ only:
16
+ - master
17
+
18
+ sudo: false
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danno_ball_clock (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.9.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ danno_ball_clock!
16
+ minitest
17
+
18
+ BUNDLED WITH
19
+ 1.10.6
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  | _ \ / _ \ | \ / \ | | | | / 12 \
3
3
  | | | | | | | | | [] / / ^ \ | | | | | ^ |
4
4
  | |_| | | |_| | | [] \ / /\ \ | |__ | |__ |9 |-> 3|
5
- |____/[] \ ___ /[] |____/ /__ / \ __\ |_____| |_____| \___6__/
5
+ |____/[] \ ___ /[] |____/ /__ / \ __\ |_____| |_____| \___6__/
6
6
 
7
7
  Movement has long been used to measure time. For example, the ball clock is a simple device which keeps track of the passing minutes by moving ball-bearings. Each minute, a rotating arm removes a ball bearing from the queue at the bottom, raises it to the top of the clock and deposits it on a track leading to indicators displaying minutes, five-minutes and hours. These indicators display the time between 1:00 and 12:59, but without 'a.m.' or 'p.m.' indicators. Thus 2 balls in the minute indicator, 6 balls in the five-minute indicator and 5 balls in the hour indicator displays the time 5:32.
8
8
 
@@ -11,7 +11,7 @@ Movement has long been used to measure time. For example, the ball clock is a si
11
11
  | \_/ | / \ / __| / \ \\ || \\//
12
12
  | | / _ \ | |__ | [ ] | \\ //\\
13
13
  |_/\_/\_| /_/ \_\ \____| \___/ ||_\\ // \\
14
-
14
+
15
15
  * Ruby -v 2.2.0+ # Use Rvm where possible `rvm install version_number`
16
16
  * Install the clock `gem install danno_ball_clock` or clone it from this repo.
17
17
 
@@ -34,6 +34,9 @@ The Clock takes two parameters, the number of balls and the number of minutes to
34
34
  # Using the Gem!
35
35
 
36
36
  * `ruby -Ilib ./bin/clock {27,0}` or `ruby -Ilib ./bin/clock {30,325}` # if cloned
37
- * `ruby -Ilib ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock-0.0.0/bin/clock {33,90}` # if installed via `gem install`
37
+ * `ruby -Ilib ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock-0.0.3/bin/clock {33,90}` # if installed via `gem install`
38
38
 
39
+ # Testing the Gem!
39
40
 
41
+ * `rake` # if cloned
42
+ * `cd ~/.rvm/gems/ruby-2.2.3/gems/danno_ball_clock_0.0.3` then `rake` # if installed via `gem install`
data/lib/clock.rb CHANGED
@@ -8,7 +8,8 @@ require 'json'
8
8
  ###
9
9
  class Clock
10
10
  ###
11
- # @method add_minute adds a ball from the begining of the main
11
+ # @method add_minute
12
+ # adds a ball from the begining of the main
12
13
  # queue to the minute track. Once the minute track is full
13
14
  # the ball will drop to the five minute track triggering in
14
15
  # reverse order the minute track to deposit to the main queue.
@@ -50,7 +51,7 @@ class Clock
50
51
  ###
51
52
  # @param [Fixnum, Fixnum] runs clock with number of balls to start with and optionally a runtime.
52
53
  # @return [Json] json hash for min, five_min, hour and main queues. If no runtime
53
- # is provided it will calculate the days tell the que repeats.
54
+ # is provided it will calculate the days tell the que repeats.
54
55
  ###
55
56
  def self.run_ball_clock(balls, run_time)
56
57
  @current_que = []
@@ -70,14 +71,13 @@ class Clock
70
71
  until @repeat == true
71
72
  add_minute
72
73
  end
73
- result = puts "Clock cycles in: #{@cycle_days} day\(s\)\."
74
+ "Clock cycles in: #{@cycle_days} day\(s\)\."
74
75
  else
75
76
  until min_left == 0
76
77
  add_minute
77
78
  min_left -= 1
78
79
  end
79
- json_clock = { min: @min_track, fiveMin: @five_min_track, hour: @hour_track, main: @current_que }
80
+ JSON.generate(min: @min_track, fiveMin: @five_min_track, hour: @hour_track, main: @current_que)
80
81
  end
81
- JSON.generate(json_clock)
82
82
  end
83
83
  end
@@ -0,0 +1,13 @@
1
+ require 'minitest/autorun'
2
+ require 'clock'
3
+
4
+ class ClockTest < Minitest::Test
5
+ def test_run_time
6
+ assert_equal "{\"min\":[],\"fiveMin\":[22,13,25,3,7],\"hour\":[6,12,17,4,15],\"main\":[11,5,26,18,2,30,19,8,24,10,29,20,16,21,28,1,23,14,27,9]}",
7
+ Clock.run_ball_clock(30,325)
8
+ end
9
+ def test_cycle_days
10
+ assert_equal "Clock cycles in: 2415 day(s).",
11
+ Clock.run_ball_clock(127,0)
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danno_ball_clock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danial Oberg
@@ -18,9 +18,13 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".travis.yml"
22
+ - Gemfile
23
+ - Gemfile.lock
21
24
  - README.md
22
25
  - bin/clock
23
26
  - lib/clock.rb
27
+ - test/test_clock.rb
24
28
  homepage: http://rubygems.org/gems/danno_ball_clock
25
29
  licenses:
26
30
  - MIT