Permalink
Browse files

conversion to different project layout

  • Loading branch information...
1 parent 372f6a5 commit e0e59bf11e9dd19afcd38d276de15a26673259c5 @copiousfreetime committed Dec 1, 2008
View
@@ -0,0 +1,5 @@
+*~
+pkg/
+coverage/
+*.swp
+*.swo
View
@@ -1,5 +1,9 @@
= HTAuth
+== Version 1.0.2 (2008-11-30)
+
+* Change project layout
+
== Version 1.0.1 (2008-02-06)
=== Changes
View
3 README
@@ -2,7 +2,8 @@
* Homepage[http://copiousfreetime.rubyforge.org/htauth]
* {Rubyforge Project}[http://rubyforge.org/projects/copiousfreetime/]
-* email jeremy at hinegardner dot org
+* Github[http://github.com/copiousfreetime/htauth/tree/master]
+* email jeremy at copiousfreetime dot org
== DESCRIPTION
View
@@ -1,14 +1,61 @@
-# make sure our project's ./lib directory is added to the ruby search path
-$: << File.join(File.dirname(__FILE__),"lib")
+#--
+# Copyright (c) 2008 Jeremy Hinegardner
+# All rights reserved. See LICENSE and/or COPYING for details.
+#++
+#-------------------------------------------------------------------------------
+# make sure our project's top level directory and the lib directory are added to
+# the ruby search path.
+#-------------------------------------------------------------------------------
+$: << File.expand_path(File.join(File.dirname(__FILE__),"lib"))
+$: << File.expand_path(File.dirname(__FILE__))
+
+#-------------------------------------------------------------------------------
+# load the global project configuration and add in the top level clean and
+# clobber tasks so that other tasks can utilize those constants if necessary
+# This loads up the defaults for the whole project configuration
+#-------------------------------------------------------------------------------
require 'rubygems'
-require 'rake/gempackagetask'
+require 'tasks/config.rb'
+require 'gemspec'
require 'rake/clean'
+require 'rake/gempackagetask'
require 'rake/rdoctask'
-require 'rake/contrib/sshpublisher'
-
+require 'spec/rake/spectask'
+#-------------------------------------------------------------------------------
+# Main configuration for the project, these overwrite the items that are in
+# tasks/config.rb
+#-------------------------------------------------------------------------------
require 'htauth'
+Configuration.for("project") {
+ name "htauth"
+ version HTAuth::VERSION
+ author "Jeremy Hinegardner"
+ email "jeremy@copiousfreetime.org"
+ homepage "http://copiousfreetime.rubyforge.org/htauth/"
+}
-load 'tasks/setup.rb'
-
+#-------------------------------------------------------------------------------
+# load up all the project tasks and setup the default task to be the
+# test:default task.
+#-------------------------------------------------------------------------------
+Configuration.for("packaging").files.tasks.each do |tasklib|
+ import tasklib
+end
+task :default => 'test:default'
+#-------------------------------------------------------------------------------
+# Finalize the loading of all pending imports and update the top level clobber
+# task to depend on all possible sub-level tasks that have a name like
+# ':clobber' in other namespaces. This allows us to say:
+#
+# rake clobber
+#
+# and it will get everything.
+#-------------------------------------------------------------------------------
+Rake.application.load_imports
+Rake.application.tasks.each do |t|
+ if t.name =~ /:clobber/ then
+ task :clobber => [t.name]
+ end
+end
View
19 bin/htdigest-ruby 100644 → 100755
@@ -1,12 +1,19 @@
#!/usr/bin/env ruby
+begin
+ require 'highline'
+rescue LoadError
+ require 'rubygems'
+ require 'highline'
+end
+
begin
- require 'htauth'
+ require 'htauth'
rescue LoadError
- path = File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
- raise if $:.include?(path)
- $: << path
- retry
+ path = File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
+ raise if $:.include?(path)
+ $: << path
+ retry
end
-HTAuth::Digest.new.run(ARGV)
+HTAuth::Digest.new.run(ARGV, ENV)
View
9 bin/htpasswd-ruby 100644 → 100755
@@ -1,5 +1,12 @@
#!/usr/bin/env ruby
+begin
+ require 'highline'
+rescue LoadError
+ require 'rubygems'
+ require 'highline'
+end
+
begin
require 'htauth'
rescue LoadError
@@ -9,4 +16,4 @@ rescue LoadError
retry
end
-HTAuth::Passwd.new.run(ARGV)
+HTAuth::Passwd.new.run(ARGV, ENV)
View
@@ -0,0 +1,43 @@
+require 'rubygems'
+require 'htauth/version'
+require 'tasks/config'
+
+HTAuth::GEM_SPEC = Gem::Specification.new do |spec|
+ proj = Configuration.for('project')
+ spec.name = proj.name
+ spec.version = HTAuth::VERSION
+
+ spec.author = proj.author
+ spec.email = proj.email
+ spec.homepage = proj.homepage
+ spec.summary = proj.summary
+ spec.description = proj.description
+ spec.platform = Gem::Platform::RUBY
+
+
+ pkg = Configuration.for('packaging')
+ spec.files = pkg.files.all
+ spec.executables = pkg.files.bin.collect { |b| File.basename(b) }
+
+ # add dependencies here
+ # spec.add_dependency("rake", ">= 0.8.1")
+ spec.add_dependency("highline", "~> 1.4.0")
+
+
+ if rdoc = Configuration.for_if_exist?('rdoc') then
+ spec.has_rdoc = true
+ spec.extra_rdoc_files = pkg.files.rdoc
+ spec.rdoc_options = rdoc.options + [ "--main" , rdoc.main_page ]
+ else
+ spec.has_rdoc = false
+ end
+
+ if test = Configuration.for_if_exist?('testing') then
+ spec.test_files = test.files
+ end
+
+ if rf = Configuration.for_if_exist?('rubyforge') then
+ spec.rubyforge_project = rf.project
+ end
+
+end
View
@@ -1,14 +1,36 @@
+#--
+# Copyrigth (c) 2008 Jeremy Hinegardner
+# All rights reserved. See LICENSE and/or COPYING for details
+#++
+
module HTAuth
-
- ROOT_DIR = ::File.expand_path(::File.join(::File.dirname(__FILE__),".."))
- LIB_DIR = ::File.join(ROOT_DIR,"lib").freeze
- class FileAccessError < StandardError ; end
- class TempFileError < StandardError ; end
- class PasswordError < StandardError ; end
+ # The root directory of the project is considered to be the parent directory
+ # of the 'lib' directory.
+ #
+ def self.root_dir
+ unless @root_dir
+ path_parts = ::File.expand_path( __FILE__ ).split( ::File::SEPARATOR )
+ lib_index = path_parts.rindex( 'lib' )
+ @root_dir = path_parts[ 0...lib_index].join( ::File::SEPARATOR ) + ::File::SEPARATOR
+ end
+ return @root_dir
+ end
+
+ def self.lib_path( *args )
+ self.sub_path( "lib", *args )
+ end
+
+ def self.sub_path( sub, *args )
+ sp = ::File.join( root_dir, sub ) + ::File::SEPARATOR
+ sp = ::File.join( sp, *args ) if args
+ end
+
+ class FileAccessError < StandardError ; end
+ class TempFileError < StandardError ; end
+ class PasswordError < StandardError ; end
end
require 'htauth/version'
-require 'htauth/gemspec'
require 'htauth/passwd'
require 'htauth/digest'
View
@@ -1,67 +1,68 @@
require 'htauth'
module HTAuth
- class InvalidAlgorithmError < StandardError ; end
- # base class all the Passwd algorithms derive from
- class Algorithm
+ class InvalidAlgorithmError < StandardError ; end
+ # base class all the Passwd algorithms derive from
+ class Algorithm
- SALT_CHARS = (%w[ . / ] + ("0".."9").to_a + ('A'..'Z').to_a + ('a'..'z').to_a).freeze
- DEFAULT = ( RUBY_PLATFORM !~ /mswin32/ ) ? "crypt" : "md5"
- EXISTING = "existing"
+ SALT_CHARS = (%w[ . / ] + ("0".."9").to_a + ('A'..'Z').to_a + ('a'..'z').to_a).freeze
+ DEFAULT = ( RUBY_PLATFORM !~ /mswin32/ ) ? "crypt" : "md5"
+ EXISTING = "existing"
- class << self
- def algorithm_from_name(a_name, params = {})
- raise InvalidAlgorithmError, "`#{a_name}' is an invalid encryption algorithm, use one of #{sub_klasses.keys.join(', ')}" unless sub_klasses[a_name.downcase]
- sub_klasses[a_name.downcase].new(params)
- end
+ class << self
+ def algorithm_from_name(a_name, params = {})
+ raise InvalidAlgorithmError, "`#{a_name}' is an invalid encryption algorithm, use one of #{sub_klasses.keys.join(', ')}" unless sub_klasses[a_name.downcase]
+ sub_klasses[a_name.downcase].new(params)
+ end
- def algorithms_from_field(password_field)
- matches = []
+ def algorithms_from_field(password_field)
+ matches = []
- if password_field.index(sub_klasses['sha1'].new.prefix) then
- matches << sub_klasses['sha1'].new
- elsif password_field.index(sub_klasses['md5'].new.prefix) then
- p = password_field.split("$")
- matches << sub_klasses['md5'].new( :salt => p[2] )
- else
- matches << sub_klasses['plaintext'].new
- matches << sub_klasses['crypt'].new( :salt => password_field[0,2] )
- end
+ if password_field.index(sub_klasses['sha1'].new.prefix) then
+ matches << sub_klasses['sha1'].new
+ elsif password_field.index(sub_klasses['md5'].new.prefix) then
+ p = password_field.split("$")
+ matches << sub_klasses['md5'].new( :salt => p[2] )
+ else
+ matches << sub_klasses['plaintext'].new
+ matches << sub_klasses['crypt'].new( :salt => password_field[0,2] )
+ end
- return matches
- end
+ return matches
+ end
- def inherited(sub_klass)
- k = sub_klass.name.split("::").last.downcase
- sub_klasses[k] = sub_klass
- end
+ def inherited(sub_klass)
+ k = sub_klass.name.split("::").last.downcase
+ sub_klasses[k] = sub_klass
+ end
- def sub_klasses
- @sub_klasses ||= {}
- end
- end
+ def sub_klasses
+ @sub_klasses ||= {}
+ end
+ end
- def prefix ; end
- def encode(password) ; end
-
- # 8 bytes of random items from SALT_CHARS
- def gen_salt
- chars = []
- 8.times { chars << SALT_CHARS[rand(SALT_CHARS.size)] }
- chars.join('')
- end
+ def prefix ; end
+ def encode(password) ; end
- # this is not the Base64 encoding, this is the to64() method from apr
- def to_64(number, rounds)
- r = StringIO.new
- rounds.times do |x|
- r.print(SALT_CHARS[number % 64])
- number >>= 6
- end
- return r.string
- end
+ # 8 bytes of random items from SALT_CHARS
+ def gen_salt
+ chars = []
+ 8.times { chars << SALT_CHARS[rand(SALT_CHARS.size)] }
+ chars.join('')
+ end
+
+ # this is not the Base64 encoding, this is the to64() method from apr
+ def to_64(number, rounds)
+ r = StringIO.new
+ rounds.times do |x|
+ r.print(SALT_CHARS[number % 64])
+ number >>= 6
+ end
+ return r.string
end
+ end
end
+
require 'htauth/md5'
require 'htauth/sha1'
require 'htauth/crypt'
View
@@ -2,19 +2,19 @@
module HTAuth
- # The basic crypt algorithm
- class Crypt < Algorithm
-
- def initialize(params = {})
- @salt = params[:salt] || params['salt'] || gen_salt
- end
+ # The basic crypt algorithm
+ class Crypt < Algorithm
- def prefix
+ def initialize(params = {})
+ @salt = params[:salt] || params['salt'] || gen_salt
+ end
+
+ def prefix
""
- end
+ end
- def encode(password)
- password.crypt(@salt)
- end
+ def encode(password)
+ password.crypt(@salt)
end
+ end
end
Oops, something went wrong.

0 comments on commit e0e59bf

Please sign in to comment.