mediawiki-gateway 0.3.1 → 0.3.2
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.
- data/lib/media_wiki.rb +1 -1
- data/lib/media_wiki/utils.rb +11 -0
- data/mediawiki-gateway.gemspec +1 -1
- data/spec/utils_spec.rb +14 -0
- metadata +3 -3
data/lib/media_wiki.rb
CHANGED
data/lib/media_wiki/utils.rb
CHANGED
@@ -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:
|
data/mediawiki-gateway.gemspec
CHANGED
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jani Patokallio
|