lita-random 0.2.0 → 0.3.0

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: c7da685634182f7dcea15158492c42484e4b2aba
4
- data.tar.gz: 363e54b12f8e064947f9010dc0c3bb49949995e2
3
+ metadata.gz: e2a5d89363f50d714f1ec46581510a27b4abd3ed
4
+ data.tar.gz: d5d2e3ddbcfbc02874f6285ee97742add4402155
5
5
  SHA512:
6
- metadata.gz: a42e4ecfa0cc4b0c27d5c929e6b1e5deedccffd4e3256122481735c623f2207c52cb29c2a025b30e78127df7b485bb55ed381367a699435f31b0eeecbe1fc6b8
7
- data.tar.gz: 3808d4315a5c0ab10561b1f3d0a5b3c5840ae90b2680cee172b793cf9df3614c6b3e8ec056bf918167c7bdcb26f0420b835ff8429c05a30d71e66914f2f74aea
6
+ metadata.gz: 02a73422b0a2633e2160154e2cdc008a375dd34c95a858bfa2caf0d4787beceb87ebdef4ff87951affb766829bc0c0ad012cce379e92cba2c2d6f1a992ef895a
7
+ data.tar.gz: 0b50610e566e97a874eed7a1be21514a48b5037691030ca4afe59b41c9827a22d7d5921edcf24aeae6f7ef5a541747198c199483a2b360ee7aa3e291131fd448
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.3.0](https://github.com/braiden-vasco/lita-random/tree/v0.3.0) (2015-06-21)
4
+
5
+ [Full Changelog](https://github.com/braiden-vasco/lita-random/compare/v0.2.0...v0.3.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Add UUID generator [\#23](https://github.com/braiden-vasco/lita-random/pull/23) ([braiden-vasco](https://github.com/braiden-vasco))
10
+
11
+ - Allow spaces between commands, add more aliases [\#22](https://github.com/braiden-vasco/lita-random/pull/22) ([braiden-vasco](https://github.com/braiden-vasco))
12
+
13
+ - Add hexadecimal string generator [\#21](https://github.com/braiden-vasco/lita-random/pull/21) ([braiden-vasco](https://github.com/braiden-vasco))
14
+
15
+ - Add base64 generator [\#20](https://github.com/braiden-vasco/lita-random/pull/20) ([braiden-vasco](https://github.com/braiden-vasco))
16
+
17
+ - Refactor regular expressions [\#19](https://github.com/braiden-vasco/lita-random/pull/19) ([braiden-vasco](https://github.com/braiden-vasco))
18
+
3
19
  ## [v0.2.0](https://github.com/braiden-vasco/lita-random/tree/v0.2.0) (2015-06-21)
4
20
 
5
21
  [Full Changelog](https://github.com/braiden-vasco/lita-random/compare/v0.1.0...v0.2.0)
data/README.md CHANGED
@@ -17,21 +17,42 @@ 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.2.0'
20
+ gem 'lita-random', '~> 0.3.0'
21
21
  ```
22
22
 
23
23
  ### Commands
24
24
 
25
- - `random` -
25
+ The space between instructions can be skiiped, so you can write
26
+ `random hex` as `randomhex`, `rand b64` as `randb64`
27
+
28
+ Command `random` has alias `rand`
29
+
30
+ * `random` -
26
31
  random float number, greater or equal to 0 and lesser than 1
27
32
 
28
- - `random <to>` -
29
- random integer number, greater or equal to 0 and lesser than `to`
33
+ * `random <to>` -
34
+ random integer or float number, greater or equal to 0 and lesser than `to`
30
35
 
31
- - `random <from> <to>` -
32
- random integer number, greater or equal to `from` and lesser than `to`
36
+ * `random <from> <to>` -
37
+ random integer or float number, greater or equal to `from` and lesser than `to`
33
38
 
34
- Command `random` has alias `rand`
39
+ Command `base64` has alias `b64`
40
+
41
+ * `random base64 <n=16>` -
42
+ random base64 string, length of source string is `n`,
43
+ length of result is about `n * 4 / 3` (24 with default value of `n`)
44
+
45
+ Command `hex` has aliases `hx` and `x`
46
+
47
+ * `random hex <n=16>` -
48
+ random hexadecimal string with length `n * 2`
49
+
50
+ Command `uuid` has alias `uid`
51
+
52
+ * `random uuid`
53
+ v4 random UUID (Universally Unique IDentifier). The version 4 UUID
54
+ is purely random (except the version). It doesn’t contain
55
+ meaningful information such as MAC address, time, etc.
35
56
 
36
57
  ### Examples
37
58
 
@@ -40,10 +61,12 @@ You: lita random
40
61
  Lita: 0.52693215290866
41
62
  You: lita rand
42
63
  Lita: 0.8332672468501509
64
+
43
65
  You: lita random 5
44
66
  Lita: 2
45
67
  You: lita rand 100
46
68
  Lita: 24
69
+
47
70
  You: lita random 1.5
48
71
  Lita: 1.1828046952104034
49
72
  You: lita random 5 10
@@ -52,4 +75,17 @@ You: lita rand 1000 2000
52
75
  Lita: 1240
53
76
  You: lita random 12 13.5
54
77
  Lita: 13.458799783677263
78
+
79
+ You: lita random base64
80
+ Lite: 56wnZVVVStKG5+I6L4LVGw==
81
+ You: lita randb64 10
82
+ Lita: NMkIhB+iG2VNpg==
83
+
84
+ You: lita random hex
85
+ Lita: 7d6f39cf53303db862bac5e1b36eb0fa
86
+ You: lita randx 10
87
+ Lita: 0d8297837d6e63b8c25b
88
+
89
+ You: lita random uuid
90
+ Lita: f1281565-3c8a-475d-a1aa-565ff840a42c
55
91
  ```
@@ -35,16 +35,45 @@ module Lita
35
35
  response.reply(::Random.rand(from...to).to_s)
36
36
  end
37
37
 
38
- route(/^rand(om)?\s+(\d+\.\d+)\s+(\d+)?$/i,
38
+ route(/^rand(om)?\s+(?<from>\d+\.\d+)\s+(?<to>\d+)?$/i,
39
39
  :route_random_float_from_to, command: true)
40
- route(/^rand(om)?\s+(\d+(\.\d+)?)\s+(\d+\.\d+)?$/i,
40
+ route(/^rand(om)?\s+(?<from>\d+(\.\d+)?)\s+(?<to>\d+\.\d+)?$/i,
41
41
  :route_random_float_from_to, command: true)
42
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
43
+ matches = response.matches[0]
44
+ from = matches[0].to_f
45
+ to = matches[1].to_f
46
46
  response.reply(::Random.rand(from...to).to_s)
47
47
  end
48
+
49
+ route(/^rand(om)?\s*b(ase)?64$/i, :route_random_base64, command: true)
50
+ def route_random_base64(response)
51
+ response.reply(SecureRandom.base64)
52
+ end
53
+
54
+ route(/^rand(om)?\s*b(ase)?64\s+(?<n>\d+)$/i,
55
+ :route_random_base64_n, command: true)
56
+ def route_random_base64_n(response)
57
+ n = response.matches[0][0].to_i
58
+ response.reply(SecureRandom.base64(n))
59
+ end
60
+
61
+ route(/^rand(om)?\s*(he?)?x$/i, :route_random_hex, command: true)
62
+ def route_random_hex(response)
63
+ response.reply(SecureRandom.hex)
64
+ end
65
+
66
+ route(/^rand(om)?\s*(he?)?x\s+(?<n>\d+)$/i,
67
+ :route_random_hex_n, command: true)
68
+ def route_random_hex_n(response)
69
+ n = response.matches[0][0].to_i
70
+ response.reply(SecureRandom.hex(n))
71
+ end
72
+
73
+ route(/^rand(om)?\s*u?uid$/i, :route_random_uuid, command: true)
74
+ def route_random_uuid(response)
75
+ response.reply(SecureRandom.uuid)
76
+ end
48
77
  end
49
78
 
50
79
  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.2.0'
5
+ spec.version = '0.3.0'
6
6
  spec.authors = ['Braiden Vasco']
7
7
  spec.email = ['braiden-vasco@mailtor.net']
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-random
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braiden Vasco