c3s 0.2.0 → 0.2.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/Manifest CHANGED
@@ -8,5 +8,6 @@ lib/component.rb
8
8
  lib/component_connection.rb
9
9
  lib/configreader.rb
10
10
  lib/databaseadapter.rb
11
+ lib/model.rb
11
12
  lib/nodetracker.rb
12
13
  lib/publisher.rb
data/README.rdoc CHANGED
@@ -0,0 +1,15 @@
1
+ # The program takes an initial word or phrase from
2
+ # the command line (or in the absence of a
3
+ # parameter from the first line of standard
4
+ # input). In then reads successive words or
5
+ # phrases from standard input and reports whether
6
+ # they are angrams of the first word.
7
+ #
8
+ # Author:: Dave Thomas (mailto:dave@x.y)
9
+ # Copyright:: Copyright (c) 2002 The Pragmatic Programmers, LLC
10
+ # License:: Distributes under the same terms as Ruby
11
+
12
+ # This class holds the letters in the original
13
+ # word or phrase. The is_anagram? method allows us
14
+ # to test if subsequent words or phrases are
15
+ # anagrams of the original.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('c3s', '0.2.0') do |p|
5
+ Echoe.new('c3s', '0.2.2') do |p|
6
6
  p.description = "C3s library gem."
7
7
  p.url = "http://github.com/rikas/c3s"
8
8
  p.author = "Ricardo Otero"
data/c3s.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{c3s}
5
- s.version = "0.2.0"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ricardo Otero"]
9
- s.date = %q{2009-11-30}
9
+ s.date = %q{2009-12-03}
10
10
  s.description = %q{C3s library gem.}
11
11
  s.email = %q{oterosantos@gmail.com}
12
- s.extra_rdoc_files = ["README.rdoc", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
13
- s.files = ["README.rdoc", "Rakefile", "c3s.gemspec", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/nodetracker.rb", "lib/publisher.rb", "Manifest"]
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
13
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "c3s.gemspec", "lib/c3s.rb", "lib/c3s_logger.rb", "lib/component.rb", "lib/component_connection.rb", "lib/configreader.rb", "lib/databaseadapter.rb", "lib/model.rb", "lib/nodetracker.rb", "lib/publisher.rb"]
14
14
  s.homepage = %q{http://github.com/rikas/c3s}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "C3s", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
data/lib/c3s.rb CHANGED
@@ -1,3 +1,16 @@
1
+ # = Context Content Consuming & Sharing
2
+ # This is a small library to make context entities on c3s project
3
+ # it is basically a set of classes with some work done so that
4
+ # the code on providers and consumers can be as DRY as possible.
5
+ #
6
+ # The library is installed and used as a ruby gem in 3 steps
7
+ # 1. sudo gem source -a http://gemcutter.org
8
+ # 2. sudo gem install c3s
9
+ # 3. require "c3s"
10
+ #
11
+ # Author:: Ricardo Otero dos Santos (mailto:oterosantos@gmail.com)
12
+ # Copyright:: Copyright (c) 2009. All rights reserved.
13
+
1
14
  require 'component_connection'
2
15
  require 'component'
3
16
  require 'configreader'
data/lib/component.rb CHANGED
@@ -17,7 +17,8 @@ module C3s
17
17
  attr_accessor :config
18
18
 
19
19
  ##
20
- # Initializes the jabber component
20
+ # Initializes the jabber component with
21
+ # a configuration hash read with ConfigReader
21
22
  #
22
23
  # config:: [Hash] configuration hash
23
24
  def initialize(config)
@@ -41,7 +42,7 @@ module C3s
41
42
 
42
43
  ##
43
44
  # Starts listening for packets and waits for activity. Also
44
- # provides a callback named handle_iq for especific components
45
+ # provides a callback named *handle_iq* for especific components
45
46
  # to use.
46
47
  def start
47
48
  super()
data/lib/model.rb ADDED
@@ -0,0 +1,46 @@
1
+ require 'active_record'
2
+
3
+ module C3s
4
+ class Model < ActiveRecord::Base
5
+ ##
6
+ # Attributes ignored and not included on model xml by default
7
+ IGNORE_ATTR = ["created_at", "updated_at", "id", "jid"]
8
+
9
+ ##
10
+ # Returns the class name for this model without module name
11
+ def _class_name
12
+ @class_name ||= self.class.name.split("::").last.downcase
13
+ end
14
+
15
+ ##
16
+ # Gets the model xml to include in a packet.
17
+ # options:: [Hash] options
18
+ def to_xml(options={})
19
+ xml = first_element(options)
20
+ self.attributes.each do |key, val|
21
+ if !IGNORE_ATTR.include?(key) && !key.match(/.+_id/)
22
+ xml.add REXML::Element.new(key).add_text(value.to_s)
23
+ end
24
+ end
25
+ xml
26
+ end
27
+
28
+ ##
29
+ # Returns the first element for the model xml
30
+ def first_element(options={})
31
+ if options[:only_childs] == true
32
+ name = self._class_name
33
+ name = name.pluralize if options[:plural]
34
+ first = REXML::Element.new(name)
35
+ else
36
+ first = options[:parent]
37
+ end
38
+ end
39
+
40
+ ##
41
+ # Returns a default namespace based on class name
42
+ def xmlns
43
+ "http://c3s.hng.av.it.pt/#{self._class_name}"
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c3s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-30 00:00:00 +00:00
12
+ date: 2009-12-03 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,9 +27,11 @@ extra_rdoc_files:
27
27
  - lib/component_connection.rb
28
28
  - lib/configreader.rb
29
29
  - lib/databaseadapter.rb
30
+ - lib/model.rb
30
31
  - lib/nodetracker.rb
31
32
  - lib/publisher.rb
32
33
  files:
34
+ - Manifest
33
35
  - README.rdoc
34
36
  - Rakefile
35
37
  - c3s.gemspec
@@ -39,9 +41,9 @@ files:
39
41
  - lib/component_connection.rb
40
42
  - lib/configreader.rb
41
43
  - lib/databaseadapter.rb
44
+ - lib/model.rb
42
45
  - lib/nodetracker.rb
43
46
  - lib/publisher.rb
44
- - Manifest
45
47
  has_rdoc: true
46
48
  homepage: http://github.com/rikas/c3s
47
49
  licenses: []