mediawiki-gateway 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/media_wiki.rb CHANGED
@@ -3,5 +3,5 @@ require File.dirname(__FILE__) + '/media_wiki/utils'
3
3
  require File.dirname(__FILE__) + '/media_wiki/gateway'
4
4
 
5
5
  module MediaWiki
6
- VERSION = "0.3.1"
6
+ VERSION = "0.3.2"
7
7
  end
@@ -1,6 +1,17 @@
1
1
  module MediaWiki
2
2
  class << self
3
3
 
4
+ # Extract base name. If there are no subpages, return page name.
5
+ #
6
+ # Examples:
7
+ # get_base_name("Namespace:Foo/Bar/Baz") -> "Namespace:Foo"
8
+ # get_base_name("Namespace:Foo") -> "Namespace:Foo"
9
+ #
10
+ # [title] Page name string in Wiki format
11
+ def get_base_name(title)
12
+ title.split('/').first if title
13
+ end
14
+
4
15
  # Extract path leading up to subpage. If title does not contain a subpage, returns nil.
5
16
  #
6
17
  # Examples:
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mediawiki-gateway}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jani Patokallio"]
data/spec/utils_spec.rb CHANGED
@@ -30,6 +30,20 @@ describe MediaWiki do
30
30
  end
31
31
  end
32
32
 
33
+ describe '.get_base_name' do
34
+ it "should return page's base name if there are subpages" do
35
+ MediaWiki.get_base_name('namespace:root/path/subpage').should == 'namespace:root'
36
+ end
37
+
38
+ it "should return entire name if there are no subpages" do
39
+ MediaWiki.get_base_name('namespace:root').should == 'namespace:root'
40
+ end
41
+
42
+ it "should pass through nil" do
43
+ MediaWiki.get_base_name(nil).should be_nil
44
+ end
45
+ end
46
+
33
47
  describe '.wiki_to_uri' do
34
48
 
35
49
  it "should underscore spaces" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-gateway
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jani Patokallio