maiha-open-uri-mapping 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +22 -0
  3. data/Rakefile +74 -0
  4. data/lib/open-uri-mapping.rb +12 -0
  5. metadata +57 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,22 @@
1
+ open-uri-mapping
2
+ ================
3
+
4
+ a wrapper to open-uri that offers filename mapping, which is useful for test
5
+
6
+ Usage
7
+ =====
8
+
9
+ require 'rubygems'
10
+ require 'open-uri-mapping'
11
+
12
+ URI::Mapping.merge!(
13
+ "http://merbi.st/plugins/" => "/tmp/plugins1.html"
14
+ )
15
+
16
+ open("http://merbi.st/plugins/")
17
+ # -> "Errno::ENOENT: No such file or directory - /tmp/plugins1.html"
18
+
19
+ This error means that it opens file from not http but a specified local file.
20
+
21
+
22
+ Copyright (c) 2009 maiha@wota.jp, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,74 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the open-uri-mapping plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the dm-ys plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'open-uri-mapping'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+
25
+ ######################################################################
26
+ ### for gem
27
+
28
+ require 'rubygems'
29
+ require 'rake/gempackagetask'
30
+
31
+ GEM_NAME = "open-uri-mapping"
32
+ AUTHOR = "maiha"
33
+ EMAIL = "maiha@wota.jp"
34
+ HOMEPAGE = "http://github.com/maiha/open-uri-mapping"
35
+ SUMMARY = "a wrapper to open-uri that offers filename mapping, which is useful for test"
36
+ GEM_VERSION = "0.1"
37
+
38
+ spec = Gem::Specification.new do |s|
39
+ # s.rubyforge_project = 'merb'
40
+ s.name = GEM_NAME
41
+ s.version = GEM_VERSION
42
+ s.platform = Gem::Platform::RUBY
43
+ s.has_rdoc = true
44
+ s.extra_rdoc_files = ["README", "MIT-LICENSE"]
45
+ s.summary = SUMMARY
46
+ s.description = s.summary
47
+ s.author = AUTHOR
48
+ s.email = EMAIL
49
+ s.homepage = HOMEPAGE
50
+ s.require_path = 'lib'
51
+ s.files = %w(MIT-LICENSE README Rakefile) + Dir.glob("{core_ext,lib,spec,tasks,test}/**/*")
52
+ end
53
+
54
+ Rake::GemPackageTask.new(spec) do |pkg|
55
+ pkg.gem_spec = spec
56
+ end
57
+
58
+ desc "Install the gem"
59
+ task :install do
60
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
61
+ end
62
+
63
+ desc "Uninstall the gem"
64
+ task :uninstall do
65
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
66
+ end
67
+
68
+ desc "Create a gemspec file"
69
+ task :gemspec do
70
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
71
+ file.puts spec.to_ruby
72
+ end
73
+ end
74
+
@@ -0,0 +1,12 @@
1
+ require 'open-uri'
2
+ unless ::URI.const_defined?(:Mapping)
3
+ ::URI::Mapping = {}
4
+ module ::Kernel
5
+ private
6
+ alias :open_without_mapping :open
7
+ def open(name, *rest, &block)
8
+ open_without_mapping(::URI::Mapping[name] || name, *rest, &block)
9
+ end
10
+ end
11
+ end
12
+
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maiha-open-uri-mapping
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - maiha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-03 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: a wrapper to open-uri that offers filename mapping, which is useful for test
17
+ email: maiha@wota.jp
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - MIT-LICENSE
25
+ files:
26
+ - MIT-LICENSE
27
+ - README
28
+ - Rakefile
29
+ - lib/open-uri-mapping.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/maiha/open-uri-mapping
32
+ post_install_message:
33
+ rdoc_options: []
34
+
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project:
52
+ rubygems_version: 1.2.0
53
+ signing_key:
54
+ specification_version: 2
55
+ summary: a wrapper to open-uri that offers filename mapping, which is useful for test
56
+ test_files: []
57
+