atom-tools 2.0.0 → 2.0.1

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/Rakefile CHANGED
@@ -7,7 +7,7 @@ require "spec/rake/spectask"
7
7
  require "rake/clean"
8
8
 
9
9
  NAME = "atom-tools"
10
- VERS = "2.0.0"
10
+ VERS = "2.0.1"
11
11
 
12
12
  # the following from markaby-0.5's tools/rakehelp
13
13
  def setup_tests
@@ -38,6 +38,9 @@ def setup_gem(pkg_name, pkg_version, author, summary, dependencies, test_file)
38
38
  s.version = pkg_version
39
39
  s.platform = Gem::Platform::RUBY
40
40
  s.author = author
41
+ s.email = 'whateley@gmail.com'
42
+ s.homepage = 'http://code.necronomicorp.com/atom-tools'
43
+ s.rubyforge_project = 'ibes'
41
44
  s.summary = summary
42
45
  s.test_file = test_file
43
46
  s.has_rdoc = true
data/bin/atom-cp CHANGED
File without changes
data/bin/atom-purge CHANGED
File without changes
data/bin/atom-show ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/ruby
2
+
3
+ =begin
4
+ Usage: atom-show [options] source
5
+ displays a feed human-readably
6
+
7
+ 'source' can be a path on the local filesystem, the
8
+ URL of an Atom Collection or '-' for stdin.
9
+ =end
10
+
11
+ require 'atom/tools'
12
+ include Atom::Tools
13
+
14
+ def parse_options
15
+ options = { }
16
+
17
+ opts = OptionParser.new do |opts|
18
+ opts.banner = <<END
19
+ Usage: #{$0} [options] [source]
20
+ displays a feed human-readably
21
+
22
+ 'source' can be a path on the local filesystem, the
23
+ URL of an Atom Collection or '-' for stdin.
24
+ END
25
+
26
+ opts.on('-c', '--complete', "Follow previous and next links in the source feed to obtain the entire logical feed") do
27
+ options[:complete] = true
28
+ end
29
+
30
+ opts.on('-n', '--content [MAX-LENGTH]', "Display max-length words of each entry's content") do |length|
31
+ options[:content] = length ? length.to_i : 0
32
+ end
33
+
34
+ atom_options opts, options
35
+ end
36
+
37
+ opts.parse!(ARGV)
38
+
39
+ if ARGV.length > 1
40
+ puts opts
41
+ exit
42
+ end
43
+
44
+ options
45
+ end
46
+
47
+ if __FILE__ == $0
48
+ require 'optparse'
49
+
50
+ options = parse_options
51
+
52
+ source = ARGV[0]
53
+ source ||= '-'
54
+
55
+ entries = parse_input source, options
56
+
57
+ entries.each do |e|
58
+ puts e.title
59
+
60
+ if options[:content]
61
+ if options[:content].zero?
62
+ puts e.content.to_s
63
+ else
64
+ puts e.content.to_s.split(' ')[0,options[:content]].join(' ')
65
+ end
66
+ end
67
+
68
+ puts
69
+ end
70
+ end
@@ -70,11 +70,22 @@ module Atom
70
70
  def initialize(href = nil, http = Atom::HTTP.new)
71
71
  super()
72
72
 
73
+ @http = http
74
+
73
75
  if href
74
76
  self.href = href
75
77
  end
78
+ end
76
79
 
77
- @http = http
80
+ def self.parse xml, base = ''
81
+ e = super
82
+
83
+ # URL absolutization
84
+ if !e.base.empty? and e.href
85
+ e.href = (e.base.to_uri + e.href).to_s
86
+ end
87
+
88
+ e
78
89
  end
79
90
 
80
91
  # POST an entry to the collection, with an optional slug
data/lib/atom/element.rb CHANGED
@@ -596,7 +596,7 @@ module Atom # :nodoc:
596
596
  e = super
597
597
 
598
598
  # URL absolutization
599
- if e.base and e.href
599
+ if !e.base.empty? and e.href
600
600
  e.href = (e.base.to_uri + e.href).to_s
601
601
  end
602
602
 
data/lib/atom/feed.rb CHANGED
@@ -93,7 +93,7 @@ module Atom
93
93
  end
94
94
 
95
95
  # gets everything in the logical feed (could be a lot of stuff)
96
- # (see <http://www.ietf.org/internet-drafts/draft-nottingham-atompub-feed-history-05.txt>)
96
+ # (see RFC 5005)
97
97
  def get_everything!
98
98
  self.update!
99
99
 
data/lib/atom/http.rb CHANGED
@@ -16,7 +16,7 @@ class String # :nodoc:
16
16
  end
17
17
 
18
18
  module Atom
19
- UA = "atom-tools 2.0.0"
19
+ UA = "atom-tools 2.0.1"
20
20
 
21
21
  module DigestAuth
22
22
  CNONCE = Digest::MD5.hexdigest("%x" % (Time.now.to_i + rand(65535)))
data/lib/atom/text.rb CHANGED
@@ -27,10 +27,20 @@ module Atom
27
27
 
28
28
  if x.is_a? REXML::Element
29
29
  if type == 'xhtml'
30
- x = x.elements['div']
30
+ x = e.get_elem x, XHTML::NS, 'div'
31
+
31
32
  raise Atom::ParseError, 'xhtml content needs div wrapper' unless x
32
33
 
33
34
  c = x.dup
35
+
36
+ unless x.prefix.empty?
37
+ # content has a namespace prefix, strip prefixes from it and all
38
+ # XHTML children
39
+
40
+ REXML::XPath.each(c, './/xhtml:*', 'xhtml' => XHTML::NS) do |x|
41
+ x.name = x.name
42
+ end
43
+ end
34
44
  else
35
45
  c = x[0] ? x[0].value : nil
36
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atom-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Taylor
@@ -9,12 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-28 00:00:00 -06:00
12
+ date: 2008-05-13 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
16
  description:
17
- email:
17
+ email: whateley@gmail.com
18
18
  executables: []
19
19
 
20
20
  extensions: []
@@ -28,6 +28,7 @@ files:
28
28
  - setup.rb
29
29
  - bin/atom-grep
30
30
  - bin/atom-post
31
+ - bin/atom-show
31
32
  - bin/atom-purge
32
33
  - bin/atom-cp
33
34
  - test/test_constructs.rb
@@ -54,7 +55,7 @@ files:
54
55
  - lib/atom/element.rb
55
56
  - lib/atom/http.rb
56
57
  has_rdoc: true
57
- homepage:
58
+ homepage: http://code.necronomicorp.com/atom-tools
58
59
  post_install_message:
59
60
  rdoc_options: []
60
61
 
@@ -74,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  version:
75
76
  requirements: []
76
77
 
77
- rubyforge_project:
78
- rubygems_version: 1.0.1
78
+ rubyforge_project: ibes
79
+ rubygems_version: 1.1.1
79
80
  signing_key:
80
81
  specification_version: 2
81
82
  summary: Tools for working with Atom Entries, Feeds and Collections