exempla-atomic 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 6
2
+ :patch: 7
3
3
  :major: 0
4
4
  :minor: 0
data/lib/atomic/entry.rb CHANGED
@@ -1,24 +1,18 @@
1
- require 'rubygems'
2
- require 'nokogiri'
3
1
  require 'time'
2
+ require 'activesupport'
4
3
 
5
4
  module Atomic
6
5
 
7
6
  class Entry
8
7
 
8
+ attr_accessor :id, :title, :categories, :created_at, :updated_at, :content
9
+
9
10
  class << self
10
11
 
11
12
  def parse(data)
12
13
  entry = new
13
14
  doc = data.kind_of?(Nokogiri::XML::Element) ? data : Nokogiri.XML(data, nil, nil, Nokogiri::XML::PARSE_RECOVER + Nokogiri::XML::PARSE_NOBLANKS)
14
15
 
15
- # puts("================================================================")
16
- # puts("XML")
17
- # puts("================================================================")
18
- # puts(doc.inspect)
19
- # puts("================================================================")
20
-
21
-
22
16
  entry_node = doc.xpath('//atom:entry', NAMESPACES).first
23
17
 
24
18
  entry.id = entry_node.xpath('atom:id', NAMESPACES).first.text
@@ -51,33 +45,20 @@ module Atomic
51
45
  entry.categories << {:term => category_node['term'], :scheme => category_node['scheme']}
52
46
  end
53
47
 
54
- # puts("================================================================")
55
- # puts("Entry")
56
- # puts("================================================================")
57
- # puts(entry.inspect)
58
- # puts("================================================================")
59
-
60
48
  entry
61
49
  end
62
50
 
63
51
  end
64
52
 
65
- attr_accessor :id, :title, :categories, :content, :created_at, :updated_at
66
-
67
53
  def initialize(params = {})
68
-
69
- # puts("================================================================")
70
- # puts(" Params")
71
- # puts("================================================================")
72
- # puts(params.inspect)
73
- # puts("================================================================")
74
-
54
+ params.symbolize_keys!
55
+ params.assert_valid_keys(:title, :id, :categories, :created_at, :updated_at, :content)
75
56
  @title = params[:title]
76
57
  @id = params[:id]
77
- @categories = params[:categories]
78
- @content = params[:content]
58
+ @categories = params[:categories] || []
79
59
  @created_at = params[:created_at].nil? ? Time.now : Time.parse(params[:created_at])
80
60
  @updated_at = params[:updated_at].nil? ? @created_at : Time.parse(params[:updated_at])
61
+ @content = params[:content]
81
62
  end
82
63
 
83
64
  def to_hash
@@ -85,12 +66,25 @@ module Atomic
85
66
  :id => @id,
86
67
  :title => @title,
87
68
  :categories => @categories,
88
- :content => @content,
89
69
  :created_at => @created_at,
90
- :updated_at => @updated_at
70
+ :updated_at => @updated_at,
71
+ :content => @content
91
72
  }
92
73
  end
93
74
 
75
+ # def method_missing(method_symbol, *arguments)
76
+ # method_name = method_symbol.to_s
77
+ # case method_name[-1..-1]
78
+ # when "="
79
+ # @attributes[method_name[0..-2]] = arguments.first
80
+ # when "?"
81
+ # @attributes[method_name[0..-2]] == true
82
+ # else
83
+ # # Returns nil on failure so forms will work
84
+ # @attributes.has_key?(method_name) ? @attributes[method_name] : nil
85
+ # end
86
+ # end
87
+
94
88
  end
95
89
 
96
90
  end
@@ -12,11 +12,6 @@ module Atomic
12
12
  workspace_node = doc.xpath('//app:workspace', NAMESPACES).first
13
13
  workspace.title = workspace_node.xpath('atom:title', NAMESPACES).first.text
14
14
  workspace_node.xpath('app:collection', NAMESPACES).each do |collection_node|
15
- # puts "+++++++++\n"
16
- # puts collection_node.inspect
17
- # puts "=========\n"
18
- # puts collection_node.xpath('//app:collection', NAMESPACES)
19
- # puts "---------\n"
20
15
  workspace.collections << Collection.parse(collection_node)
21
16
  end
22
17
  workspace
data/lib/atomic.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/atomic/service'
2
2
  require File.dirname(__FILE__) + '/atomic/feed'
3
3
  require File.dirname(__FILE__) + '/atomic/entry'
4
+ require File.dirname(__FILE__) + '/atomic/extensions'
4
5
 
5
6
  Atomic::NAMESPACES = { "xmlns:atom" => "http://www.w3.org/2005/Atom",
6
7
  "xmlns:app" => "http://www.w3.org/2007/app",
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'spec'
2
2
 
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
4
 
5
- require 'atomic'
5
+ require File.dirname(__FILE__) + '/../lib/atomic'
6
6
 
7
7
  Spec::Runner.configure do |config|
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exempla-atomic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darrin Wortlehock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-11 00:00:00 -08:00
12
+ date: 2009-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -26,8 +26,15 @@ files:
26
26
  - lib/atomic.rb
27
27
  - lib/atomic
28
28
  - lib/atomic/service.rb
29
+ - lib/atomic/extensions
30
+ - lib/atomic/extensions/cirrus.rb
31
+ - lib/atomic/extensions/cirrus
32
+ - lib/atomic/extensions/cirrus/announcement.rb
33
+ - lib/atomic/extensions/cirrus/base.rb
34
+ - lib/atomic/extensions/cirrus/news.rb
35
+ - lib/atomic/extensions/cirrus/event.rb
29
36
  - lib/atomic/entry.rb
30
- - lib/atomic/category.rb
37
+ - lib/atomic/extensions.rb
31
38
  - lib/atomic/feed.rb
32
39
  - spec/spec.opts
33
40
  - spec/fixtures