pandorified 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ Summary
2
+ -------
3
+
4
+ Pandorified makes it easy for your Ruby scripts to interact with chat bots hosted on Pandorabots.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ gem install pandorified
10
+
11
+ Author
12
+ ------
13
+
14
+ [Justin Workman](mailto:xtagon@gmail.com)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,36 @@
1
+ require 'rest_client'
2
+ require 'nokogiri'
3
+
4
+ module Pandorified
5
+ API_URL = 'http://www.pandorabots.com/pandora/talk-xml'
6
+
7
+ class Result
8
+ def initialize(params)
9
+ @xml = Nokogiri::XML(RestClient.post(API_URL, params))
10
+ end
11
+
12
+ def status
13
+ @xml.xpath('/result/@status').first.value.to_i
14
+ end
15
+
16
+ def botid
17
+ @xml.xpath('/result/@botid').first.value
18
+ end
19
+
20
+ def custid
21
+ @xml.xpath('/result/@custid').first.value
22
+ end
23
+
24
+ def input
25
+ @xml.xpath('/result/input').first.text
26
+ end
27
+
28
+ def that
29
+ @xml.xpath('/result/that').first.text
30
+ end
31
+
32
+ def message
33
+ @xml.xpath('/result/message').first.text
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ require 'pandorified/result'
2
+
3
+ module Pandorified
4
+ class Session
5
+ def initialize(botid, custid = nil)
6
+ @botid = botid
7
+ @custid = custid
8
+ end
9
+
10
+ def talk(input)
11
+ result = Pandorified::Result.new(botid: @botid, custid: @custid, input: input)
12
+ if result.status.zero?
13
+ @custid ||= result.custid
14
+ result.that
15
+ else
16
+ raise "Pandorabots returned status #{result.status}: #{result.message}"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Pandorified
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'pandorified/version'
2
+ require 'pandorified/session'
@@ -0,0 +1,20 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'pandorified/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pandorified'
7
+ spec.version = Pandorified::VERSION
8
+ spec.authors = 'Justin Workman'
9
+ spec.email = 'xtagon@gmail.com'
10
+ spec.summary = 'A Ruby client for the Pandorabots API.'
11
+ spec.description = 'Pandorified makes it easy for your Ruby scripts to interact with chat bots hosted on Pandorabots.'
12
+
13
+ spec.files = `git ls-files`.split("\n")
14
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.add_runtime_dependency 'rest-client'
19
+ spec.add_runtime_dependency 'nokogiri'
20
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pandorified
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Justin Workman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-11 00:00:00.000000000 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rest-client
17
+ requirement: &7625680 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *7625680
26
+ - !ruby/object:Gem::Dependency
27
+ name: nokogiri
28
+ requirement: &7625000 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *7625000
37
+ description: Pandorified makes it easy for your Ruby scripts to interact with chat
38
+ bots hosted on Pandorabots.
39
+ email: xtagon@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - README.md
47
+ - Rakefile
48
+ - lib/pandorified.rb
49
+ - lib/pandorified/result.rb
50
+ - lib/pandorified/session.rb
51
+ - lib/pandorified/version.rb
52
+ - pandorified.gemspec
53
+ has_rdoc: true
54
+ homepage:
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.6.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: A Ruby client for the Pandorabots API.
78
+ test_files: []