genki-merb_full_url 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,3 +2,11 @@ merb_full_url
2
2
  =============
3
3
 
4
4
  A plugin for the Merb framework that provides full_url method.
5
+
6
+ USAGE:
7
+
8
+ You can use full_url and full_resource for acquiring full URL instead of
9
+ original url and resource.
10
+
11
+ full_url(...)
12
+ full_resource(...)
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'merb-core'
5
5
  require 'merb-core/tasks/merb'
6
6
 
7
7
  GEM_NAME = "merb_full_url"
8
- GEM_VERSION = "0.0.1"
8
+ GEM_VERSION = "0.0.2"
9
9
  AUTHOR = "Genki Takiuchi"
10
10
  EMAIL = "genki@s21g.com"
11
11
  HOMEPAGE = "http://blog.s21g.com/genki"
@@ -8,6 +8,7 @@ if defined?(Merb::Plugins)
8
8
 
9
9
  Merb::BootLoader.before_app_loads do
10
10
  # require code that must be loaded before the application
11
+ require 'merb_full_url/request_ext'
11
12
  require 'merb_full_url/controller_ext'
12
13
  end
13
14
 
@@ -1,6 +1,10 @@
1
1
  class Merb::Controller
2
2
  private
3
3
  def full_url(*args, &block)
4
- URI.join("#{request.protocol}://#{request.host}", url(*args, &block))
4
+ URI.join(request.origin, url(*args, &block))
5
+ end
6
+
7
+ def full_resource(*args, &block)
8
+ URI.join(request.origin, resource(*args, &block))
5
9
  end
6
10
  end
@@ -0,0 +1,5 @@
1
+ class Merb::Request
2
+ def origin
3
+ "#{protocol}://#{host}"
4
+ end
5
+ end
@@ -5,5 +5,12 @@ describe "merb_full_url" do
5
5
  @c = Users.new({})
6
6
  @c.should be_kind_of(Merb::Controller)
7
7
  @c.private_methods.should be_include("full_url")
8
+ @c.private_methods.should be_include("full_resource")
9
+ end
10
+ end
11
+
12
+ describe "Request#origin" do
13
+ it "should be extended" do
14
+ Merb::Request.new({}).should be_respond_to(:origin)
8
15
  end
9
16
  end
@@ -4,6 +4,7 @@ require 'rubygems'
4
4
  require 'merb-core'
5
5
  require 'dm-core'
6
6
  require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
7
+ require 'merb_full_url/request_ext'
7
8
  require 'merb_full_url/controller_ext'
8
9
  require 'dm-aggregates'
9
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genki-merb_full_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Takiuchi
@@ -39,6 +39,7 @@ files:
39
39
  - lib/merb_full_url
40
40
  - lib/merb_full_url/controller_ext.rb
41
41
  - lib/merb_full_url/merbtasks.rb
42
+ - lib/merb_full_url/request_ext.rb
42
43
  - lib/merb_full_url.rb
43
44
  - spec/fixture
44
45
  - spec/fixture/app