pwm 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pwm.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/pwm ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pwm'
3
+ length = (ARGV[0] || 16).to_i
4
+ puts Pwm.password(length)
@@ -0,0 +1,3 @@
1
+ module Pwm
2
+ VERSION = "1.0.0"
3
+ end
data/lib/pwm.rb ADDED
@@ -0,0 +1,13 @@
1
+ require "pwm/version"
2
+
3
+ module Pwm
4
+ def self.characters
5
+ [('A'..'Z'),('a'..'z'),('2'..'9')].collect{|r| r.collect{|c| c}}.flatten
6
+ end
7
+
8
+ def self.password(length=16)
9
+ (0..length-1).inject('') do |pw, n|
10
+ pw + characters[rand(characters.length)]
11
+ end
12
+ end
13
+ end
data/pwm.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "pwm/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pwm"
7
+ s.version = Pwm::VERSION
8
+ s.authors = ["Mark Cornick"]
9
+ s.email = ["mark@markcornick.com"]
10
+ s.homepage = "https://github.com/markcornick/pwm"
11
+ s.summary = %q{A reasonably secure password maker}
12
+ s.description = %q{A tiny class and command-line tool to generate reasonably secure passwords.}
13
+
14
+ s.rubyforge_project = "pwm"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
data/spec/pwm_spec.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'pwm'
2
+
3
+ describe Pwm do
4
+ context 'The default set of characters' do
5
+ it 'should include all upper-case letters' do
6
+ ('A'..'Z').each do |letter|
7
+ Pwm.characters.should include(letter)
8
+ end
9
+ end
10
+ it 'should include all lower-case letters' do
11
+ ('a'..'z').each do |letter|
12
+ Pwm.characters.should include(letter)
13
+ end
14
+ end
15
+ it 'should include all digits 2 through 9' do
16
+ ('2'..'9').each do |letter|
17
+ Pwm.characters.should include(letter)
18
+ end
19
+ end
20
+ end
21
+
22
+ context 'The password method' do
23
+ context 'when given a length' do
24
+ it 'should generate a password of that length' do
25
+ Pwm.password(8).length.should == 8
26
+ end
27
+ end
28
+ context 'when not given a length' do
29
+ it 'should generate a 16-character password' do
30
+ Pwm.password.length.should == 16
31
+ end
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pwm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Cornick
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-03 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70348764844280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70348764844280
25
+ description: A tiny class and command-line tool to generate reasonably secure passwords.
26
+ email:
27
+ - mark@markcornick.com
28
+ executables:
29
+ - pwm
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - Rakefile
36
+ - bin/pwm
37
+ - lib/pwm.rb
38
+ - lib/pwm/version.rb
39
+ - pwm.gemspec
40
+ - spec/pwm_spec.rb
41
+ homepage: https://github.com/markcornick/pwm
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project: pwm
61
+ rubygems_version: 1.8.10
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: A reasonably secure password maker
65
+ test_files:
66
+ - spec/pwm_spec.rb