memotoo 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/Gemfile CHANGED
@@ -3,10 +3,12 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem "savon"
6
+ #, "~> 0.9.2"
6
7
 
7
8
  # Add dependencies to develop your gem here.
8
9
  # Include everything needed to run rake, tests, features, etc.
9
10
  group :development do
11
+ gem "rack", "~>1.1.2"
10
12
  gem "shoulda", ">= 0"
11
13
  gem "bundler", "~> 1.0.0"
12
14
  gem "jeweler", "~> 1.5.2"
@@ -15,7 +15,7 @@ GEM
15
15
  nokogiri (1.4.4)
16
16
  nori (0.2.0)
17
17
  ntlm-http (0.1.1)
18
- rack (1.2.2)
18
+ rack (1.1.2)
19
19
  rake (0.8.7)
20
20
  rcov (0.9.9)
21
21
  savon (0.9.2)
@@ -32,6 +32,7 @@ PLATFORMS
32
32
  DEPENDENCIES
33
33
  bundler (~> 1.0.0)
34
34
  jeweler (~> 1.5.2)
35
+ rack (~> 1.1.2)
35
36
  rcov
36
37
  savon
37
38
  shoulda
@@ -11,7 +11,7 @@ I searched for an memotoo-gem and could't find anyone. There are only php-script
11
11
  Here is the first available ruby version and my first gem.
12
12
 
13
13
  == You need
14
- you need a memotoo-credential (usetrname/passwd) to use this gem
14
+ you need a memotoo-credential (username/passwd) to use this gem
15
15
 
16
16
  <b>get a free account here: {www.memotoo.com}[http://www.memotoo.com/index-saleshype.php]</b>
17
17
 
@@ -29,11 +29,11 @@ give a first try in irb: ./script/console
29
29
 
30
30
  @connect=Memotoo::Connect.new("myusername","mypassword")
31
31
 
32
- [Add a contact:]
32
+ add a contact:
33
33
 
34
34
  @response = @connect.addContact({:title => "Mr",:lastname => "Wonder",:firstname => "Test"})
35
35
 
36
- get a contact from id
36
+ get a contact from id:
37
37
 
38
38
  @response = @connect.getContact(12345)
39
39
 
@@ -45,16 +45,25 @@ modify a contact:
45
45
 
46
46
  @response = @connect.modifyContact({:id=>"12345",:lastname=>"New",:jobtitle => "cat-doctor",:otherphone => "12345"})
47
47
 
48
+ ==Testing
49
+
50
+ I added tests for all possible functions. (rcov 100%)
51
+ You can add your own credential to /test/test_memotoo.rb
52
+
53
+ I also added support for {http://test.rubygems.org}[http://test.rubygems.org]
54
+
55
+ You can now use the gem rubygems-test for easy testing this gem.
56
+
57
+ See my testrsult here: http://test.rubygems.org/gems/memotoo/v/1.0.1/test_results/1645
58
+
48
59
  ==Documentation
49
60
 
50
61
  see rdoc
51
62
 
52
- start rdoc server with: gem server
53
-
54
63
  ==To-Dos
55
- 1. I havn't wrote any tests, but tested a lot.
56
- 2. Exception handling should be done
57
- 3. I only implemented contacts - these soap-objects are missing: bookmark, bookmark's folder, contact's group, event, holiday, task, note
64
+
65
+ 1. Exception handling should be done
66
+ 2. I only implemented contacts - these soap-objects are missing: bookmark, bookmark's folder, contact's group, event, holiday, task, note
58
67
 
59
68
  It would be nice if *someone* could help me with the missing parts .
60
69
 
data/Rakefile CHANGED
@@ -14,8 +14,8 @@ Jeweler::Tasks.new do |gem|
14
14
  gem.name = "memotoo"
15
15
  gem.homepage = "http://github.com/kredmer/memotoo"
16
16
  gem.license = "MIT"
17
- gem.summary = "A gem for connecting to the memotoo soap-api"
18
- gem.description = "A gem for connecting to the memotoo soap-api and handle your contact needs"
17
+ gem.summary = "Unofficial gem for connecting to the memotoo soap-api"
18
+ gem.description = "Unofficial gem for connecting to the memotoo soap-api and handle your contact needs. Memotoo lets your synchronize all your contacts, events and tasks with yahoo, gmail, facebook, xing, outlook, your mobile-phone and more. You can also get your e-mails in one place. Memotoo is good value for money!"
19
19
  gem.email = "k.redmer@yahoo.de"
20
20
  gem.authors = ["Karsten Redmer"]
21
21
  gem.add_dependency 'savon'
@@ -41,7 +41,6 @@ task :default => :test
41
41
  require 'rake/rdoctask'
42
42
  Rake::RDocTask.new do |rdoc|
43
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
44
  rdoc.rdoc_dir = 'rdoc'
46
45
  rdoc.title = "memotoo #{version}"
47
46
  rdoc.rdoc_files.include('README*')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -1,6 +1,5 @@
1
1
  require "savon"
2
2
  require "memotoo/core-ext/hash"
3
- require "memotoo/core-ext/kernel"
4
3
  require "memotoo/contact/contact"
5
4
 
6
5
  module Memotoo
@@ -26,14 +25,6 @@ module Memotoo
26
25
  :password => password,
27
26
  }
28
27
  }
29
-
30
- # set savon logging and erros
31
- Savon.configure do |config|
32
- config.raise_errors = false # do not raise SOAP faults and HTTP errors
33
- config.log = false # disable logging
34
- config.log_level = :info # changing the log level
35
- config.logger = Rails.logger # using the Rails logger
36
- end
37
28
 
38
29
  # creates client with memotoo settings
39
30
  client(https)
@@ -59,13 +50,14 @@ module Memotoo
59
50
  end
60
51
  http.auth.basic self.opts[:param][:login], self.opts[:param][:password]
61
52
  end
53
+
62
54
  end
63
55
 
64
56
  # used internally for a request
65
57
  def apicall(action, parameter)
66
58
 
67
59
  response=@client.request :wsdl, action do
68
- soap.body = { :param => parameter }.deep_merge!(self.opts)
60
+ soap.body = { :param => parameter }.deep_merge_me!(self.opts)
69
61
  end
70
62
  response
71
63
 
@@ -76,11 +68,30 @@ module Memotoo
76
68
  rescue Savon::Error => error
77
69
  if error.message.nil?
78
70
  puts "invalid username/password"
79
- else
80
- puts error.to_s
81
- end
71
+
72
+ # I don't know which error is still possible
73
+ # else
74
+ # puts error.to_s
75
+ end
82
76
  end
83
77
 
78
+
84
79
  end # class
85
80
 
86
81
  end # module
82
+
83
+ # stop savon logging and raising errors
84
+
85
+ module Savon
86
+ module Global
87
+
88
+ def log?
89
+ false
90
+ end
91
+
92
+ def raise_errors?
93
+ @raise_errors = true
94
+ end
95
+
96
+ end
97
+ end
@@ -45,7 +45,12 @@ module Memotoo
45
45
  }.merge!(searchparameter)
46
46
  search_response = apicall(:searchContact, search)
47
47
  # returns an array of contacts from search result
48
- search_response.to_hash.seek :search_contact_response, :return, :contact
48
+ if search_response.nil? || search_response==""
49
+ nil
50
+ else
51
+ search_response.to_hash.seek :search_contact_response, :return, :contact
52
+ end
53
+
49
54
  else
50
55
  # returns false and a message
51
56
  go_home(check[1])
@@ -27,13 +27,13 @@ class Hash # :nodoc: all
27
27
  # Modifies the receiver in place.
28
28
  # => already in savon gem
29
29
  # => in case a time come and it will be away - just uncomment it
30
- # def deep_merge!(other_hash)
31
- # other_hash.each_pair do |k,v|
32
- # tv = self[k]
33
- # self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v
34
- # end
35
- # self
36
- # end unless defined? deep_merge!
30
+ def deep_merge_me!(other_hash)
31
+ other_hash.each_pair do |k,v|
32
+ tv = self[k]
33
+ self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge_me!(v) : v
34
+ end
35
+ self
36
+ end unless defined? deep_merge!
37
37
 
38
38
 
39
39
 
Binary file
@@ -0,0 +1,78 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{memotoo}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Karsten Redmer}]
12
+ s.date = %q{2011-06-06}
13
+ s.description = %q{Unofficial gem for connecting to the memotoo soap-api and handle your contact needs. Memotoo lets your synchronize all your contacts, events and tasks with yahoo, gmail, facebook, xing, outlook, your mobile-phone and more. You can also get your e-mails in one place. Memotoo is good value for money!}
14
+ s.email = %q{k.redmer@yahoo.de}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gemtest",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/memotoo.rb",
29
+ "lib/memotoo/connect.rb",
30
+ "lib/memotoo/contact/contact.rb",
31
+ "lib/memotoo/core-ext/hash.rb",
32
+ "memotoo-1.0.0.gem",
33
+ "memotoo-1.0.1.gem",
34
+ "memotoo.gemspec",
35
+ "test/helper.rb",
36
+ "test/test_memotoo.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/kredmer/memotoo}
39
+ s.licenses = [%q{MIT}]
40
+ s.require_paths = [%q{lib}]
41
+ s.rubygems_version = %q{1.8.5}
42
+ s.summary = %q{Unofficial gem for connecting to the memotoo soap-api}
43
+ s.test_files = [
44
+ "test/helper.rb",
45
+ "test/test_memotoo.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<savon>, [">= 0"])
53
+ s.add_development_dependency(%q<rack>, ["~> 1.1.2"])
54
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
57
+ s.add_development_dependency(%q<rcov>, [">= 0"])
58
+ s.add_runtime_dependency(%q<savon>, [">= 0"])
59
+ else
60
+ s.add_dependency(%q<savon>, [">= 0"])
61
+ s.add_dependency(%q<rack>, ["~> 1.1.2"])
62
+ s.add_dependency(%q<shoulda>, [">= 0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ s.add_dependency(%q<savon>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<savon>, [">= 0"])
70
+ s.add_dependency(%q<rack>, ["~> 1.1.2"])
71
+ s.add_dependency(%q<shoulda>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<savon>, [">= 0"])
76
+ end
77
+ end
78
+
@@ -10,9 +10,11 @@ end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
12
 
13
+
13
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'memotoo'
16
+
17
+ #require 'memotoo'
16
18
 
17
19
  class Test::Unit::TestCase
18
20
  end
@@ -1,7 +1,125 @@
1
1
  require 'helper'
2
+ require 'savon'
3
+ require File.dirname(__FILE__) + "/../lib/memotoo"
4
+
2
5
 
3
6
  class TestMemotoo < 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"
7
+
8
+ # put your own credentials here
9
+
10
+ MEMOTOO_USERNAME = "memotoo-tester"
11
+ MEMOTOO_PASSWORD = "memotoo-tester"
12
+
13
+ context "Memotoo-Soap Api for contact" do
14
+
15
+ setup do
16
+ @connect=Memotoo::Connect.new(MEMOTOO_USERNAME,MEMOTOO_PASSWORD)
17
+ end
18
+
19
+ should "have a connect-instance" do
20
+ assert_equal Memotoo::Connect, @connect.class
21
+ end
22
+
23
+ should "write a message if username/password is not correct" do
24
+ @connect=Memotoo::Connect.new(MEMOTOO_USERNAME,"wrongpasswd")
25
+ response = @connect.searchContact({:search=>" ", :limit_start => '0', :limit_nb => '2'})
26
+ assert_raise RuntimeError do
27
+ raise 'Boom!!!'
28
+ end
29
+ end
30
+
31
+ should "have valid username and password and get search results" do
32
+ response = @connect.searchContact({:search=>" ", :limit_start => '0', :limit_nb => '2'})
33
+ assert_not_nil response
34
+ end
35
+
36
+
37
+ should "also use http request instead of https" do
38
+ @connect=Memotoo::Connect.new(MEMOTOO_USERNAME,MEMOTOO_PASSWORD, false)
39
+ response = @connect.searchContact({:search=>" ", :limit_start => '0', :limit_nb => '2'})
40
+ assert_not_nil response
41
+ end
42
+
43
+
44
+
45
+ context "Adding and finding contacts" do
46
+
47
+ should "add a new testcontact" do
48
+ response = @connect.addContact({:lastname => "Testcontact123456"})
49
+ assert_not_nil response
50
+ end
51
+
52
+ should "add a new testcontact (and look for needed params)" do
53
+ response = @connect.addContact({})
54
+ assert_not_nil response
55
+ end
56
+
57
+
58
+ should "find the testcontact" do
59
+ response = @connect.searchContact({:search=>"Testcontact123456"})
60
+ assert_not_nil response
61
+ end
62
+
63
+ should "not find a non existent contact" do
64
+ response = @connect.searchContact({:search=>"Testcontact1234567890"})
65
+ assert_nil response
66
+ end
67
+
68
+ should "look for a search parameter in search" do
69
+ response = @connect.searchContact({})
70
+ assert !response
71
+ end
72
+
73
+
74
+ should "get the testcontact" do
75
+ response = @connect.searchContact({:search=>"Testcontact123456"})
76
+ contact = @connect.getContact(response[:id])
77
+ assert_not_nil contact
78
+ end
79
+
80
+ end
81
+
82
+
83
+ context "B Modifying contacts" do
84
+
85
+ should "modify the testcontact" do
86
+ response = @connect.searchContact({:search=>"Testcontact123456"})
87
+ contact = @connect.modifyContact({:id=>response[:id], :lastname=>"Testcontact123456", :firstname=>"test"})
88
+ assert contact
89
+ end
90
+
91
+ should "modify the testcontact (and look for needed params)" do
92
+ response = @connect.searchContact({:search=>"Testcontact123456"})
93
+ contact = @connect.modifyContact({})
94
+ assert !contact
95
+ end
96
+
97
+
98
+ end
99
+
100
+
101
+ context "Deleting contacts" do
102
+
103
+ should "delete the testcontact" do
104
+ response = @connect.searchContact({:search=>"Testcontact123456"})
105
+ contact = @connect.deleteContact(response[:id])
106
+ assert contact
107
+ end
108
+
109
+ end
110
+
111
+
6
112
  end
113
+
7
114
  end
115
+
116
+ # uncomment this if you want to see everything in log what happens...it's a lot
117
+ #module Savon
118
+ # module Global
119
+
120
+ # def log?
121
+ # true
122
+ # end
123
+ #
124
+ # end
125
+ #end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memotoo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Karsten Redmer
@@ -15,12 +15,9 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-14 00:00:00 +02:00
19
- default_executable:
18
+ date: 2011-06-06 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- name: savon
24
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
25
22
  none: false
26
23
  requirements:
@@ -30,12 +27,28 @@ dependencies:
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
33
- requirement: *id001
34
30
  type: :runtime
35
- - !ruby/object:Gem::Dependency
31
+ requirement: *id001
36
32
  prerelease: false
37
- name: shoulda
33
+ name: savon
34
+ - !ruby/object:Gem::Dependency
38
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ hash: 23
41
+ segments:
42
+ - 1
43
+ - 1
44
+ - 2
45
+ version: 1.1.2
46
+ type: :development
47
+ requirement: *id002
48
+ prerelease: false
49
+ name: rack
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
39
52
  none: false
40
53
  requirements:
41
54
  - - ">="
@@ -44,12 +57,12 @@ dependencies:
44
57
  segments:
45
58
  - 0
46
59
  version: "0"
47
- requirement: *id002
48
60
  type: :development
49
- - !ruby/object:Gem::Dependency
61
+ requirement: *id003
50
62
  prerelease: false
51
- name: bundler
52
- version_requirements: &id003 !ruby/object:Gem::Requirement
63
+ name: shoulda
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
53
66
  none: false
54
67
  requirements:
55
68
  - - ~>
@@ -60,12 +73,12 @@ dependencies:
60
73
  - 0
61
74
  - 0
62
75
  version: 1.0.0
63
- requirement: *id003
64
76
  type: :development
65
- - !ruby/object:Gem::Dependency
77
+ requirement: *id004
66
78
  prerelease: false
67
- name: jeweler
68
- version_requirements: &id004 !ruby/object:Gem::Requirement
79
+ name: bundler
80
+ - !ruby/object:Gem::Dependency
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
69
82
  none: false
70
83
  requirements:
71
84
  - - ~>
@@ -76,12 +89,12 @@ dependencies:
76
89
  - 5
77
90
  - 2
78
91
  version: 1.5.2
79
- requirement: *id004
80
92
  type: :development
81
- - !ruby/object:Gem::Dependency
93
+ requirement: *id005
82
94
  prerelease: false
83
- name: rcov
84
- version_requirements: &id005 !ruby/object:Gem::Requirement
95
+ name: jeweler
96
+ - !ruby/object:Gem::Dependency
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
85
98
  none: false
86
99
  requirements:
87
100
  - - ">="
@@ -90,12 +103,12 @@ dependencies:
90
103
  segments:
91
104
  - 0
92
105
  version: "0"
93
- requirement: *id005
94
106
  type: :development
95
- - !ruby/object:Gem::Dependency
107
+ requirement: *id006
96
108
  prerelease: false
97
- name: savon
98
- version_requirements: &id006 !ruby/object:Gem::Requirement
109
+ name: rcov
110
+ - !ruby/object:Gem::Dependency
111
+ version_requirements: &id007 !ruby/object:Gem::Requirement
99
112
  none: false
100
113
  requirements:
101
114
  - - ">="
@@ -104,9 +117,11 @@ dependencies:
104
117
  segments:
105
118
  - 0
106
119
  version: "0"
107
- requirement: *id006
108
120
  type: :runtime
109
- description: A gem for connecting to the memotoo soap-api and handle your contact needs
121
+ requirement: *id007
122
+ prerelease: false
123
+ name: savon
124
+ description: Unofficial gem for connecting to the memotoo soap-api and handle your contact needs. Memotoo lets your synchronize all your contacts, events and tasks with yahoo, gmail, facebook, xing, outlook, your mobile-phone and more. You can also get your e-mails in one place. Memotoo is good value for money!
110
125
  email: k.redmer@yahoo.de
111
126
  executables: []
112
127
 
@@ -117,6 +132,7 @@ extra_rdoc_files:
117
132
  - README.rdoc
118
133
  files:
119
134
  - .document
135
+ - .gemtest
120
136
  - Gemfile
121
137
  - Gemfile.lock
122
138
  - LICENSE.txt
@@ -127,10 +143,11 @@ files:
127
143
  - lib/memotoo/connect.rb
128
144
  - lib/memotoo/contact/contact.rb
129
145
  - lib/memotoo/core-ext/hash.rb
130
- - lib/memotoo/core-ext/kernel.rb
146
+ - memotoo-1.0.0.gem
147
+ - memotoo-1.0.1.gem
148
+ - memotoo.gemspec
131
149
  - test/helper.rb
132
150
  - test/test_memotoo.rb
133
- has_rdoc: true
134
151
  homepage: http://github.com/kredmer/memotoo
135
152
  licenses:
136
153
  - MIT
@@ -160,10 +177,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
177
  requirements: []
161
178
 
162
179
  rubyforge_project:
163
- rubygems_version: 1.3.7
180
+ rubygems_version: 1.8.5
164
181
  signing_key:
165
182
  specification_version: 3
166
- summary: A gem for connecting to the memotoo soap-api
183
+ summary: Unofficial gem for connecting to the memotoo soap-api
167
184
  test_files:
168
185
  - test/helper.rb
169
186
  - test/test_memotoo.rb
@@ -1,10 +0,0 @@
1
- module Kernel # :nodoc: all
2
- private
3
- def this_method
4
- caller[0] =~ /`([^']*)'/ and $1
5
- end
6
- def calling_method
7
- caller[1] =~ /`([^']*)'/ and $1
8
- end
9
- end
10
-