sched 0.0.6 → 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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTQzNjljMGM3N2Q5ZWIyN2JmZmI2MzhiYWFmOTgxZjdhNzkxZWQ1Mw==
5
+ data.tar.gz: !binary |-
6
+ MmI4ZmQ2ZDU2YTI4ZDMxYTIzN2RlN2NiYTk1ZDdhYjg2NzA4MTQwOA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTRiYjA5OWRjZjhkMjE2ZDUyNDIwYzEyMWQ4MGE0MGZjZGE1NWQ3YTU1NGNi
10
+ ZmQxYTE2OTk4YzYyZWNhNmM3OWYxMGYyMzZkMjZmYjc0NWUwM2NlNDU0NDJk
11
+ OGQ0ZTgzNGM4MmQ4NjRiNWQzMWM4YzNhZGY3ZGNhNzcyNThmOTc=
12
+ data.tar.gz: !binary |-
13
+ NDBlZTM3YWQxNzM3ODUxMmE1ZmE3ZTUxOTRjOTlhMmQwMTdmMzE1ZWEzZjll
14
+ ZjI5MWUzZDY3MTZhMTFjZmE4NjczYzg0ZTdiYWVlOTkyZjAxYjJmYjJmODA5
15
+ M2FjYTA2YTM5YTkyOTM2MGVjNTRkYzI4NDEzYzcwODZjOTk0YjA=
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sched (0.1.1)
5
+ curb
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ curb (0.8.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ sched!
data/lib/sched/client.rb CHANGED
@@ -1,52 +1,56 @@
1
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.strip.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
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(session_key)
9
+ event = Sched::Event.new(session_key, self)
10
+ if event.exists?
11
+ event = self.events.select{|e| e.session_key == session_key}.first
12
+ end
13
+ event
14
+ end
15
+
16
+ def events
17
+ unless @events
18
+ results = FasterCSV.parse(request('session/list', nil, :get))
19
+ attributes = results.shift.map{|a| a.strip.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[:session_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.new(url)
43
+ c.headers["User-Agent"] = "sched-gem"
44
+ c.http_post(post_fields)
45
+ output = c.body_str
46
+ elsif method == :get
47
+ get_attributes = data.map{|key, value| "#{key}=#{value}" }.join("&")
48
+ c = Curl::Easy.new("#{url}?#{get_attributes}")
49
+ c.headers["User-Agent"] = "sched-gem"
50
+ c.perform
51
+ output = c.body_str
52
+ end
53
+ output
54
+ end
55
+ end
56
+ end
data/lib/sched/event.rb CHANGED
@@ -1,67 +1,67 @@
1
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
2
+ class Event
3
+ SCHED_ATTRIBUTES = [
4
+ # Required
5
+ :session_key, :name, :session_start, :session_end, :session_type,
6
+ # Optional
7
+ :session_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
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
12
+ def initialize(session_key, client=nil)
13
+ @session_key = session_key
14
+ @client = client
15
+ end
20
16
 
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
17
+ def get_attribute(key)
18
+ self.send("#{key}")
19
+ end
50
20
 
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
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('session/add', self.data)
53
+ end
54
+
55
+ def update
56
+ self.client.request('session/mod', self.data)
57
+ end
58
+
59
+ def exists?
60
+ client.events.map{|e| e.session_key}.include?(self.session_key) ? true : false
61
+ end
62
+
63
+ def destroy
64
+ self.client.request('session/del', {:session_key => self.session_key})
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ module Sched
2
+ unless Sched.const_defined?('VERSION')
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
data/lib/sched.rb CHANGED
@@ -2,4 +2,4 @@ require 'curb'
2
2
  require 'fastercsv'
3
3
 
4
4
  require 'sched/client'
5
- require 'sched/event'
5
+ require 'sched/event'
data/sched.gemspec CHANGED
@@ -1,62 +1,25 @@
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 -*-
1
+ # encoding: utf-8
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "sched/version"
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{sched}
8
- s.version = "0.0.6"
7
+ s.name = 'sched'
8
+ s.version = Sched::VERSION
9
+ s.date = '2014-01-20'
10
+ s.summary = "SCHED* (http://sched.org) API client library for Ruby"
11
+ s.description = "SCHED* (http://sched.org) API client library for Ruby"
12
+ s.authors = ["Inge Jørgensen"]
13
+ s.email = 'inge@manualdesign.no'
14
+ s.homepage = 'http://github.com/elektronaut/sched'
15
+ s.license = 'MIT'
16
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
9
17
 
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{2011-01-20}
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"]
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
35
21
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
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
22
 
47
- if Gem::Version.new(Gem::VERSION) >= 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
23
+ s.add_dependency 'curb'
24
+ s.add_dependency 'fastercsv'
61
25
  end
62
-
metadata CHANGED
@@ -1,121 +1,86 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sched
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
11
5
  platform: ruby
12
- authors:
13
- - "Inge J\xC3\xB8rgensen"
6
+ authors:
7
+ - Inge Jørgensen
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-01-20 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: thoughtbot-shoulda
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
36
14
  name: curb
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
47
20
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: fastercsv
51
21
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastercsv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
61
34
  type: :runtime
62
- version_requirements: *id003
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
63
41
  description: SCHED* (http://sched.org) API client library for Ruby
64
42
  email: inge@manualdesign.no
65
43
  executables: []
66
-
67
44
  extensions: []
68
-
69
- extra_rdoc_files:
70
- - LICENSE
71
- - README.rdoc
72
- files:
73
- - .document
45
+ extra_rdoc_files: []
46
+ files:
74
47
  - .gitignore
48
+ - Gemfile
49
+ - Gemfile.lock
75
50
  - LICENSE
76
51
  - README.rdoc
77
- - Rakefile
78
- - VERSION
79
52
  - lib/sched.rb
80
53
  - lib/sched/client.rb
81
54
  - lib/sched/event.rb
55
+ - lib/sched/version.rb
82
56
  - sched.gemspec
83
57
  - test/helper.rb
84
58
  - test/test_sched.rb
85
- has_rdoc: true
86
59
  homepage: http://github.com/elektronaut/sched
87
- licenses: []
88
-
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
89
63
  post_install_message:
90
- rdoc_options:
91
- - --charset=UTF-8
92
- require_paths:
64
+ rdoc_options: []
65
+ require_paths:
93
66
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: 1.8.7
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
112
77
  requirements: []
113
-
114
78
  rubyforge_project:
115
- rubygems_version: 1.3.7
79
+ rubygems_version: 2.1.4
116
80
  signing_key:
117
- specification_version: 3
118
- summary: SCHED* API client library for Ruby
119
- test_files:
81
+ specification_version: 4
82
+ summary: SCHED* (http://sched.org) API client library for Ruby
83
+ test_files:
120
84
  - test/helper.rb
121
85
  - test/test_sched.rb
86
+ has_rdoc:
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/Rakefile DELETED
@@ -1,54 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
1
- 0.0.6