sometimes 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de2d58e8adfec5dfccd82cf65b2e0159910016fc
4
+ data.tar.gz: 17988ad64d9a21b2704313088cee824163ec7b61
5
+ SHA512:
6
+ metadata.gz: 531543b6687268ccf89ce8275e9945a0e2eadf21ea2f99b58940b246a889c69f6a08cd1c3ce9763eed542ec5eb855970f4b09b8e9ab7f7fac23e15166781dd6c
7
+ data.tar.gz: 3953b76e389ff785fd5439a341c1706de259200da77e7b4160320e84d1591c034125601e86daf04c20e63c9ce44ec1d0af30d07849b7eb2b688360e37e37c1d9
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Sudara
1
+ Copyright (c) 2013-2017 Sudara
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,62 +1,91 @@
1
1
  # Sometimes
2
2
 
3
+ [![Build Status](https://travis-ci.org/rubytune/sometimes.svg?branch=master)](https://travis-ci.org/rubytune/sometimes)
4
+
5
+
3
6
  Stop being so black and white. Mix things up a bit and execute code *sometimes*.
4
7
 
5
8
  A (very) simple collection of lil' helpers polluting namespaces because...why the hell not?
6
9
 
7
- ## Installation
10
+ ## Versions
8
11
 
9
- Works with only ruby 1.9.2 and up for now because I'm lazy and like the Random class.
12
+ Works with ruby 2.2 and up as of version 0.0.3.
13
+
14
+ Use version 0.0.2 if you want to support earlier rubies.
15
+
16
+ ## Installation
10
17
 
11
18
  Add this line to your Gemfile:
12
19
 
13
- gem 'sometimes'
20
+ ```ruby
21
+ gem 'sometimes'
22
+ ```
14
23
 
15
24
  And then execute:
16
25
 
17
- $ bundle
26
+ ```console
27
+ $ bundle
28
+ ```
18
29
 
19
30
  Require when needed
20
31
 
21
- require 'sometimes'
32
+ ```ruby
33
+ require 'sometimes'
34
+ ```
22
35
 
23
36
  ## Usage
24
37
 
25
38
  Say something every other time
26
39
 
27
- sometimes do
28
- puts "Hey, you are awesome. You really are." # executes warm fuzzies 50% of the time
29
- end
40
+ ```ruby
41
+ sometimes do
42
+ puts "Hey, you are awesome. You really are." # executes warm fuzzies 50% of the time
43
+ end
44
+ ```
30
45
 
31
46
  Maybe you want to do something several times, but not always the exact same number of times
32
47
 
33
- (4..10).times do
34
- pick_nose # between 4 and 10 boogers made, it's unpredictable!
35
- end
36
-
48
+ ```ruby
49
+ (4..10).times do
50
+ pick_nose # between 4 and 10 boogers made, it's unpredictable!
51
+ end
52
+ ```
37
53
 
38
54
  Maybe you want to remind someone of something, but not toooo often (It gets annoying!)
39
55
 
40
- 15.percent_of_the_time do
41
- puts "Howdy, Don't forget to register!" # be annoying, but only 15% of the time
42
- end
43
-
44
- 33.percent_of_the time do
45
- be_very_polite
46
- end
56
+ ```ruby
57
+ 15.percent_of_the_time do
58
+ puts "Howdy, Don't forget to register!" # be annoying, but only 15% of the time
59
+ end
60
+
61
+ 33.percent_of_the time do
62
+ be_very_polite
63
+ end
64
+ ```
47
65
 
48
66
  Share a rare moment with your user
49
67
 
50
- rarely do
51
- puts "How would you like some spammy spam spam!" # be really annoying about 5% of the time
52
- end
53
-
54
- 1.percent_of_the_time do
55
- puts "Want to see something really cool?"
56
- end
68
+ ```ruby
69
+ rarely do
70
+ puts "How would you like some spammy spam spam!" # be really annoying about 5% of the time
71
+ end
72
+
73
+ 1.percent_of_the_time do
74
+ puts "Want to see something really cool?"
75
+ end
76
+ ```
57
77
 
58
78
  ## Why?
59
79
 
60
- This gem was made so [alonetone](http://github.com/sudara/alonetone) could bit more fun when displaying notices and communicating to our users.
80
+ This gem was made so [alonetone](http://github.com/sudara/alonetone) could bit more fun when displaying notices and communicating to our users.
81
+
82
+ We are human, and have personality. Shouldn't our applications reflect this? Be predictable where it counts. But toss in some spice here and there — it is always a good thing.
83
+
84
+ ## Updating and Releasing this gem
85
+
86
+ * Update lib/sometimes/version.rb
61
87
 
62
- We are human, and have personality. Shouldn't our applications reflect this? Be predictable where it counts. But toss in some spice here and there — it is always a good thing.
88
+ ```
89
+ bundle && bundle exec rake gemspec
90
+ bundle exec rake release
91
+ ```
@@ -1,10 +1,10 @@
1
1
  require "sometimes/version"
2
2
 
3
3
  # -*- encoding : utf-8 -*-
4
- # OH SO FUN HELPERS!
4
+ # OH SO FUN HELPERS!
5
5
 
6
6
  # RANDOMLY EXECUTES A BLOCK X percent OF THE TIME
7
- #
7
+ #
8
8
  # TEST WITH
9
9
  #
10
10
  # i = 0
@@ -17,9 +17,9 @@ require "sometimes/version"
17
17
  #
18
18
  #
19
19
  # 40.percent_of_the_time do
20
- class Fixnum
20
+ class Integer
21
21
  def percent_of_the_time(&block)
22
- raise(ArgumentError, 'Fixnum should be between 1 and 100 to be used with the times method') unless self > 0 && self <= 100
22
+ raise(ArgumentError, 'Integer should be between 1 and 100 to be used with the times method') unless self > 0 && self <= 100
23
23
  yield if (Kernel.rand(99)+1) <= self
24
24
  end
25
25
  end
@@ -38,7 +38,7 @@ class Object
38
38
  50.percent_of_the_time {yield}
39
39
  end
40
40
  alias :sometimes :half_the_time
41
-
41
+
42
42
  def rarely(&block)
43
43
  5.percent_of_the_time {yield}
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module Sometimes
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,55 @@
1
+ # ……………………………………………..__„„„„------„„¸._¸„
2
+ # ………………………………__„„---^^^^””¯. . . ƒ|. . „~”„”^--¸
3
+ # ………………………..„„---^^”””””””””””””””'-------ƒ-|--„-“„-”_. . .”~„
4
+ # ……………………..„•”. . . . . . . . . . . . .|---ƒ¸ƒ/¯¯. . . . . . . .“-„
5
+ # …………………..„-“. . . . . . . . . . . . . . .|/ƒ„”/|. . . . . . . . . . .”^”-„
6
+ # …………..__.„„•”. . . . . . . . . . . . . . . .ƒ„”ƒ|„”„”. . .„-^,^-^^-„¸. . . .\”-„¸
7
+ # ………^^^^^„~”-^^---„„„___. . . . . . . . . ./„”;;”;„-“. . .„~”¯. . . .”^„. . “.„.”„¸
8
+ # ….....„….„-“/. . . . . . ”^•„_"„. . . . . . . '|„”„;;„”. . „~”. . . . . |. . . “*-„. “-„.|
9
+ # ……..|.„~”. . . . . . . . . .”•„. . . . . . . . ”„¸.|ƒ. .„”. . . . . . . !„„¸__„-.“-„. “-„\
10
+ # ……¸„|/. . . . . . _„„-^^^^^^--„”-„. . . . . . .„|--“. ƒ. . . . . . . . . . . . . . .“|. . \”„
11
+ # ..¸..„”|. . . . . .„~”. . . . . . . .¯”„”^-„¸. . . . . . . |„¸. . . . . . . . . . . . . . .”i. . “„”-„
12
+ # ..'|.|.ƒ. . . . .'ƒ.----„. . . . . . . . .”^-.|. . . . . . . . “^„. . . . . . . . . . . . . . |. . .”„.”„
13
+ # ..'|..„”. . . . .‘|. . . „”. . . . . . . . . .„”. . . . ___. . . “^-„¸_. . . . . . . . . .„-“. . . “„.”^„
14
+ # ..'|.ƒ'. . . . . ”’|”””¯. . . . . . . . . .„*. . ¸„„-^”. . .”I””^^---„„¸””^^------------^*”. . . . . “„. \
15
+ # ..|.'|. . . . . . .'|. . . . . . . . . . „-“. . „--“¯”„_. . .’|--„¸_„-. .””^--„_. .„„„„. . . . . . . . “„.|
16
+ # ..|.’|. . . . . . ."•„. . . . . . . „~”. . „“|¸. . . .”|^--„„|. . . . . . . . . .¯”^--.”•„. . . . . . . |.|
17
+ # ..|.'|. . . . . . . . ."^---------^”. . . „|. -„”„_. . | . . . . . . . . . . . . . . . . . .”„. . . . . . \’|
18
+ # ..|.‘|. . . . . . . . . . . . . . . . . . ƒ. ._„|. “”””. . . . . . . . . . . . . . . . . . . “-„. . . . . ‘|
19
+ # ..|.’|. . . . . . . . . . . . . . . . . . /.”””. . . . . . . . . . . . . „-~--„. . . . . . . . .”^„. . . . |i
20
+ # ..”„.”|. . . . . . . . . . . . . . . . .ƒ. . . . . . . . . .„„„„„__„’”. . . . “^„. . „„„„„. . . |. . . . .|
21
+ # …|. |. . . . . . . . . . . . . . . . .|. . . . . . . . .„-“. . . . . . . . . „--~-„„||. . “^-„. |. . . . .|
22
+ # …”|. “„. . . . . . . . . . . . . . . ƒ. . . . . . . .„”. . . . . _„----„. /. . . .|. . . . . .„”. . . . ||.„
23
+ # ….|…”„. . . . . . . . . . . . . . /. . . . . . . .““. . . . . ƒ|. . . ”-“. ¸„----“------^^”. . . . . . |.|
24
+ # …..”-„. |. . . . . . . . . . . . . ƒ. . . . . . . . ¸„----„. . i”. . . . „„^”. . . . . . . . . . . . . . |-“
25
+ # ……..”„\. . . . . . . . . . . . i|. . . __. . .„„”. . . . “-„”. „--^”’. . . . . . . . . . . . . . . „-”„”
26
+ # ……….|”--„. . . . . . . . .„-”. . „~”. “•„. .|. . . . ._„-‘^”. . . . . . . . . . . . . . . . . .ƒ„-”
27
+ # ………..|. .“„. . . . . . . .”^--„’„„„„___.”’. ¸„„---^”. . . . . . . . . . . . . . . . . . . . . /„”
28
+ # ………..\”„. .“^-„„„_. . . . . . . . . . . .”””””. . . . . . . . . . . . . . . . . . . . . . . . ƒ
29
+ # …………”„\. . . .“••-„. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .„”
30
+
31
+ ffffu_text = <<DOC
32
+ ________________________ _ _ _ _ _ _ _ _ _ _ _ _ _ _
33
+ | ___| ___| ___| ___| | | | | | | | | | | | | | | | | | | | | |
34
+ | |_ | |_ | |_ | |_ | | | | | | | | | | | | | | | | | | | | | |
35
+ | _| | _| | _| | _| | | | | | | | | | | | | | | | | | | | | | |
36
+ | | | | | | | | | |_| | |_| | |_| | |_| | |_| | |_| | |_| | _ _ _
37
+ \\_| \\_| \\_| \\_| \\___/ \\___/ \\___/ \\___/ \\___/ \\___/ \\___/ (_|_|_)
38
+
39
+ JUST KIDDING!!!
40
+ DOC
41
+
42
+ sometimes do
43
+ puts ""
44
+ puts "Run options:"
45
+ puts ""
46
+ puts "Running tests:"
47
+ puts ""
48
+ 10.times { putc "." ; sleep 0.15 }
49
+ %w". E E . E E E . ".each {|c| putc c ; sleep 0.25}
50
+ %w" F F . F F F F F F U U U U U U U U U U U U . ".each {|c| putc c ; sleep 0.1}
51
+ puts ""
52
+ puts ffffu_text
53
+ puts ""
54
+ sleep 2
55
+ end
@@ -1,11 +1,12 @@
1
1
  require 'test/unit'
2
2
  require 'sometimes'
3
+ require 'helper'
3
4
 
4
5
  class SometimesTest < Test::Unit::TestCase
5
6
  def test_ranges
6
7
  i = 0
7
8
  (25..50).times { i += 1 }
8
- assert i > 24
9
+ assert i > 24
9
10
  assert i < 51
10
11
  end
11
12
 
@@ -29,7 +30,7 @@ class SometimesTest < Test::Unit::TestCase
29
30
  end
30
31
  assert i < 8000
31
32
  end
32
-
33
+
33
34
  def test_99
34
35
  i = 0
35
36
  100000.times do
@@ -39,7 +40,7 @@ class SometimesTest < Test::Unit::TestCase
39
40
  end
40
41
  assert i > 97000
41
42
  end
42
-
43
+
43
44
  def test_1
44
45
  i = 0
45
46
  100000.times do
@@ -47,7 +48,7 @@ class SometimesTest < Test::Unit::TestCase
47
48
  i += 1
48
49
  end
49
50
  end
50
- assert i < 1000
51
+ assert i < 1100
51
52
  end
52
-
53
+
53
54
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sometimes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sudara
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Be random. Be unpredictable. But only sometimes
15
14
  email:
@@ -18,7 +17,7 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - .gitignore
20
+ - ".gitignore"
22
21
  - Gemfile
23
22
  - LICENSE.txt
24
23
  - README.md
@@ -26,30 +25,31 @@ files:
26
25
  - lib/sometimes.rb
27
26
  - lib/sometimes/version.rb
28
27
  - sometimes.gemspec
28
+ - test/helper.rb
29
29
  - test/test_sometimes.rb
30
30
  homepage: ''
31
31
  licenses: []
32
+ metadata: {}
32
33
  post_install_message:
33
34
  rdoc_options: []
34
35
  require_paths:
35
36
  - lib
36
37
  required_ruby_version: !ruby/object:Gem::Requirement
37
- none: false
38
38
  requirements:
39
- - - ! '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
- none: false
44
43
  requirements:
45
- - - ! '>='
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  requirements: []
49
48
  rubyforge_project:
50
- rubygems_version: 1.8.23
49
+ rubygems_version: 2.6.11
51
50
  signing_key:
52
- specification_version: 3
51
+ specification_version: 4
53
52
  summary: Be random. Be unpredictable. But only sometimes
54
53
  test_files:
54
+ - test/helper.rb
55
55
  - test/test_sometimes.rb