fog-wunderlist 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/CONTRIBUTING.md +25 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.md +22 -0
  6. data/README.md +113 -0
  7. data/Rakefile +1 -0
  8. data/TODO.md +1 -0
  9. data/fog-wunderlist.gemspec +24 -0
  10. data/lib/fog/tasks.rb +35 -0
  11. data/lib/fog/wunderlist.rb +10 -0
  12. data/lib/fog/wunderlist/models/tasks/list.rb +47 -0
  13. data/lib/fog/wunderlist/models/tasks/lists.rb +23 -0
  14. data/lib/fog/wunderlist/models/tasks/task.rb +59 -0
  15. data/lib/fog/wunderlist/models/tasks/tasks.rb +23 -0
  16. data/lib/fog/wunderlist/requests/tasks/create_list.rb +31 -0
  17. data/lib/fog/wunderlist/requests/tasks/create_task.rb +34 -0
  18. data/lib/fog/wunderlist/requests/tasks/delete_list.rb +30 -0
  19. data/lib/fog/wunderlist/requests/tasks/delete_task.rb +30 -0
  20. data/lib/fog/wunderlist/requests/tasks/get_task.rb +25 -0
  21. data/lib/fog/wunderlist/requests/tasks/list_lists.rb +25 -0
  22. data/lib/fog/wunderlist/requests/tasks/list_tasks.rb +30 -0
  23. data/lib/fog/wunderlist/requests/tasks/update_list.rb +31 -0
  24. data/lib/fog/wunderlist/requests/tasks/update_task.rb +31 -0
  25. data/lib/fog/wunderlist/tasks.rb +107 -0
  26. data/lib/fog/wunderlist/version.rb +1 -0
  27. data/tests/helper.rb +8 -0
  28. data/tests/helpers/format_helpers.rb +99 -0
  29. data/tests/helpers/succeeds_helper.rb +11 -0
  30. data/tests/wunderlist/models/.list_tests.rb.swp +0 -0
  31. data/tests/wunderlist/models/list_tests.rb +31 -0
  32. data/tests/wunderlist/models/task_tests.rb +31 -0
  33. data/tests/wunderlist/requests/create_task_tests.rb +25 -0
  34. data/tests/wunderlist/requests/list_tasks_tests.rb +43 -0
  35. data/tests/wunderlist/requests/update_list_tests.rb +17 -0
  36. data/tests/wunderlist/requests/update_task_tests.rb +23 -0
  37. metadata +135 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9eab9e1e8ed0e83e454f35ee0f16dd96f2c1e658
4
+ data.tar.gz: cfb8e204a8967762f1d206ca2ebb277804abbd5d
5
+ SHA512:
6
+ metadata.gz: 480e90e5115d6c5131cc0400649cb718fe58e7032d390b4f1cc85760cb033fb35d6007fdd8639fa3efef84d348cfb39fadfad06d5afb3b89715907753406981c
7
+ data.tar.gz: c8d423ca38b576f7ca4562e4ad07fd068fd1ffda7ab1d183b391d1fe2fc6056a481a3415056465f1218371da8574cc066ef82cb9dfc714be1dcebd9702b5d169
@@ -0,0 +1,3 @@
1
+ tests/.fog
2
+ Gemfile.lock
3
+ pkg/*
@@ -0,0 +1,25 @@
1
+ # Contributing
2
+
3
+ The structure of the library is pretty similar to any Fog provider with the
4
+ exception that a new 'Tasks' service has been added. Same Fog rules for
5
+ contributing apply.
6
+
7
+ ## Building the gem
8
+
9
+ ```
10
+ bundle install
11
+ rake build
12
+ ```
13
+
14
+ ## Testing fog-wunderlist
15
+
16
+ Create a tests/.fog file with your Wunderlist credentials:
17
+
18
+ ```
19
+ # tests/.fog content
20
+ :default:
21
+ :wunderlist_username: myemail@foobar.com
22
+ :wunderlist_password: secret
23
+ ```
24
+
25
+ Then run [shindo](http://github.com/shindo).
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fog-wunderlist.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2013 [rubiojr (Sergio Rubio)](http://github.com/rubiojr)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,113 @@
1
+ # Wunderlist Fog provider
2
+
3
+ Fog provider to manage www.wunderlist.com tasks using the familiar
4
+ [Fog](http://fog.io) interface.
5
+
6
+ The provider is fully functional an only depends on Fog. Note that
7
+ Wunderlist does not provide a public API so the API might change at
8
+ any time breaking this library.
9
+
10
+ fog-wunderlist is based on the excellent work from
11
+ https://github.com/bsmt/wunderpy and some API request sniffing
12
+ done by myself.
13
+
14
+ ## Installation
15
+
16
+ gem install fog-wunderlist
17
+
18
+ ## Connecting to Wunderlist
19
+
20
+ ```ruby
21
+
22
+ require 'fog/wunderlist'
23
+ require 'pp'
24
+
25
+ service = Fog::Tasks.new :provider => 'Wunderlist',
26
+ :wunderlist_username => 'myemail@foo.com',
27
+ :wunderlist_password => 'secret'
28
+
29
+ ```
30
+
31
+ ## Managing tasks
32
+
33
+ ```ruby
34
+
35
+ # Listing tasks
36
+ service.tasks.each do |task|
37
+ pp task # =>
38
+ # <Fog::Tasks::Wunderlist::Task
39
+ # id="ACQSAACGzsM",
40
+ # recurrence_count=0,
41
+ # assignee_id=nil,
42
+ # user_id="AAQSAAAHQGM",
43
+ # title="Tap to open me",
44
+ # recurring_parent_id=nil,
45
+ # note="",
46
+ # parent_id=nil,
47
+ # version=5,
48
+ # list_id="inbox",
49
+ # type="Task",
50
+ # owner_id="AAQSAAAHQGM",
51
+ # created_by_id=nil,
52
+ # due_date=nil,
53
+ # created_at=2012-12-06 14:32:31 UTC,
54
+ # completed_at=2012-12-06 14:32:31 UTC,
55
+ # updated_at=2012-12-06 14:32:31 UTC,
56
+ # local_identifier=nil,
57
+ # position=0.0,
58
+ # starred=true
59
+ # >
60
+ end
61
+
62
+ # Creating a new Task in my 'Home' list
63
+ list = service.lists.find { |l| l.title == 'Home' }
64
+ service.tasks.create :title => 'test task',
65
+ :starred => true,
66
+ :list_id => list.id
67
+
68
+ # There's a special list named 'inbox' also
69
+ # that is not listed but we can use
70
+ service.tasks.create :title => 'test task',
71
+ :starred => true,
72
+ :list_id => 'inbox'
73
+
74
+ # Updating a task
75
+ task = service.tasks.find { |t| t.title == 'my task' }
76
+ task.note = 'some random notes'
77
+ task.starred = true
78
+ task.save
79
+
80
+ # Deleting the task
81
+ task.destroy
82
+ ```
83
+
84
+ ## Managing lists
85
+
86
+ ```ruby
87
+ # List all the lists (inbox isn't listed)
88
+ service.lists.each do |list|
89
+ pp list # =>
90
+ #<Fog::Tasks::Wunderlist::List
91
+ # id="ABQSAABVlOE",
92
+ # title="Home",
93
+ # created_at=2012-12-06 00:09:15 UTC,
94
+ # updated_at=2013-03-28 20:53:14 UTC,
95
+ # version=2,
96
+ # local_identifier=nil,
97
+ # position=18.0,
98
+ # type="List",
99
+ # owner_id="AAQSAAAHQGM"
100
+ #>
101
+ end
102
+
103
+ # Creating a new list
104
+ list = service.lists.create :title => 'new list'
105
+
106
+ # Updating the list
107
+ list.title = 'new title for the list'
108
+ list.save
109
+
110
+ # Destroy the list
111
+ list.destroy
112
+
113
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO.md ADDED
@@ -0,0 +1 @@
1
+ * Implement mocking
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fog-wunderlist"
7
+ spec.version = "0.1"
8
+ spec.authors = ["Sergio Rubio"]
9
+ spec.email = ["rubiojr@frameos.org"]
10
+ spec.description = %q{www.wunderlist.com Fog provider}
11
+ spec.summary = %q{www.wunderlist.com Fog provider}
12
+ spec.homepage = "https://github.com/rubiojr"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+ spec.add_dependency('fog', '>= 1.0')
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "shindo"
24
+ end
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Tasks
3
+
4
+ def self.[](provider)
5
+ self.new(:provider => provider)
6
+ end
7
+
8
+ def self.new(attributes)
9
+ attributes = attributes.dup # prevent delete from having side effects
10
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
11
+
12
+ if self.providers.include?(provider)
13
+ require "fog/#{provider}/tasks"
14
+ return Fog::Tasks.const_get(Fog.providers[provider]).new(attributes)
15
+ end
16
+ raise ArgumentError.new("#{provider} is not a recognized tasks provider")
17
+ end
18
+
19
+ def self.providers
20
+ Fog.services[:tasks]
21
+ end
22
+
23
+ def self.servers
24
+ servers = []
25
+ for provider in self.providers
26
+ begin
27
+ servers.concat(self[provider].servers)
28
+ rescue # ignore any missing credentials/etc
29
+ end
30
+ end
31
+ servers
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ require 'fog/core'
2
+ require 'fog/tasks'
3
+
4
+ module Fog
5
+ module Wunderlist
6
+ extend Fog::Provider
7
+ service(:tasks, 'wunderlist/tasks', 'Tasks')
8
+ end
9
+ end
10
+
@@ -0,0 +1,47 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Tasks
5
+ class Wunderlist
6
+ class List < Fog::Model
7
+
8
+ identity :id
9
+
10
+ attribute :title
11
+ attribute :created_at, :type => :time
12
+ attribute :updated_at, :type => :time
13
+ attribute :version
14
+ attribute :local_identifier
15
+ attribute :position
16
+ attribute :type
17
+ attribute :owner_id
18
+
19
+ def destroy
20
+ requires :id
21
+ service.delete_list(id)
22
+ true
23
+ end
24
+
25
+ def save
26
+ requires :title
27
+ if identity
28
+ update
29
+ else
30
+ merge_attributes(
31
+ service.create_list(title, attributes).body
32
+ )
33
+ end
34
+ true
35
+ end
36
+
37
+ def update
38
+ requires :id
39
+ merge_attributes(
40
+ service.update_list(id, attributes).body
41
+ )
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/wunderlist/models/tasks/list'
3
+
4
+ module Fog
5
+ module Tasks
6
+ class Wunderlist
7
+
8
+ class Lists < Fog::Collection
9
+ model Fog::Tasks::Wunderlist::List
10
+
11
+ def all
12
+ load service.list_lists.body
13
+ end
14
+
15
+ def get(id)
16
+ all.find{ |l| l.id == id}
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,59 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Tasks
5
+ class Wunderlist
6
+ class Task < Fog::Model
7
+
8
+ identity :id
9
+
10
+ attribute :recurrence_count, :type => :integer
11
+ attribute :assignee_id
12
+ attribute :user_id
13
+ attribute :title
14
+ attribute :recurring_parent_id
15
+ attribute :note
16
+ attribute :parent_id
17
+ attribute :version, :type => :integer
18
+ attribute :list_id
19
+ attribute :type
20
+ attribute :owner_id
21
+ attribute :created_by_id
22
+ attribute :due_date, :type => :time
23
+ attribute :created_at, :type => :time
24
+ attribute :completed_at, :type => :time
25
+ attribute :updated_at, :type => :time
26
+ attribute :local_identifier
27
+ attribute :position, :type => :float
28
+ attribute :starred, :type => :boolean
29
+
30
+ def destroy
31
+ requires :id
32
+ service.delete_task(id)
33
+ true
34
+ end
35
+
36
+ def save
37
+ requires :list_id, :title
38
+ if identity
39
+ update
40
+ else
41
+ merge_attributes(
42
+ service.create_task(title, list_id, attributes).body
43
+ )
44
+ end
45
+ true
46
+ end
47
+
48
+ def update
49
+ requires :id
50
+ merge_attributes(
51
+ service.update_task(id, attributes).body
52
+ )
53
+ true
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/wunderlist/models/tasks/task'
3
+
4
+ module Fog
5
+ module Tasks
6
+ class Wunderlist
7
+
8
+ class Tasks < Fog::Collection
9
+ model Fog::Tasks::Wunderlist::Task
10
+
11
+ def all
12
+ load service.list_tasks.body
13
+ end
14
+
15
+ def get(id)
16
+ all.find { |t| t.id == id }
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def create_list(title, attributes = {})
7
+ request(
8
+ :expects => [201],
9
+ :method => 'POST',
10
+ :path => "/me/lists",
11
+ :body => { :title => title }.merge(attributes)
12
+ )
13
+ end
14
+
15
+ end
16
+
17
+ class Mock
18
+
19
+ def create_list(title, attributes = {})
20
+ Fog::Mock.not_implemented
21
+ #response = Excon::Response.new
22
+ #response.status = 200
23
+ #response.body = {
24
+ #}
25
+ #response
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def create_task(title, list_id, attributes = {})
7
+ request(
8
+ :expects => [201],
9
+ :method => 'POST',
10
+ :path => "/me/tasks",
11
+ :body => {
12
+ :title => title,
13
+ :list_id => list_id
14
+ }.merge(attributes)
15
+ )
16
+ end
17
+
18
+ end
19
+
20
+ class Mock
21
+
22
+ def create_task(attributes)
23
+ Fog::Mock.not_implemented
24
+ #response = Excon::Response.new
25
+ #response.status = 200
26
+ #response.body = {
27
+ #}
28
+ #response
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def delete_list(id)
7
+ request(
8
+ :expects => [200],
9
+ :method => 'DELETE',
10
+ :path => "/#{id}"
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ class Mock
17
+
18
+ def delete_list(id)
19
+ Fog::Mock.not_implemented
20
+ #response = Excon::Response.new
21
+ #response.status = 200
22
+ #response.body = {
23
+ #}
24
+ #response
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def delete_task(id)
7
+ request(
8
+ :expects => [200],
9
+ :method => 'DELETE',
10
+ :path => "/#{id}"
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ class Mock
17
+
18
+ def delete_task(id)
19
+ Fog::Mock.not_implemented
20
+ #response = Excon::Response.new
21
+ #response.status = 200
22
+ #response.body = {
23
+ #}
24
+ #response
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def get_task(id)
7
+ request(
8
+ :expects => [200],
9
+ :method => 'GET',
10
+ :path => "/me/#{id}"
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ class Mock
17
+
18
+ def get_tasks(id)
19
+ Fog::Mock.not_implemented
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def list_lists
7
+ request(
8
+ :expects => [200],
9
+ :method => 'GET',
10
+ :path => '/me/lists'
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ class Mock
17
+
18
+ def list_lists
19
+ Fog::Mock.not_implemented
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def list_tasks
7
+ request(
8
+ :expects => [200],
9
+ :method => 'GET',
10
+ :path => '/me/tasks'
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ class Mock
17
+
18
+ def list_tasks
19
+ Fog::Mock.not_implementeD
20
+ #response = Excon::Response.new
21
+ #response.status = 200
22
+ #response.body = {
23
+ #}
24
+ #response
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def update_list(id, attributes = {})
7
+ request(
8
+ :expects => [200],
9
+ :method => 'PUT',
10
+ :path => "#{id}",
11
+ :body => attributes
12
+ )
13
+ end
14
+
15
+ end
16
+
17
+ class Mock
18
+
19
+ def update_list(id, attributes = {})
20
+ Fog::Mock.not_implemented
21
+ #response = Excon::Response.new
22
+ #response.status = 200
23
+ #response.body = {
24
+ #}
25
+ #response
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Tasks
3
+ class Wunderlist
4
+ class Real
5
+
6
+ def update_task(id, attributes = {})
7
+ request(
8
+ :expects => [200],
9
+ :method => 'PUT',
10
+ :path => "#{id}",
11
+ :body => attributes
12
+ )
13
+ end
14
+
15
+ end
16
+
17
+ class Mock
18
+
19
+ def update_task(id, attributes = {})
20
+ Fog::Mock.not_implemented
21
+ #response = Excon::Response.new
22
+ #response.status = 200
23
+ #response.body = {
24
+ #}
25
+ #response
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,107 @@
1
+ require 'fog/wunderlist'
2
+ require 'fog/tasks'
3
+
4
+ module Fog
5
+ module Tasks
6
+ class Wunderlist < Fog::Service
7
+
8
+ requires :wunderlist_username
9
+ requires :wunderlist_password
10
+
11
+ recognizes :wunderlist_api_url
12
+
13
+ model_path 'fog/wunderlist/models/tasks'
14
+ model :task
15
+ collection :tasks
16
+ model :list
17
+ collection :lists
18
+
19
+ request_path 'fog/wunderlist/requests/tasks'
20
+ request :list_tasks
21
+ request :list_lists
22
+ request :create_task
23
+ request :delete_task
24
+ request :update_task
25
+ request :create_list
26
+ request :delete_list
27
+ request :update_list
28
+
29
+ class Mock
30
+
31
+ def self.data
32
+ @data ||= Hash.new do |hash, key|
33
+ hash[key] = {
34
+ :tasks => [],
35
+ :lists => []
36
+ }
37
+ end
38
+ end
39
+
40
+ def self.reset
41
+ @data = nil
42
+ end
43
+
44
+ def initialize(options={})
45
+ @password = options[:wunderlist_password]
46
+ end
47
+
48
+ def data
49
+ self.class.data[@password]
50
+ end
51
+
52
+ def reset_data
53
+ self.class.data.delete(@password)
54
+ end
55
+
56
+ end
57
+
58
+ class Real
59
+
60
+ def initialize(options={})
61
+ @username = options[:wunderlist_username]
62
+ @password = options[:wunderlist_password]
63
+ @api_url = options[:wunderlist_api_url] || 'https://api.wunderlist.com'
64
+ @connection = Fog::Connection.new(@api_url)
65
+ @auth_data = authenticate
66
+ end
67
+
68
+ def reload
69
+ @connection.reset
70
+ end
71
+
72
+ def request(params = {})
73
+ params.merge!(
74
+ :headers => {
75
+ 'Authorization' => "Bearer #{@auth_data['token']}",
76
+ 'Content-Type' => 'application/json; charset=utf-8'
77
+ },
78
+ :body => Fog::JSON.encode(params[:body])
79
+ )
80
+ response = @connection.request(params)
81
+
82
+ unless response.body.empty?
83
+ response.body = Fog::JSON.decode(response.body)
84
+ #if response.body['status'] != 'OK'
85
+ # raise Fog::Errors::Error.new
86
+ #end
87
+ end
88
+ response
89
+ end
90
+
91
+ private
92
+ def authenticate
93
+ res = @connection.request :method => 'POST',
94
+ :path => '/login',
95
+ :expects => [200],
96
+ :body => Fog::JSON.encode({
97
+ :email => @username,
98
+ :password => @password
99
+ })
100
+ Fog::JSON.decode(res.body)
101
+ end
102
+
103
+
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1 @@
1
+ F
@@ -0,0 +1,8 @@
1
+ ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('../.fog', __FILE__)
2
+ ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default'
3
+
4
+ require 'fog/wunderlist'
5
+
6
+ Dir["./#{File.dirname(__FILE__)}/helpers/*.rb"].each do |h|
7
+ require h
8
+ end
@@ -0,0 +1,99 @@
1
+ require "fog/schema/data_validator"
2
+
3
+ # format related hackery
4
+ # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean)
5
+ # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String)
6
+ module Fog
7
+ module Boolean; end
8
+ module Nullable
9
+ module Boolean; end
10
+ module Integer; end
11
+ module String; end
12
+ module Time; end
13
+ module Float; end
14
+ module Hash; end
15
+ module Array; end
16
+ end
17
+ end
18
+ [FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
19
+ [FalseClass, TrueClass, NilClass, Fog::Boolean].each {|klass| klass.send(:include, Fog::Nullable::Boolean)}
20
+ [NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
21
+ [NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)}
22
+ [Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
23
+ [Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)}
24
+ [Hash, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Hash)}
25
+ [Array, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Array)}
26
+
27
+ module Shindo
28
+ class Tests
29
+
30
+ # Generates a Shindo test that compares a hash schema to the result
31
+ # of the passed in block returning true if they match.
32
+ #
33
+ # The schema that is passed in is a Hash or Array of hashes that
34
+ # have Classes in place of values. When checking the schema the
35
+ # value should match the Class.
36
+ #
37
+ # Strict mode will fail if the data has additional keys. Setting
38
+ # +strict+ to +false+ will allow additional keys to appear.
39
+ #
40
+ # @param [Hash] schema A Hash schema
41
+ # @param [Hash] options Options to change validation rules
42
+ # @option options [Boolean] :allow_extra_keys
43
+ # If +true+ does not fail when keys are in the data that are
44
+ # not specified in the schema. This allows new values to
45
+ # appear in API output without breaking the check.
46
+ # @option options [Boolean] :allow_optional_rules
47
+ # If +true+ does not fail if extra keys are in the schema
48
+ # that do not match the data. Not recommended!
49
+ # @yield Data to check with schema
50
+ #
51
+ # @example Using in a test
52
+ # Shindo.tests("comparing welcome data against schema") do
53
+ # data = {:welcome => "Hello" }
54
+ # data_matches_schema(:welcome => String) { data }
55
+ # end
56
+ #
57
+ # comparing welcome data against schema
58
+ # + data matches schema
59
+ #
60
+ # @example Example schema
61
+ # {
62
+ # "id" => String,
63
+ # "ram" => Integer,
64
+ # "disks" => [
65
+ # {
66
+ # "size" => Float
67
+ # }
68
+ # ],
69
+ # "dns_name" => Fog::Nullable::String,
70
+ # "active" => Fog::Boolean,
71
+ # "created" => DateTime
72
+ # }
73
+ #
74
+ # @return [Boolean]
75
+ def data_matches_schema(schema, options = {})
76
+ test('data matches schema') do
77
+ validator = Fog::Schema::DataValidator.new
78
+ valid = validator.validate(yield, schema, options)
79
+ @message = validator.message unless valid
80
+ valid
81
+ end
82
+ end
83
+
84
+ # @deprecated #formats is deprecated. Use #data_matches_schema instead
85
+ def formats(format, strict = true)
86
+ test('has proper format') do
87
+ if strict
88
+ options = {:allow_extra_keys => false, :allow_optional_rules => true}
89
+ else
90
+ options = {:allow_extra_keys => true, :allow_optional_rules => true}
91
+ end
92
+ validator = Fog::Schema::DataValidator.new
93
+ valid = validator.validate(yield, format, options)
94
+ @message = validator.message unless valid
95
+ valid
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,11 @@
1
+ module Shindo
2
+ class Tests
3
+
4
+ def succeeds
5
+ test('succeeds') do
6
+ !!instance_eval(&Proc.new)
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ Shindo.tests("Fog::Tasks[:wunderlist] | list model") do
2
+
3
+ service = Fog::Tasks[:wunderlist]
4
+
5
+ tests('success') do
6
+
7
+ tests('#save').succeeds do
8
+ @list = service.lists.new :title => 'fog test list',
9
+ :starred => true,
10
+ :list_id => 'inbox'
11
+ @list.save
12
+ end
13
+
14
+ tests('#update using save').succeeds do
15
+ @list.title = 'updated title'
16
+ @list.save
17
+ service.lists.get(@list.id).title == 'updated title'
18
+ end
19
+
20
+ tests('#update').succeeds do
21
+ @list.title = 'updated title 2'
22
+ @list.update
23
+ service.lists.get(@list.id).title == 'updated title 2'
24
+ end
25
+
26
+ tests('#destroy').succeeds do
27
+ @list.destroy
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,31 @@
1
+ Shindo.tests("Fog::Tasks[:wunderlist] | task model") do
2
+
3
+ service = Fog::Tasks[:wunderlist]
4
+
5
+ tests('success') do
6
+
7
+ tests('#save').succeeds do
8
+ @task = service.tasks.new :title => 'fog test task',
9
+ :starred => true,
10
+ :list_id => 'inbox'
11
+ @task.save
12
+ end
13
+
14
+ tests('#update using save').succeeds do
15
+ @task.note = 'some note'
16
+ @task.save
17
+ service.tasks.get(@task.id).note == 'some note'
18
+ end
19
+
20
+ tests('#update').succeeds do
21
+ @task.note = 'some note 2'
22
+ @task.update
23
+ service.tasks.get(@task.id).note == 'some note 2'
24
+ end
25
+
26
+ tests('#destroy').succeeds do
27
+ @task.destroy
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,25 @@
1
+ Shindo.tests('Fog::Tasks[:wunderlist] | create_task request', ['wunderlist']) do
2
+
3
+ tests('success') do
4
+
5
+ test('#create_task') do
6
+ @task = Fog::Tasks[:wunderlist].create_task("fog test task", 'inbox').body
7
+ @task['title'] == 'fog test task'
8
+ end
9
+
10
+ test('task list is inbox') do
11
+ @task['list_id'] == 'inbox'
12
+ end
13
+
14
+ test('#delete_task') do
15
+ Fog::Tasks[:wunderlist].delete_task(@task['id']).status == 200
16
+ end
17
+ end
18
+
19
+ tests('failure') do
20
+ raises(Excon::Errors::NotFound, '#create_task with invalid list') do
21
+ Fog::Tasks[:wunderlist].create_task("fog test task", '00000011').body
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,43 @@
1
+ Shindo.tests('Fog::Tasks[:wunderlist] | list_tasks request', ['wunderlist']) do
2
+
3
+ @task_format = {
4
+ 'id' => String,
5
+ 'created_at' => String,
6
+ 'updated_at' => String,
7
+ 'title' => String,
8
+ 'starred' => Fog::Boolean,
9
+ 'note' => Fog::Nullable::String,
10
+ 'completed_at' => Fog::Nullable::String,
11
+ 'local_identifier' => Fog::Nullable::String,
12
+ 'recurrence_type' => Fog::Nullable::String,
13
+ 'recurrence_count' => Integer,
14
+ 'recurring_parent_id' => Fog::Nullable::String,
15
+ 'due_date' => Fog::Nullable::String,
16
+ 'parent_id' => Fog::Nullable::String,
17
+ 'created_by_id' => Fog::Nullable::String,
18
+ 'updated_by_id' => Fog::Nullable::String,
19
+ 'completed_by_id' => Fog::Nullable::String,
20
+ 'version' => Integer,
21
+ 'assignee_id' => Fog::Nullable::String,
22
+ 'type' => String,
23
+ 'user_id' => String,
24
+ 'owner_id' => String,
25
+ 'position' => Fog::Nullable::Float,
26
+ 'list_id' => String,
27
+ 'deleted_at' => Fog::Nullable::String
28
+ }
29
+
30
+ service = Fog::Tasks[:wunderlist]
31
+ tests('success') do
32
+ @task = service.create_task("fog test task", 'inbox').body
33
+ service.list_tasks.body.each do |t|
34
+ tests('#list_tasks').formats(@task_format) do
35
+ t
36
+ end
37
+ end
38
+
39
+ service.delete_task @task['id']
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,17 @@
1
+ Shindo.tests('Fog::Tasks[:wunderlist] | update_list request') do
2
+
3
+ service = Fog::Tasks[:wunderlist]
4
+
5
+ tests('success') do
6
+
7
+ tests('#update_list').succeeds do
8
+ @list = service.lists.create :title => 'test list'
9
+ service.update_list @list.id, { :title => 'test list modified' }
10
+ service.lists.get(@list.id).title == 'test list modified'
11
+ end
12
+
13
+ @list.destroy
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ Shindo.tests('Fog::Tasks[:wunderlist] | create_task request', ['wunderlist']) do
2
+
3
+ service = Fog::Tasks[:wunderlist]
4
+
5
+ tests('success') do
6
+
7
+ test('#update_task title') do
8
+ @task = service.create_task("fog test task", 'inbox').body
9
+ service.update_task @task['id'], { :title => 'updated by fog' }
10
+ @task = service.tasks.get @task['id']
11
+ @task.title == 'updated by fog'
12
+ end
13
+
14
+ test('#update_task note') do
15
+ service.update_task @task.id, { :note => 'some notes' }
16
+ @task = service.tasks.get @task.id
17
+ @task.note == 'some notes'
18
+ end
19
+
20
+ @task.destroy
21
+ end
22
+
23
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fog-wunderlist
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Sergio Rubio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fog
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: shindo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: www.wunderlist.com Fog provider
70
+ email:
71
+ - rubiojr@frameos.org
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - CONTRIBUTING.md
78
+ - Gemfile
79
+ - LICENSE.md
80
+ - README.md
81
+ - Rakefile
82
+ - TODO.md
83
+ - fog-wunderlist.gemspec
84
+ - lib/fog/tasks.rb
85
+ - lib/fog/wunderlist.rb
86
+ - lib/fog/wunderlist/models/tasks/list.rb
87
+ - lib/fog/wunderlist/models/tasks/lists.rb
88
+ - lib/fog/wunderlist/models/tasks/task.rb
89
+ - lib/fog/wunderlist/models/tasks/tasks.rb
90
+ - lib/fog/wunderlist/requests/tasks/create_list.rb
91
+ - lib/fog/wunderlist/requests/tasks/create_task.rb
92
+ - lib/fog/wunderlist/requests/tasks/delete_list.rb
93
+ - lib/fog/wunderlist/requests/tasks/delete_task.rb
94
+ - lib/fog/wunderlist/requests/tasks/get_task.rb
95
+ - lib/fog/wunderlist/requests/tasks/list_lists.rb
96
+ - lib/fog/wunderlist/requests/tasks/list_tasks.rb
97
+ - lib/fog/wunderlist/requests/tasks/update_list.rb
98
+ - lib/fog/wunderlist/requests/tasks/update_task.rb
99
+ - lib/fog/wunderlist/tasks.rb
100
+ - lib/fog/wunderlist/version.rb
101
+ - tests/helper.rb
102
+ - tests/helpers/format_helpers.rb
103
+ - tests/helpers/succeeds_helper.rb
104
+ - tests/wunderlist/models/.list_tests.rb.swp
105
+ - tests/wunderlist/models/list_tests.rb
106
+ - tests/wunderlist/models/task_tests.rb
107
+ - tests/wunderlist/requests/create_task_tests.rb
108
+ - tests/wunderlist/requests/list_tasks_tests.rb
109
+ - tests/wunderlist/requests/update_list_tests.rb
110
+ - tests/wunderlist/requests/update_task_tests.rb
111
+ homepage: https://github.com/rubiojr
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.0.6
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: www.wunderlist.com Fog provider
135
+ test_files: []