teneo_client 0.3.0

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,22 @@
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
22
+ doc/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jacob Atzen
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,25 @@
1
+ = Teneo Client
2
+
3
+ Library for interacting with the API for Teneo.
4
+
5
+ == Configuration
6
+
7
+ Configure with:
8
+
9
+ TeneoClient.configure do |config|
10
+ config.host = "demo.novalisapp.com"
11
+ end
12
+
13
+ == Note on Patches/Pull Requests
14
+
15
+ * Fork the project.
16
+ * Make your feature addition or bug fix.
17
+ * Add tests for it. This is important so I don't break it in a
18
+ future version unintentionally.
19
+ * Commit, do not mess with rakefile, version, or history.
20
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
21
+ * Send me a pull request. Bonus points for topic branches.
22
+
23
+ == Copyright
24
+
25
+ Copyright (c) 2010 Novalis A/S. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "teneo_client"
8
+ gem.summary = %Q{Rest client to work with Teneo}
9
+ gem.description = %Q{Rest client to work with the Teneo API}
10
+ gem.email = "jacob@incremental.dk"
11
+ gem.homepage = "http://github.com/jacobat/teneo_client"
12
+ gem.authors = ["Jacob Atzen"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "config_newton", ">= 0.1.1"
15
+ gem.add_dependency "activesupport", ">= 2.3.5"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ begin
39
+ require 'sdoc'
40
+ rescue LoadError => e
41
+ puts "sdoc not found"
42
+ end
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'doc'
48
+ rdoc.title = "teneo_client #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
52
+
53
+ desc 'Upload docs to doc server'
54
+ task :upload_docs do
55
+ `rsync -az doc/ m@docs.minime.i.novalis.dk:Sites/docs/teneo_client/`
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,12 @@
1
+ require 'active_support/hash_with_indifferent_access'
2
+ require 'active_support/core_ext/hash/conversions'
3
+ require 'httparty'
4
+ require 'config_newton'
5
+
6
+ module TeneoClient
7
+ include ConfigNewton
8
+ config :host
9
+ end
10
+
11
+ require 'teneo_client/questionnaire'
12
+ require 'teneo_client/survey'
@@ -0,0 +1,50 @@
1
+ module TeneoClient
2
+ class Questionnaire
3
+ include HTTParty
4
+ format :xml
5
+
6
+ class << self
7
+ def list
8
+ init
9
+ q = get("/questionnaires.xml")
10
+ HashWithIndifferentAccess.new(q)
11
+ end
12
+
13
+ def find(id)
14
+ init
15
+ q = get("/questionnaires/#{id}.xml")["questionnaire"]
16
+ HashWithIndifferentAccess.new(q)
17
+ end
18
+
19
+ def update(id, questionnaire)
20
+ init
21
+ res = put("/questionnaires/#{id}.xml", payload(questionnaire))
22
+ raise "Error" if res.headers['status'].first != "200"
23
+ res
24
+ end
25
+
26
+ def create(questionnaire)
27
+ init
28
+ res = post("/questionnaires.xml", payload(questionnaire))
29
+ raise "Error" if res.headers['status'].first != "201"
30
+ res
31
+ end
32
+
33
+ private
34
+
35
+ def payload(questionnaire)
36
+ q = HashWithIndifferentAccess.new(questionnaire.clone)
37
+ q.delete(:id)
38
+ {
39
+ :body => q.to_xml(:root => "questionnaire"),
40
+ :headers => { "Content-Type" => "application/xml" }
41
+ }
42
+ end
43
+
44
+ def init
45
+ self.base_uri "#{TeneoClient.config.host}/survey_engine/api/"
46
+ end
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,40 @@
1
+ module TeneoClient
2
+ class Survey
3
+ include HTTParty
4
+ format :xml
5
+ base_uri "#{TeneoClient.config.host}/survey_engine/api/"
6
+
7
+ class << self
8
+
9
+ def find(id)
10
+ init
11
+ q = get("/surveys/#{id}.xml")["survey_engine_survey"]
12
+ HashWithIndifferentAccess.new(q)
13
+ end
14
+
15
+ def update(id, survey)
16
+ init
17
+ put("/surveys/#{id}.xml", payload(survey))
18
+ end
19
+
20
+ def create(survey)
21
+ init
22
+ post("/surveys.xml", payload(survey))
23
+ end
24
+
25
+ private
26
+
27
+ def payload(survey)
28
+ q = HashWithIndifferentAccess.new(survey.clone)
29
+ {
30
+ :body => q.to_xml(:root => "survey"),
31
+ :headers => { "Content-Type" => "application/xml" }
32
+ }
33
+ end
34
+
35
+ def init
36
+ self.base_uri "#{TeneoClient.config.host}/survey_engine/api/"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'teneo_client'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "TeneoClient" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,58 @@
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{teneo_client}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jacob Atzen"]
12
+ s.date = %q{2010-09-20}
13
+ s.description = %q{Rest client to work with the Teneo API}
14
+ s.email = %q{jacob@incremental.dk}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/teneo_client.rb",
26
+ "lib/teneo_client/questionnaire.rb",
27
+ "lib/teneo_client/survey.rb",
28
+ "spec/spec.opts",
29
+ "spec/spec_helper.rb",
30
+ "spec/teneo_client_spec.rb",
31
+ "teneo_client.gemspec"
32
+ ]
33
+ s.homepage = %q{http://github.com/jacobat/teneo_client}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{Rest client to work with Teneo}
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
45
+ s.add_runtime_dependency(%q<config_newton>, [">= 0.1.1"])
46
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
47
+ else
48
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
49
+ s.add_dependency(%q<config_newton>, [">= 0.1.1"])
50
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
+ s.add_dependency(%q<config_newton>, [">= 0.1.1"])
55
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
56
+ end
57
+ end
58
+
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teneo_client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.3.0
6
+ platform: ruby
7
+ authors:
8
+ - Jacob Atzen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-09-20 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: config_newton
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.1
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.5
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ description: Rest client to work with the Teneo API
49
+ email: jacob@incremental.dk
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - README.rdoc
56
+ files:
57
+ - .document
58
+ - .gitignore
59
+ - LICENSE
60
+ - README.rdoc
61
+ - Rakefile
62
+ - VERSION
63
+ - lib/teneo_client.rb
64
+ - lib/teneo_client/questionnaire.rb
65
+ - lib/teneo_client/survey.rb
66
+ - spec/spec.opts
67
+ - spec/spec_helper.rb
68
+ - spec/teneo_client_spec.rb
69
+ - teneo_client.gemspec
70
+ homepage: http://github.com/jacobat/teneo_client
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --charset=UTF-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.10
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Rest client to work with Teneo
97
+ test_files: []
98
+