Permalink
Browse files

ready

  • Loading branch information...
maiha committed Mar 3, 2009
1 parent f7ea49e commit 88e9b2b0fe5355fb427dda338d176725b1d0e3b2
Showing with 157 additions and 0 deletions.
  1. +20 −0 MIT-LICENSE
  2. +22 −0 README
  3. +74 −0 Rakefile
  4. +12 −0 lib/open-uri-mapping.rb
  5. +29 −0 open-uri-mapping.gemspec
View
@@ -0,0 +1,20 @@
+Copyright (c) 2008 [name of plugin creator]
+
+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.
View
22 README
@@ -0,0 +1,22 @@
+open-uri-mapping
+================
+
+a wrapper to open-uri that offers filename mapping, which is useful for test
+
+Usage
+=====
+
+ require 'rubygems'
+ require 'open-uri-mapping'
+
+ URI::Mapping.merge!(
+ "http://merbi.st/plugins/" => "/tmp/plugins1.html"
+ )
+
+ open("http://merbi.st/plugins/")
+ # -> "Errno::ENOENT: No such file or directory - /tmp/plugins1.html"
+
+This error means that it opens file from not http but a specified local file.
+
+
+Copyright (c) 2009 maiha@wota.jp, released under the MIT license
View
@@ -0,0 +1,74 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the open-uri-mapping plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the dm-ys plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'open-uri-mapping'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+
+######################################################################
+### for gem
+
+require 'rubygems'
+require 'rake/gempackagetask'
+
+GEM_NAME = "open-uri-mapping"
+AUTHOR = "maiha"
+EMAIL = "maiha@wota.jp"
+HOMEPAGE = "http://github.com/maiha/open-uri-mapping"
+SUMMARY = "a wrapper to open-uri that offers filename mapping, which is useful for test"
+GEM_VERSION = "0.1"
+
+spec = Gem::Specification.new do |s|
+# s.rubyforge_project = 'merb'
+ s.name = GEM_NAME
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "MIT-LICENSE"]
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+ s.require_path = 'lib'
+ s.files = %w(MIT-LICENSE README Rakefile) + Dir.glob("{core_ext,lib,spec,tasks,test}/**/*")
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "Install the gem"
+task :install do
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
+end
+
+desc "Uninstall the gem"
+task :uninstall do
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
+end
+
+desc "Create a gemspec file"
+task :gemspec do
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
+
View
@@ -0,0 +1,12 @@
+require 'open-uri'
+unless ::URI.const_defined?(:Mapping)
+ ::URI::Mapping = {}
+ module ::Kernel
+ private
+ alias :open_without_mapping :open
+ def open(name, *rest, &block)
+ open_without_mapping(::URI::Mapping[name] || name, *rest, &block)
+ end
+ end
+end
+
View
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{open-uri-mapping}
+ s.version = "0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["maiha"]
+ s.date = %q{2009-03-03}
+ s.description = %q{a wrapper to open-uri that offers filename mapping, which is useful for test}
+ s.email = %q{maiha@wota.jp}
+ s.extra_rdoc_files = ["README", "MIT-LICENSE"]
+ s.files = ["MIT-LICENSE", "README", "Rakefile", "lib/open-uri-mapping.rb"]
+ s.has_rdoc = true
+ s.homepage = %q{http://github.com/maiha/open-uri-mapping}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.1}
+ s.summary = %q{a wrapper to open-uri that offers filename mapping, which is useful for test}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end

0 comments on commit 88e9b2b

Please sign in to comment.