xkcd936 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Xkcd936
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/xkcd936.svg)](http://badge.fury.io/rb/xkcd936)
4
+
3
5
  [xkcd936](https://www.xkcd.com/936/) style passphrase generator.
4
6
 
5
- But we use 5 words instead of 4, since 5 words will achieve an entropy of:
7
+ But we use 5 words as default instead of 4, since 5 words will achieve an entropy of:
6
8
 
7
- $$log(99171)/log(2)*5 = 82.988$$
9
+ log(99171)/log(2)*5 = 82.988
8
10
 
9
11
  This is enough.
10
12
  NIST recommends 80-bits for the most secure passwords.
@@ -32,9 +34,10 @@ As a library:
32
34
 
33
35
  ```ruby
34
36
  require 'xkcd936'
35
- Xkcd936.generate_passphrase('path/to/dictionary/file')
37
+ Xkcd936.generate_passphrase(4, 'path/to/dictionary/file')
36
38
  ```
37
39
 
40
+ If you does not specify how many words you want, it will use the default value `5`.
38
41
  If you does not give a path, it will use `/usr/share/dict/words` as default.
39
42
 
40
43
  As a command line tool:
@@ -0,0 +1,16 @@
1
+ require 'lib/xkcd936'
2
+ require 'pry-rescue/minitest'
3
+
4
+ open('lib/xkcd936.rb') do |f|
5
+ module_lines = f.find_all { |line| line[0..5] == 'module' }
6
+ modules = module_lines.map { |s| s.strip.tr(' ', '')[6..-1] }
7
+ modules.each do |mod|
8
+ mod = Object.const_get(mod)
9
+ include mod
10
+ YARD::Doctest.configure do |doctest|
11
+ mod.private_instance_methods.each do |m|
12
+ doctest.skip "#{mod}.#{m.to_s}"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,18 +1,31 @@
1
- require "xkcd936/version"
1
+ require 'xkcd936/version'
2
+ require 'i18n'
2
3
 
3
4
  module Xkcd936
4
5
  module_function
5
6
 
6
7
  # Inspired by http://xkcd.com/936/
7
- # But I use 5 words instead of 4, since 5 words will achieve an entropy of:
8
+ # But I use 5 words as default instead of 4, since 5 words will achieve
9
+ # an entropy of:
8
10
  # log(99171)/log(2)*5 = 82.988
9
11
  # This is enough.
10
12
  # NIST recommends 80-bits for the most secure passwords.
11
13
  # And it roughly needs 6 billions USD to break.
12
14
  #
15
+ # @param [Fixnum] number of words
13
16
  # @param [String] dict file path
14
17
  # @return [String] passphrase
15
- def generate_passphrase(dict='/usr/share/dict/words')
16
- (IO.readlines(dict).sample(5).map { |s| s.chomp.capitalize }).join
18
+ #
19
+ # @example default values
20
+ # generate_passphrase
21
+ # @example pick up four words
22
+ # generate_passphrase(4)
23
+ def generate_passphrase(number=5, dict='/usr/share/dict/words')
24
+ pick_five = IO.readlines(dict).sample(number)
25
+ passphrase = pick_five.map { |s| s.chomp.capitalize }.join
26
+ # Let I18n skip validation and fall back to built in :en locale.
27
+ # Otherwise you need to have a locale file.
28
+ I18n.enforce_available_locales = false
29
+ I18n.transliterate(passphrase)
17
30
  end
18
31
  end
@@ -1,3 +1,3 @@
1
1
  module Xkcd936
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -4,25 +4,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'xkcd936/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "xkcd936"
7
+ spec.name = 'xkcd936'
8
8
  spec.version = Xkcd936::VERSION
9
- spec.authors = ["Jakukyo Friel"]
10
- spec.email = ["weakish@gmail.com"]
9
+ spec.authors = ['Jakukyo Friel']
10
+ spec.email = ['weakish@gmail.com']
11
11
  spec.summary = %q{xkcd936 style passphrase generator.}
12
- spec.homepage = "https://github.com/weakish/xkcd936"
13
- spec.license = "MIT"
12
+ spec.homepage = 'https://github.com/weakish/xkcd936'
13
+ spec.license = 'MIT'
14
+ =begin gem < 2.0 does not support metadata
14
15
  spec.metadata = {
15
16
  'repository' => 'https://github.com/weakish/xkcd936.git',
16
17
  'documentation' => 'http://www.rubydoc.info/gems/xkcd936',
17
18
  'issues' => 'https://github.com/weakish/xkcd936/issues',
18
19
  'wiki' => 'https://github.com/weakish/xkcd936/wiki'
19
20
  }
20
-
21
+ =end
21
22
  spec.files = `git ls-files -z`.split("\x0")
22
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
- spec.require_paths = ["lib"]
25
+ spec.require_paths = ['lib']
25
26
 
26
- spec.add_development_dependency "bundler", "~> 1.7"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.required_ruby_version = '>= 1.9.3'
28
+ spec.add_development_dependency 'bundler', '~> 1.3'
29
+ spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'yard'
31
+ spec.add_development_dependency 'yard-doctest'
32
+ spec.add_development_dependency 'pry-rescue'
28
33
  end
metadata CHANGED
@@ -1,43 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xkcd936
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Jakukyo Friel
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
12
+ date: 2016-04-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: '1.7'
21
+ version: '1.3'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: '1.7'
29
+ version: '1.3'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
- version: '10.0'
37
+ version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
- version: '10.0'
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard-doctest
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry-rescue
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
41
94
  description:
42
95
  email:
43
96
  - weakish@gmail.com
@@ -46,42 +99,40 @@ executables:
46
99
  extensions: []
47
100
  extra_rdoc_files: []
48
101
  files:
49
- - ".gitignore"
102
+ - .gitignore
50
103
  - Gemfile
51
104
  - LICENSE.txt
52
105
  - README.md
53
106
  - Rakefile
54
107
  - bin/xkcd936
108
+ - doctest_helper.rb
55
109
  - lib/xkcd936.rb
56
110
  - lib/xkcd936/version.rb
57
111
  - xkcd936.gemspec
58
112
  homepage: https://github.com/weakish/xkcd936
59
113
  licenses:
60
114
  - MIT
61
- metadata:
62
- repository: https://github.com/weakish/xkcd936.git
63
- documentation: http://www.rubydoc.info/gems/xkcd936
64
- issues: https://github.com/weakish/xkcd936/issues
65
- wiki: https://github.com/weakish/xkcd936/wiki
66
115
  post_install_message:
67
116
  rdoc_options: []
68
117
  require_paths:
69
118
  - lib
70
119
  required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
71
121
  requirements:
72
- - - ">="
122
+ - - ! '>='
73
123
  - !ruby/object:Gem::Version
74
- version: '0'
124
+ version: 1.9.3
75
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
76
127
  requirements:
77
- - - ">="
128
+ - - ! '>='
78
129
  - !ruby/object:Gem::Version
79
130
  version: '0'
80
131
  requirements: []
81
132
  rubyforge_project:
82
- rubygems_version: 2.2.2
133
+ rubygems_version: 1.8.23
83
134
  signing_key:
84
- specification_version: 4
135
+ specification_version: 3
85
136
  summary: xkcd936 style passphrase generator.
86
137
  test_files: []
87
138
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3ab3ee6f0bee59bc50b0910a7013dc281f90de25
4
- data.tar.gz: 82a6ffd0105226d0b0dabdf097dc78f519ed2817
5
- SHA512:
6
- metadata.gz: 6d913f6d591b18a21270f0e8b3b0ad956dc9606ff498ae61859665324db40b92f3c887f261602893d504ff8f3f65d889d64b3d36b4ff154cbceba97f303a1455
7
- data.tar.gz: 8fc6ea179996e8298efd555548e4ae8f69eb8a7ac73c30bc5f4e645b4ae9dc9f23f06e944bc37a4ff96906c456efa8e278373297e72bc46fb3d212a659a6c037