lita-random 0.3.0 → 0.4.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: e2a5d89363f50d714f1ec46581510a27b4abd3ed
4
- data.tar.gz: d5d2e3ddbcfbc02874f6285ee97742add4402155
3
+ metadata.gz: c67828bb15939d57f5bec91b06da08d4d6aee941
4
+ data.tar.gz: 1cfe508040cdac80136ece314a00ebb8ba475e7e
5
5
  SHA512:
6
- metadata.gz: 02a73422b0a2633e2160154e2cdc008a375dd34c95a858bfa2caf0d4787beceb87ebdef4ff87951affb766829bc0c0ad012cce379e92cba2c2d6f1a992ef895a
7
- data.tar.gz: 0b50610e566e97a874eed7a1be21514a48b5037691030ca4afe59b41c9827a22d7d5921edcf24aeae6f7ef5a541747198c199483a2b360ee7aa3e291131fd448
6
+ metadata.gz: 88025951bc7403f01a417f3df20e9ee9eb44dd823b124a9182b40239185847868adaf7fbe74d64f4164cd45b797d156da9bd911d63997e91c069f5e6355b924e
7
+ data.tar.gz: eef729336d090cf88bffde3a8337b4882f7e0c4fa96e5bd281ac303888d6757224b5140e11610813118548b173b2904fb281f466ca2414012612dcffdfefb704
data/.rubocop.yml CHANGED
@@ -2,5 +2,11 @@ AllCops:
2
2
  Exclude:
3
3
  - vendor/**/*
4
4
 
5
+ Style/AccessModifierIndentation:
6
+ EnforcedStyle: outdent
7
+
5
8
  Style/AndOr:
6
9
  Enabled: false
10
+
11
+ Style/TrailingComma:
12
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.4.0](https://github.com/braiden-vasco/lita-random/tree/v0.4.0) (2015-06-23)
4
+
5
+ [Full Changelog](https://github.com/braiden-vasco/lita-random/compare/v0.3.0...v0.4.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Add password generator [\#28](https://github.com/braiden-vasco/lita-random/pull/28) ([braiden-vasco](https://github.com/braiden-vasco))
10
+
11
+ - Add smart password generator [\#27](https://github.com/braiden-vasco/lita-random/pull/27) ([braiden-vasco](https://github.com/braiden-vasco))
12
+
13
+ - Add help for commands [\#26](https://github.com/braiden-vasco/lita-random/pull/26) ([braiden-vasco](https://github.com/braiden-vasco))
14
+
3
15
  ## [v0.3.0](https://github.com/braiden-vasco/lita-random/tree/v0.3.0) (2015-06-21)
4
16
 
5
17
  [Full Changelog](https://github.com/braiden-vasco/lita-random/compare/v0.2.0...v0.3.0)
@@ -8,7 +20,7 @@
8
20
 
9
21
  - Add UUID generator [\#23](https://github.com/braiden-vasco/lita-random/pull/23) ([braiden-vasco](https://github.com/braiden-vasco))
10
22
 
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))
23
+ - Optional spaces between commands, add more aliases [\#22](https://github.com/braiden-vasco/lita-random/pull/22) ([braiden-vasco](https://github.com/braiden-vasco))
12
24
 
13
25
  - Add hexadecimal string generator [\#21](https://github.com/braiden-vasco/lita-random/pull/21) ([braiden-vasco](https://github.com/braiden-vasco))
14
26
 
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.3.0'
20
+ gem 'lita-random', '~> 0.4.0'
21
21
  ```
22
22
 
23
23
  ### Commands
@@ -49,11 +49,20 @@ Command `hex` has aliases `hx` and `x`
49
49
 
50
50
  Command `uuid` has alias `uid`
51
51
 
52
- * `random uuid`
52
+ * `random uuid` -
53
53
  v4 random UUID (Universally Unique IDentifier). The version 4 UUID
54
54
  is purely random (except the version). It doesn’t contain
55
55
  meaningful information such as MAC address, time, etc.
56
56
 
57
+ Command `password` has alias `pass`
58
+
59
+ * `random password <n=16>` -
60
+ random password with length `n` containing characters
61
+ in upper and lower case, and digits
62
+
63
+ * `random smart password <n=8>` -
64
+ random pronounceable password with a minimum length of `n`
65
+
57
66
  ### Examples
58
67
 
59
68
  ```
@@ -88,4 +97,14 @@ Lita: 0d8297837d6e63b8c25b
88
97
 
89
98
  You: lita random uuid
90
99
  Lita: f1281565-3c8a-475d-a1aa-565ff840a42c
100
+
101
+ You: lita random password
102
+ Lita: TXXBu7XEBdwFF7fP
103
+ You: lita randpass 8
104
+ Lita: 7lFateFs
105
+
106
+ You: lita random smart password
107
+ Lita: mospowot
108
+ You: lita random smartpass 16
109
+ Lita: jophemyrdivezagi
91
110
  ```
@@ -9,8 +9,42 @@ module Lita
9
9
  ##
10
10
  # Generator of random numbers and strings for the Lita chat bot.
11
11
  #
12
- class Random < Handler
13
- route(/^rand(om)?$/i, :route_random, command: true)
12
+ class Random < Handler # rubocop:disable Metrics/ClassLength
13
+ HELP = {
14
+ 'random' =>
15
+ 'random float number, greater or equal to 0 and lesser than 1',
16
+
17
+ 'random <to>' =>
18
+ 'random integer or float number, ' \
19
+ 'greater or equal to 0 and lesser than `to`',
20
+
21
+ 'random <from> <to>' =>
22
+ 'random integer or float number, ' \
23
+ 'greater or equal to `from` and lesser than `to`',
24
+
25
+ 'random base64 <n=16>' =>
26
+ 'random base64 string, length of source string is n, ' \
27
+ 'length of result is about `n * 4 / 3` ' \
28
+ '(24 with default value of `n`)',
29
+
30
+ 'random hex <n=16>' =>
31
+ 'random hexadecimal string with length `n * 2`',
32
+
33
+ 'random uuid' =>
34
+ 'v4 random UUID (Universally Unique IDentifier). ' \
35
+ 'The version 4 UUID is purely random (except the version). ' \
36
+ 'It doesn’t contain meaningful information ' \
37
+ 'such as MAC address, time, etc.',
38
+
39
+ 'random password <n=16>' =>
40
+ 'random password with length `n` containing characters ' \
41
+ 'in upper and lower case, and digits',
42
+
43
+ 'random smart password <n=8>' =>
44
+ 'random pronounceable password with a minimum length of `n`',
45
+ }
46
+
47
+ route(/^rand(om)?$/i, :route_random, command: true, help: HELP)
14
48
  def route_random(response)
15
49
  response.reply(::Random.rand.to_s)
16
50
  end
@@ -74,6 +108,58 @@ module Lita
74
108
  def route_random_uuid(response)
75
109
  response.reply(SecureRandom.uuid)
76
110
  end
111
+
112
+ route(/^rand(om)?\s*smart\s*pass(word)?$/i,
113
+ :route_random_smart_pass, command: true)
114
+ def route_random_smart_pass(response)
115
+ response.reply(smart_password)
116
+ end
117
+
118
+ route(/^rand(om)?\s*smart\s*pass(word)?\s+(?<n>\d+)$/i,
119
+ :route_random_smart_pass_n, command: true)
120
+ def route_random_smart_pass_n(response)
121
+ min_length = response.matches[0][0].to_i
122
+ response.reply(smart_password(min_length))
123
+ end
124
+
125
+ route(/^rand(om)?\s*pass(word)?$/i, :route_random_pass, command: true)
126
+ def route_random_pass(response)
127
+ response.reply(password)
128
+ end
129
+
130
+ route(/^rand(om)?\s*pass(word)?\s+(?<n>\d+)$/i,
131
+ :route_random_pass_n, command: true)
132
+ def route_random_pass_n(response)
133
+ length = response.matches[0][0].to_i
134
+ response.reply(password(length))
135
+ end
136
+
137
+ protected
138
+
139
+ SMART_PASS_SEQS = {
140
+ false => %w(
141
+ b c d f g h j k l m n p qu r s t v w x z
142
+ ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr lt
143
+ ),
144
+ true => %w(a e i o u y),
145
+ }
146
+
147
+ def smart_password(min_length = 8)
148
+ password = ''
149
+ sequence_id = false
150
+ while password.length < min_length
151
+ sequence = SMART_PASS_SEQS[sequence_id]
152
+ password << sequence.sample
153
+ sequence_id = !sequence_id
154
+ end
155
+ password
156
+ end
157
+
158
+ PASS_CHARS = [*'a'..'z', *'A'..'Z', *'0'..'9']
159
+
160
+ def password(length = 16)
161
+ (0...length).map { |_| PASS_CHARS.sample }.join
162
+ end
77
163
  end
78
164
 
79
165
  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.3.0'
5
+ spec.version = '0.4.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.3.0
4
+ version: 0.4.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-21 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler