dmoz_sax_doc 0.0.2 → 0.0.3

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dmoz_sax_doc (0.0.2)
4
+ dmoz_sax_doc (0.0.3)
5
5
  json (~> 1.7)
6
6
  nokogiri (~> 1.5)
7
7
 
@@ -1,9 +1,16 @@
1
1
  module DmozSax
2
2
  class Alias
3
- attr_accessor :path, :title
3
+ attr_accessor :path
4
4
  def initialize path_str
5
5
  @path = DmozSax::Path.new path_str
6
- @title = @path.name
6
+ end
7
+
8
+ def title
9
+ @path.name
10
+ end
11
+
12
+ def title= str
13
+ @path.name = str
7
14
  end
8
15
  end
9
16
  end
data/lib/dmoz_sax/path.rb CHANGED
@@ -27,5 +27,13 @@ module DmozSax
27
27
  def to_s
28
28
  @path.join('/')
29
29
  end
30
+
31
+ def parent_path
32
+ if @path.length == 0
33
+ nil
34
+ else
35
+ @path[0...-1].join('/')
36
+ end
37
+ end
30
38
  end
31
39
  end
@@ -1,3 +1,3 @@
1
1
  module DmozSax
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/path_spec.rb CHANGED
@@ -37,4 +37,24 @@ describe DmozSax::Path do
37
37
  expect { path[0] = 'Bob' }.to raise_error
38
38
  end
39
39
  end
40
+
41
+ context "getting parent path" do
42
+ it "returns parent path" do
43
+ path = DmozSax::Path.new 'This/Topic/Path'
44
+ path.parent_path.should == 'This/Topic'
45
+ end
46
+
47
+ it "has not parent path if top level path" do
48
+ path = DmozSax::Path.new ''
49
+ path.parent_path.should be_nil
50
+
51
+ path = DmozSax::Path.new 'Top'
52
+ path.parent_path.should be_nil
53
+ end
54
+
55
+ it "follows the same rules removing index categories" do
56
+ path = DmozSax::Path.new 'Top/Topic/A/Path'
57
+ path.parent_path.should == 'Topic'
58
+ end
59
+ end
40
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmoz_sax_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-28 00:00:00.000000000 Z
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri