sched 0.0.5

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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Manual design
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = SCHED*
2
+
3
+ Thirt-party Ruby client library for the SCHED* API. See http://sched.org
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2010 Manual design. See LICENSE for details.
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "sched"
8
+ gem.summary = %Q{SCHED* API client library for Ruby}
9
+ gem.description = %Q{SCHED* (http://sched.org) API client library for Ruby}
10
+ gem.email = "inge@manualdesign.no"
11
+ gem.homepage = "http://github.com/elektronaut/sched"
12
+ gem.authors = ["Inge Jørgensen"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency "curb"
15
+ gem.add_dependency "fastercsv"
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+ task :test => :check_dependencies
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "sched #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.5
@@ -0,0 +1,5 @@
1
+ require 'curb'
2
+ require 'fastercsv'
3
+
4
+ require 'sched/client'
5
+ require 'sched/event'
@@ -0,0 +1,52 @@
1
+ module Sched
2
+ class Client
3
+ attr_accessor :conference, :api_key
4
+ def initialize(conference, api_key)
5
+ @conference, @api_key = conference, api_key
6
+ end
7
+
8
+ def event(event_key)
9
+ event = Sched::Event.new(event_key, self)
10
+ if event.exists?
11
+ event = self.events.select{|e| e.event_key == event_key}.first
12
+ end
13
+ event
14
+ end
15
+
16
+ def events
17
+ unless @events
18
+ results = FasterCSV.parse(request('event/list', nil, :get))
19
+ attributes = results.shift.map{|a| a.to_sym}
20
+ @events = results.map do |row|
21
+ row_hash = {}
22
+ attributes.each_with_index do |a, i|
23
+ row_hash[a] = row[i]
24
+ end
25
+ event = Sched::Event.new(row_hash[:event_key], self).configure(row_hash)
26
+ end
27
+ end
28
+ @events
29
+ end
30
+
31
+ def api_url
32
+ "http://#{@conference}.sched.org/api"
33
+ end
34
+
35
+ def request(sub_url, data={}, method = :post)
36
+ data ||= {}
37
+ data.merge!({:api_key => @api_key})
38
+ url = "#{api_url}/#{sub_url}"
39
+ output = nil
40
+ if method == :post
41
+ post_fields = data.map{|key, value| Curl::PostField.content(key.to_s, value)}
42
+ c = Curl::Easy.http_post(url, post_fields)
43
+ output = c.body_str
44
+ elsif method == :get
45
+ get_attributes = data.map{|key, value| "#{key}=#{value}" }.join("&")
46
+ c = Curl::Easy.perform("#{url}?#{get_attributes}")
47
+ output = c.body_str
48
+ end
49
+ output
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,67 @@
1
+ module Sched
2
+ class Event
3
+ SCHED_ATTRIBUTES = [
4
+ # Required
5
+ :event_key, :name, :event_start, :event_end, :event_type,
6
+ # Optional
7
+ :event_subtype, :description, :panelists, :url, :media_url, :venue, :address, :map, :tags, :active
8
+ ]
9
+ SCHED_ATTRIBUTES.each{ |attribute| attr_accessor attribute }
10
+ attr_accessor :client
11
+
12
+ def initialize(event_key, client=nil)
13
+ @event_key = event_key
14
+ @client = client
15
+ end
16
+
17
+ def get_attribute(key)
18
+ self.send("#{key}")
19
+ end
20
+
21
+ def configure(options={})
22
+ options.each do |key, value|
23
+ if SCHED_ATTRIBUTES.include?(key)
24
+ self.send("#{key.to_s}=", value)
25
+ end
26
+ end
27
+ self
28
+ end
29
+
30
+ def data
31
+ data = {}
32
+ SCHED_ATTRIBUTES.each do |attribute|
33
+ unless self.get_attribute(attribute) === nil
34
+ value = self.get_attribute(attribute)
35
+ value = 'Y' if value === true
36
+ value = 'N' if value === false
37
+ data[attribute] = value
38
+ end
39
+ end
40
+ data
41
+ end
42
+
43
+ def save
44
+ if self.exists?
45
+ self.update
46
+ else
47
+ self.create
48
+ end
49
+ end
50
+
51
+ def create
52
+ self.client.request('event/add', self.data)
53
+ end
54
+
55
+ def update
56
+ self.client.request('event/mod', self.data)
57
+ end
58
+
59
+ def exists?
60
+ client.events.map{|e| e.event_key}.include?(self.event_key) ? true : false
61
+ end
62
+
63
+ def destroy
64
+ self.client.request('event/del', {:event_key => self.event_key})
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sched}
8
+ s.version = "0.0.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Inge J\303\270rgensen"]
12
+ s.date = %q{2010-01-15}
13
+ s.description = %q{SCHED* (http://sched.org) API client library for Ruby}
14
+ s.email = %q{inge@manualdesign.no}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/sched.rb",
27
+ "lib/sched/client.rb",
28
+ "lib/sched/event.rb",
29
+ "sched.gemspec",
30
+ "test/helper.rb",
31
+ "test/test_sched.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/elektronaut/sched}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.5}
37
+ s.summary = %q{SCHED* API client library for Ruby}
38
+ s.test_files = [
39
+ "test/helper.rb",
40
+ "test/test_sched.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ s.add_runtime_dependency(%q<curb>, [">= 0"])
50
+ s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
53
+ s.add_dependency(%q<curb>, [">= 0"])
54
+ s.add_dependency(%q<fastercsv>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
+ s.add_dependency(%q<curb>, [">= 0"])
59
+ s.add_dependency(%q<fastercsv>, [">= 0"])
60
+ end
61
+ end
62
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'sched'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSched < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sched
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - "Inge J\xC3\xB8rgensen"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-15 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: curb
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: fastercsv
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: SCHED* (http://sched.org) API client library for Ruby
46
+ email: inge@manualdesign.no
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/sched.rb
62
+ - lib/sched/client.rb
63
+ - lib/sched/event.rb
64
+ - sched.gemspec
65
+ - test/helper.rb
66
+ - test/test_sched.rb
67
+ has_rdoc: true
68
+ homepage: http://github.com/elektronaut/sched
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: SCHED* API client library for Ruby
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/test_sched.rb