senha 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Jacob Hammack, Arxopia LLC
1
+ Copyright (c) 2010-2012 Arxopia LLC.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -9,17 +9,17 @@ modification, are permitted provided that the following conditions are met:
9
9
  * Redistributions in binary form must reproduce the above copyright
10
10
  notice, this list of conditions and the following disclaimer in the
11
11
  documentation and/or other materials provided with the distribution.
12
- * Neither the name of the Jacob Hammack or Arxopia LLC nor the
13
- names of its contributors may be used to endorse or promote products
14
- derived from this software without specific prior written permission.
12
+ * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ may be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
15
 
16
16
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
17
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
18
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
- DISCLAIMED. IN NO EVENT SHALL JACOB HAMMACK or ARXOPIA LLC BE LIABLE FOR ANY
20
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
+ DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,8 +1,12 @@
1
1
  # News
2
2
 
3
+ # 0.0.3 (July 30, 2012)
4
+ - License / Copyright changes
5
+ - Removed rspec
6
+
3
7
  # 0.0.2 (March 1, 2012)
4
8
  - Copyright updates
5
- - License uddates
9
+ - License updates
6
10
 
7
11
  # 0.0.1 (February 17, 2011)
8
- - Initial Release
12
+ - Initial Release
data/Rakefile CHANGED
@@ -1,16 +1,63 @@
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
1
27
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
28
 
3
29
  require "senha"
4
-
30
+ require 'rake'
31
+ require 'rake/testtask'
32
+
5
33
  task :build do
6
34
  system "gem build #{Senha::APP_NAME}.gemspec"
7
35
  end
8
36
 
9
- task :release => :build do
37
+ task :tag_and_bag do
38
+ system "git tag -a v#{Senha::VERSION} -m 'version #{Senha::VERSION}'"
39
+ system "git push --tags"
40
+ end
41
+
42
+ task :release => [:tag_and_bag, :build] do
10
43
  system "gem push #{Senha::APP_NAME}-#{Senha::VERSION}.gem"
11
- puts "Just released #{Senha::APP_NAME} v#{Senha::VERSION}. #{Senha::APP_NAME} is always available in RubyGems! More information at http://hammackj.com/projects/senha/"
44
+ puts "Just released #{Senha::APP_NAME} v#{Senha::VERSION}. #{Senha::APP_NAME} is a simple CLI password generator. More information at http://hammackj.com/projects/senha/"
45
+ end
46
+
47
+ task :merge do
48
+ system "git checkout master"
49
+ system "get merge #{Senha::VERSION}"
50
+ system "git push"
12
51
  end
13
52
 
14
53
  task :clean do
15
54
  system "rm *.gem"
16
55
  end
56
+
57
+ Rake::TestTask.new("run_tests") do |t|
58
+ t.libs << "test"
59
+ t.pattern = 'test/*/*_test.rb'
60
+ t.verbose = true
61
+ end
62
+
63
+ task :default => [:run_tests]
@@ -1,5 +1,13 @@
1
+ #0.0.2
1
2
  002:0> pwlen = 30
2
3
  30
3
4
  003:0> rand(36**pwlen).to_s(36)
4
5
  "hiswhwiuiqr7h1poet0o4kqizww15a"
5
6
 
7
+ - unhandled argument exception on cli parse
8
+
9
+ - add .senha/ config folder
10
+
11
+ - use gpg to encrypt a password file
12
+
13
+ - look at passgen
data/bin/senha CHANGED
@@ -1,9 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Copyright (c) 2010-2012 Arxopia LLC.
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # * Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ # * Redistributions in binary form must reproduce the above copyright
12
+ # notice, this list of conditions and the following disclaimer in the
13
+ # documentation and/or other materials provided with the distribution.
14
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
15
+ # may be used to endorse or promote products derived from this software
16
+ # without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
22
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
3
29
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../lib'))
4
30
 
5
31
  require 'senha'
6
- require 'senha/cli'
7
32
 
8
33
  app = Senha::CLI::Application.new
9
34
  app.run
@@ -1,6 +1,35 @@
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
1
27
  module Senha
2
28
  APP_NAME = "senha"
3
- VERSION = "0.0.2"
29
+ VERSION = "0.0.3"
4
30
  end
5
31
 
32
+ require 'optparse'
33
+
6
34
  require 'senha/base'
35
+ require 'senha/cli'
@@ -1,5 +1,32 @@
1
- module Senha::Base
2
-
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ module Senha
28
+ module Base
29
+ end
3
30
  end
4
31
 
5
32
  require 'senha/base/generator'
@@ -1,59 +1,85 @@
1
- module Senha::Base
2
-
3
- # A class for handling the generation of a password based on options
4
- #
5
- # @author Jacob Hammack <jacob.hammack@hammackj.com>
6
- class Generator
7
- attr_accessor :available_chars
8
-
9
- # Creates a new instance of the Generator class
10
- #
11
- # @return [Generator]
12
- def initialize(options)
13
- @available_chars = Array.new
14
-
15
- @numbers = ('0'..'9').to_a
16
- @lower_case = ('a'..'z').to_a
17
- @upper_case = ('A'..'Z').to_a
18
- @punctuation = %w(. , ! :).to_a
19
- @symbols = %w(~ ! @ # $ % ^ & * ( ) _).to_a
20
-
21
- if options[:all]
22
- @available_chars.concat @numbers
23
- @available_chars.concat @lower_case
24
- @available_chars.concat @upper_case
25
- @available_chars.concat @symbols
26
- @available_chars.concat @punctuation
27
- else
28
- if options[:numbers]
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ module Senha
28
+ module Base
29
+
30
+ # A class for handling the generation of a password based on options
31
+ class Generator
32
+ attr_accessor :available_chars
33
+
34
+ # Creates a new instance of the Generator class
35
+ #
36
+ # @return [Generator]
37
+ def initialize(options)
38
+ @available_chars = Array.new
39
+
40
+ @numbers = ('0'..'9').to_a
41
+ @lower_case = ('a'..'z').to_a
42
+ @upper_case = ('A'..'Z').to_a
43
+ @punctuation = %w(. , ! :).to_a
44
+ @symbols = %w(~ ! @ # $ % ^ & * ( ) _).to_a
45
+
46
+ if options[:all]
29
47
  @available_chars.concat @numbers
30
- end
31
-
32
- if options[:lowercase]
33
48
  @available_chars.concat @lower_case
34
- end
35
-
36
- if options[:uppercase]
37
49
  @available_chars.concat @upper_case
38
- end
39
-
40
- if options[:symbols]
41
50
  @available_chars.concat @symbols
42
- end
43
-
44
- if options[:punct]
45
51
  @available_chars.concat @punctuation
52
+ else
53
+ if options[:numbers]
54
+ @available_chars.concat @numbers
55
+ end
56
+
57
+ if options[:lowercase]
58
+ @available_chars.concat @lower_case
59
+ end
60
+
61
+ if options[:uppercase]
62
+ @available_chars.concat @upper_case
63
+ end
64
+
65
+ if options[:symbols]
66
+ @available_chars.concat @symbols
67
+ end
68
+
69
+ if options[:punct]
70
+ @available_chars.concat @punctuation
71
+ end
46
72
  end
47
73
  end
74
+
75
+ # Generates a password
76
+ #
77
+ # @return [String] of the randomly generated password
78
+ def password(length = 10)
79
+ 1.upto(length).collect do |a|
80
+ @available_chars[rand(@available_chars.size)]
81
+ end.join
82
+ end
48
83
  end
49
-
50
- # Generates a password
51
- #
52
- # @return [String] of the randomly generated password
53
- def password(length = 10)
54
- 1.upto(length).collect do |a|
55
- @available_chars[rand(@available_chars.size)]
56
- end.join
57
- end
58
84
  end
59
85
  end
@@ -1,4 +1,28 @@
1
- # encoding: utf-8
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
2
26
 
3
27
  module Senha
4
28
  module CLI
@@ -1,56 +1,75 @@
1
- # encoding: utf-8
2
-
3
- require 'optparse'
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
4
26
 
5
27
  module Senha
6
28
  module CLI
7
-
8
- # The Application class is responsible for the
9
- #
10
- # @author Jacob Hammack <jacob.hammack@hammackj.com>
29
+
30
+ # The Application class is responsible for the
11
31
  class Application
12
-
32
+
13
33
  # Creates a new instance of the Application Class
14
34
  #
15
35
  # @return [Application] New instance
16
36
  def initialize
17
37
  end
18
-
38
+
19
39
  # Parses the command line arguments
20
- #
21
40
  def parse_arguments
22
41
  begin
23
42
  options = {}
24
-
43
+
25
44
  options[:length] = 10
26
45
  options[:count] = 1
27
-
46
+
28
47
  opts = OptionParser.new do |opt|
29
48
  opt.banner = "#{APP_NAME} v#{VERSION}\nJacob Hammack\nhttp://www.hammackj.com\n\n"
30
49
  opt.banner << "Usage: #{APP_NAME} <options>"
31
50
  opt.separator('')
32
51
  opt.separator("Password Options")
33
-
52
+
34
53
  opt.on("-n", "--numbers", "Use digits [0-9] in the password generation") do |n|
35
54
  options[:numbers] = n
36
55
  end
37
-
56
+
38
57
  opt.on("-p", "--punctuation", "Use punctuation in the password generation") do |p|
39
58
  options[:punct] = p
40
59
  end
41
-
60
+
42
61
  opt.on("-s", "--symbols", "Use symbols in the password generation") do |s|
43
62
  options[:symbols] = s
44
63
  end
45
-
64
+
46
65
  opt.on("-l", "--lowercase", "Use lowercase [a-z] in the password generation") do |l|
47
66
  options[:lowercase] = l
48
- end
49
-
67
+ end
68
+
50
69
  opt.on("-u", "--uppercase", "Use uppercase [A-Z] in the password generation") do |u|
51
70
  options[:uppercase] = u
52
71
  end
53
-
72
+
54
73
  opt.on("-a", "--all-characters", "Use all available character sets for password generationA") do |a|
55
74
  options[:all] = a
56
75
  end
@@ -60,12 +79,12 @@ module Senha
60
79
 
61
80
  opt.on("--count COUNT", Integer, "Number of passwords to generate, default is 1") do |count|
62
81
  options[:count] = count#.to_i
63
- end
82
+ end
64
83
 
65
84
  opt.on("--length LENGTH", Integer, "Use uppercase in the password generation, default is 10") do |length|
66
85
  options[:length] = length#.to_i
67
86
  end
68
-
87
+
69
88
  opt.on_tail('-v', '--version', "Shows application version information") do
70
89
  puts "#{APP_NAME} - #{VERSION}"
71
90
  exit
@@ -77,34 +96,33 @@ module Senha
77
96
  end
78
97
 
79
98
  end
80
-
81
- if ARGV.length != 0
99
+
100
+ if ARGV.length != 0
82
101
  opts.parse!
83
102
  else
84
103
  puts opts.to_s + "\n"
85
104
  exit
86
105
  end
87
-
106
+
88
107
  options
89
108
  rescue OptionParser::MissingArgument => m
90
109
  puts opts.to_s + "\n"
91
110
  exit
92
111
  rescue OptionParser::InvalidOption => i
93
112
  puts opts.to_s + "\n"
94
- exit
113
+ exit
95
114
  end
96
115
  end
97
-
116
+
98
117
  # Main body of the Application class
99
- #
100
118
  def run
101
119
  options = parse_arguments
102
-
120
+
103
121
  gen = Senha::Base::Generator.new(options)
104
-
122
+
105
123
  options[:count].times do
106
124
  puts gen.password(options[:length])
107
- end
125
+ end
108
126
  end
109
127
  end
110
128
  end
@@ -1,4 +1,28 @@
1
- # encoding: utf-8
1
+ # Copyright (c) 2010-2012 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
2
26
 
3
27
  base = __FILE__
4
28
  $:.unshift(File.join(File.dirname(base), 'lib'))
@@ -12,23 +36,19 @@ Gem::Specification.new do |s|
12
36
  s.summary = "#{Senha::APP_NAME}"
13
37
  s.description = "#{Senha::APP_NAME} is a password generation tool"
14
38
  s.license = "BSD"
15
-
39
+
16
40
  s.author = "Jacob Hammack"
17
41
  s.email = "jacob.hammack@hammackj.com"
18
-
42
+
19
43
  s.files = Dir['[A-Z]*'] + Dir['lib/**/*'] + ['senha.gemspec']
20
44
  s.default_executable = "#{Senha::APP_NAME}"
21
45
  s.executables = ["#{Senha::APP_NAME}"]
22
46
  s.require_paths = ["lib"]
23
-
47
+
24
48
  s.has_rdoc = 'yard'
25
49
  s.extra_rdoc_files = ["README.markdown", "LICENSE", "NEWS.markdown"]
26
-
27
- s.required_rubygems_version = ">= 1.3.6"
50
+
51
+ s.required_rubygems_version = ">= 1.6.0"
28
52
  s.rubyforge_project = "#{Senha::APP_NAME}"
29
-
30
- s.add_development_dependency("rspec", ">= 2.4.0")
31
- s.add_development_dependency("rcov", ">= 0.9.9")
32
- s.add_development_dependency("yard", ">= 0.6.4")
33
-
53
+
34
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: senha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,41 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-02 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: &70179446946840 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 2.4.0
22
- type: :development
23
- prerelease: false
24
- version_requirements: *70179446946840
25
- - !ruby/object:Gem::Dependency
26
- name: rcov
27
- requirement: &70179446946360 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 0.9.9
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70179446946360
36
- - !ruby/object:Gem::Dependency
37
- name: yard
38
- requirement: &70179446945900 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: 0.6.4
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70179446945900
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
+ dependencies: []
47
14
  description: senha is a password generation tool
48
15
  email: jacob.hammack@hammackj.com
49
16
  executables:
@@ -54,15 +21,15 @@ extra_rdoc_files:
54
21
  - LICENSE
55
22
  - NEWS.markdown
56
23
  files:
24
+ - README.markdown
57
25
  - LICENSE
58
26
  - NEWS.markdown
59
- - Rakefile
60
- - README.markdown
61
27
  - TODO.markdown
28
+ - Rakefile
62
29
  - lib/senha/base/generator.rb
63
30
  - lib/senha/base.rb
64
- - lib/senha/cli/application.rb
65
31
  - lib/senha/cli.rb
32
+ - lib/senha/cli/application.rb
66
33
  - lib/senha.rb
67
34
  - senha.gemspec
68
35
  - bin/senha
@@ -84,10 +51,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
51
  requirements:
85
52
  - - ! '>='
86
53
  - !ruby/object:Gem::Version
87
- version: 1.3.6
54
+ version: 1.6.0
88
55
  requirements: []
89
56
  rubyforge_project: senha
90
- rubygems_version: 1.8.6
57
+ rubygems_version: 1.8.24
91
58
  signing_key:
92
59
  specification_version: 3
93
60
  summary: senha