xbel 0.1.1 → 0.1.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/.document CHANGED
@@ -1,4 +1,4 @@
1
- README.rdoc
1
+ README.markdown
2
2
  lib/**/*.rb
3
3
  bin/*
4
4
  features/**/*.feature
data/README.markdown CHANGED
@@ -7,6 +7,16 @@ development.
7
7
 
8
8
  gem install xbel
9
9
 
10
+ ## Use
11
+
12
+ require 'rubygems'
13
+ require 'xbel'
14
+
15
+ xbel = XBEL.parse File.read('complex.xbel')
16
+
17
+ with_aliases = true # TODO...
18
+ xbel.root.bookmarks(with_aliases).each { |bm| system 'open', bm.href }
19
+
10
20
  ### Note on Patches/Pull Requests
11
21
 
12
22
  1. Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -2,53 +2,63 @@ module Nokogiri::Decorators::XBEL
2
2
  module Folder
3
3
  include Entry
4
4
 
5
+ # Returns an instance of NodeSet with all valid children for this folder.
5
6
  def entries
6
7
  xpath './alias', './bookmark', './folder', './separator'
7
8
  end
9
+ # Returns an instance of NodeSet with all aliases for this folder.
8
10
  def aliases
9
11
  xpath './alias'
10
12
  end
13
+ # Returns an instance of NodeSet with all bookmarks for this folder.
11
14
  def bookmarks
12
15
  xpath './bookmark'
13
16
  end
17
+ # Returns an instance of NodeSet with all folders for this folder.
14
18
  def folders
15
19
  xpath './folder'
16
20
  end
17
21
 
22
+ # Returns true.
18
23
  def folder?
19
24
  true
20
25
  end
21
26
 
27
+ # Adds a entry and sets added attribute.
22
28
  def add_child(node)
23
29
  node.added = Date.today if node.is_a? Entry
24
30
  super
25
31
  end
26
32
 
33
+ # Builds a bookmark with given attributes and add it.
27
34
  def build_bookmark(attributes = {}, &block)
28
35
  node = Nokogiri::XML::Node.new('bookmark', document)
29
36
  assign_to node, attributes
30
37
 
31
38
  add_child node
32
39
  end
40
+ # Builds a folder with given attributes and add it.
33
41
  def build_folder(attributes = {}, &block)
34
42
  node = Nokogiri::XML::Node.new('folder', document)
35
43
  assign_to node, attributes
36
44
 
37
45
  add_child node
38
46
  end
47
+ # Builds an alias with given attributes and add it.
39
48
  def build_alias(ref)
40
49
  node = Nokogiri::XML::Node.new('alias', document)
41
50
  node.ref = (Entry === ref) ? ref.id : ref.to_s
42
51
 
43
52
  add_child node
44
53
  end
54
+ # Builds a seperator with given attributes and add it.
45
55
  def add_seperator
46
56
  add_child Nokogiri::XML::Node.new('separator', document)
47
57
  end
48
58
 
49
59
  protected
50
60
 
51
- def assign_to(node, attributes)
61
+ def assign_to(node, attributes) #:nodoc:
52
62
  attributes.each do |key, value|
53
63
  node.send "#{ key }=", value
54
64
  end
data/lib/xbel/writer.rb CHANGED
@@ -1,4 +1,4 @@
1
- class XBEL::Writer
1
+ class XBEL::Writer #:nodoc:
2
2
  DOCTYPE = '<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">'
3
3
 
4
4
  attr_reader :document, :lockfile_path, :path
data/lib/xbel.rb CHANGED
@@ -11,6 +11,7 @@ class XBEL < Nokogiri::XML::Document
11
11
 
12
12
  autoload :Writer, 'xbel/writer'
13
13
 
14
+ # Use <tt>XBEL.parse(string)</tt> create an instance.
14
15
  def initialize(*args)
15
16
  super
16
17
  decorators(Nokogiri::XML::Node) << Nokogiri::Decorators::XBEL
@@ -19,14 +20,18 @@ class XBEL < Nokogiri::XML::Document
19
20
  # self.root = '<xbel version="1.0"></xbel>'
20
21
  end
21
22
 
23
+ # Returns an array of version numbers.
22
24
  def version
23
25
  root.attribute('version').value.split('.').map { |n| n.to_i }
24
26
  end
27
+ # Sets version numbers.
25
28
  def version=(*numbers)
26
29
  root.attribute('version').value = numbers.join '.'
27
30
  end
28
31
 
32
+ # Writes XBEL to path.
29
33
  def write(path)
34
+ # TODO: should start locking write process
30
35
  Writer.new(self, path).write
31
36
  end
32
37
 
data/xbel.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{xbel}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Florian A\303\237mann"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xbel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Florian A\xC3\x9Fmann"