Skip to content

Instantly share code, notes, and snippets.

@ohac
Created January 14, 2010 08:59
Show Gist options
  • Save ohac/276997 to your computer and use it in GitHub Desktop.
Save ohac/276997 to your computer and use it in GitHub Desktop.
md5web
README.rdoc
lib/**/*.rb
bin/*
features/**/*.feature
LICENSE
main.rb
views/*
## MAC OS
.DS_Store
## TEXTMATE
*.tmproj
tmtags
## EMACS
*~
\#*
.\#*
## VIM
*.swp
## PROJECT::GENERAL
coverage
rdoc
pkg
## PROJECT::SPECIFIC

md5web

Description goes here.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 OHASHI Hideya. See LICENSE for details.

require 'rubygems'
require 'test/unit'
require 'shoulda'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'md5web'
class Test::Unit::TestCase
end
%html
%head
%title file to md5sum
%body
%form{:action => '/md5', :method => 'post',
:enctype => 'multipart/form-data'}
%input{:type => 'input', :name => 'text'}
%input{:type => 'file', :name => 'file'}
%input{:type => 'submit'}
Copyright (c) 2009 OHASHI Hideya
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby-station'; RubyStation.parse_argv
require 'sinatra'
require 'haml'
require 'digest'
set :port, RubyStation.port
get '/' do
haml :index
end
post '/md5' do
t = params[:text]
f = params[:file]
c = f.nil? ? '' : f[:tempfile].read
md5t = t.size > 0 ? Digest::MD5.hexdigest(t) : nil
md5c = c.size > 0 ? Digest::MD5.hexdigest(c) : nil
haml :md5, :locals => { :md5t => md5t, :md5f => md5c }
end
%html
%head
%title result
%body
%table
- unless md5t.nil?
%tr
%td
%img{:src => "http://gravatar.com/avatar/#{md5t}?s=69&d=identicon"}
%td= md5t
- unless md5f.nil?
%tr
%td
%img{:src => "http://gravatar.com/avatar/#{md5f}?s=69&d=identicon"}
%td= md5f
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{md5web}
s.version = "0.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["OHASHI Hideya"]
s.date = %q{2010-01-20}
s.description = %q{support gravatar identicon}
s.email = %q{ohachige@gmail.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
]
s.files = [
".document",
".gitignore",
"LICENSE",
"README.rdoc",
"Rakefile",
"VERSION",
"lib/md5web.rb",
"main.rb",
"md5web.gemspec",
"md5web.rb",
"test/helper.rb",
"test/test_md5web.rb",
"views/index.haml",
"views/md5.haml"
]
s.homepage = %q{http://gist.github.com/276997}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
s.summary = %q{md5sum checker on web page}
s.test_files = [
"test/helper.rb",
"test/test_md5web.rb"
]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
s.add_runtime_dependency(%q<haml>, [">= 0"])
else
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<sinatra>, [">= 0"])
s.add_dependency(%q<haml>, [">= 0"])
end
else
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<sinatra>, [">= 0"])
s.add_dependency(%q<haml>, [">= 0"])
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'digest/md5'
get '/' do
haml :index
end
post '/md5' do
t = params[:text]
f = params[:file]
c = f.nil? ? '' : f[:tempfile].read
md5t = t.size > 0 ? Digest::MD5.hexdigest(t) : nil
md5c = c.size > 0 ? Digest::MD5.hexdigest(c) : nil
haml :md5, :locals => { :md5t => md5t, :md5f => md5c }
end
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "md5web"
gem.summary = %Q{md5sum checker on web page}
gem.description = %Q{support gravatar identicon}
gem.email = "ohachige@gmail.com"
gem.homepage = "http://gist.github.com/276997"
gem.authors = ["OHASHI Hideya"]
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
gem.add_dependency "sinatra"
gem.add_dependency "haml"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
rescue LoadError
task :rcov do
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
end
end
task :test => :check_dependencies
task :default => :test
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "md5web #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
require 'helper'
class TestMd5web < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment