lita-random 0.1.0 → 0.2.0

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: c33b10fc27b89bc2ba196711f6cc2f98667a8ca3
4
- data.tar.gz: 6c4b832b944f8dcb7c6e9745a7bdf09909c4157a
3
+ metadata.gz: c7da685634182f7dcea15158492c42484e4b2aba
4
+ data.tar.gz: 363e54b12f8e064947f9010dc0c3bb49949995e2
5
5
  SHA512:
6
- metadata.gz: 9e77ac2236e918063a8bcdb67dda1d810abdac540625964fe164a54fe3d71624354435afc3878d1245023a4e839529bd5bb165547563a034308d1a229aa3322b
7
- data.tar.gz: e7ecb042f941d79fa51357b62f6330422e38765a0ae7a84589161cef85718785254520f6107826411569856937601aa4458c32524e3d07a56e40b1a2fde08ee2
6
+ metadata.gz: a42e4ecfa0cc4b0c27d5c929e6b1e5deedccffd4e3256122481735c623f2207c52cb29c2a025b30e78127df7b485bb55ed381367a699435f31b0eeecbe1fc6b8
7
+ data.tar.gz: 3808d4315a5c0ab10561b1f3d0a5b3c5840ae90b2680cee172b793cf9df3614c6b3e8ec056bf918167c7bdcb26f0420b835ff8429c05a30d71e66914f2f74aea
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.2.0](https://github.com/braiden-vasco/lita-random/tree/v0.2.0) (2015-06-21)
4
+
5
+ [Full Changelog](https://github.com/braiden-vasco/lita-random/compare/v0.1.0...v0.2.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Allow float ranges [\#17](https://github.com/braiden-vasco/lita-random/pull/17) ([braiden-vasco](https://github.com/braiden-vasco))
10
+
11
+ - Basic testing [\#15](https://github.com/braiden-vasco/lita-random/pull/15) ([braiden-vasco](https://github.com/braiden-vasco))
12
+
3
13
  ## [v0.1.0](https://github.com/braiden-vasco/lita-random/tree/v0.1.0) (2015-06-20)
4
14
 
5
15
  **Merged pull requests:**
data/README.md CHANGED
@@ -17,7 +17,7 @@ At first, see the documentation for Lita: https://docs.lita.io/
17
17
  Add **lita-random** to your Lita instance's Gemfile:
18
18
 
19
19
  ```ruby
20
- gem 'lita-random', '~> 0.1.0'
20
+ gem 'lita-random', '~> 0.2.0'
21
21
  ```
22
22
 
23
23
  ### Commands
@@ -44,8 +44,12 @@ You: lita random 5
44
44
  Lita: 2
45
45
  You: lita rand 100
46
46
  Lita: 24
47
+ You: lita random 1.5
48
+ Lita: 1.1828046952104034
47
49
  You: lita random 5 10
48
50
  Lita: 8
49
51
  You: lita rand 1000 2000
50
52
  Lita: 1240
53
+ You: lita random 12 13.5
54
+ Lita: 13.458799783677263
51
55
  ```
@@ -10,20 +10,41 @@ module Lita
10
10
  # Generator of random numbers and strings for the Lita chat bot.
11
11
  #
12
12
  class Random < Handler
13
- route(/^rand(om)?$/i, command: true) do |response|
13
+ route(/^rand(om)?$/i, :route_random, command: true)
14
+ def route_random(response)
14
15
  response.reply(::Random.rand.to_s)
15
16
  end
16
17
 
17
- route(/^rand(om)?\s+(\d+)?$/i, command: true) do |response|
18
+ route(/^rand(om)?\s+(\d+)?$/i, :route_random_to, command: true)
19
+ def route_random_to(response)
18
20
  to = response.matches[0][1].to_i
19
21
  response.reply(::Random.rand(to).to_s)
20
22
  end
21
23
 
22
- route(/^rand(om)?\s+(\d+)\s+(\d+)?$/i, command: true) do |response|
24
+ route(/^rand(om)?\s+(\d+\.\d+)?$/i, :route_random_float_to, command: true)
25
+ def route_random_float_to(response)
26
+ to = response.matches[0][1].to_f
27
+ response.reply(::Random.rand(to).to_s)
28
+ end
29
+
30
+ route(/^rand(om)?\s+(\d+)\s+(\d+)?$/i,
31
+ :route_random_from_to, command: true)
32
+ def route_random_from_to(response)
23
33
  from = response.matches[0][1].to_i
24
34
  to = response.matches[0][2].to_i
25
35
  response.reply(::Random.rand(from...to).to_s)
26
36
  end
37
+
38
+ route(/^rand(om)?\s+(\d+\.\d+)\s+(\d+)?$/i,
39
+ :route_random_float_from_to, command: true)
40
+ route(/^rand(om)?\s+(\d+(\.\d+)?)\s+(\d+\.\d+)?$/i,
41
+ :route_random_float_from_to, command: true)
42
+ def route_random_float_from_to(response)
43
+ matches = response.matches[0][0..1] + [response.matches[0][-1]]
44
+ from = matches[1].to_f
45
+ to = matches[2].to_f
46
+ response.reply(::Random.rand(from...to).to_s)
47
+ end
27
48
  end
28
49
 
29
50
  Lita.register_handler(Random)
data/lita-random.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'lita-random'
5
- spec.version = '0.1.0'
5
+ spec.version = '0.2.0'
6
6
  spec.authors = ['Braiden Vasco']
7
7
  spec.email = ['braiden-vasco@mailtor.net']
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-random
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braiden Vasco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-20 00:00:00.000000000 Z
11
+ date: 2015-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler