todoly 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.1.0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "fakeweb"
13
+ end
14
+
15
+ gem "rest-client", "> 0"
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ fakeweb (1.3.0)
6
+ git (1.2.5)
7
+ jeweler (1.5.1)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ mime-types (1.16)
12
+ rake (0.8.7)
13
+ rest-client (1.6.1)
14
+ mime-types (>= 1.16)
15
+ rspec (2.1.0)
16
+ rspec-core (~> 2.1.0)
17
+ rspec-expectations (~> 2.1.0)
18
+ rspec-mocks (~> 2.1.0)
19
+ rspec-core (2.1.0)
20
+ rspec-expectations (2.1.0)
21
+ diff-lcs (~> 1.1.2)
22
+ rspec-mocks (2.1.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.0.0)
29
+ fakeweb
30
+ jeweler (~> 1.5.1)
31
+ rest-client (> 0)
32
+ rspec (~> 2.1.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 nagachika
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,19 @@
1
+ = todoly
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to todoly
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 nagachika. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "todoly"
16
+ gem.homepage = "http://github.com/nagachika/ruby-todoly"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{todo.ly REST API Library}
19
+ gem.description = %Q{todo.ly REST API Library}
20
+ gem.email = "nagachika00@gmail.com"
21
+ gem.authors = ["nagachika"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "todoly #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,121 @@
1
+
2
+ require "json"
3
+ require "rest_client"
4
+
5
+ module Todoly
6
+
7
+ class TodolyError < StandardError; end
8
+
9
+ TODOLY_API_URL = "https://todo.ly/api/"
10
+
11
+ class Client
12
+ def rest_client_with_token(token)
13
+ RestClient::Resource.new(@api_url,
14
+ :headers => { :Token => token })
15
+ end
16
+
17
+ def rest_client_with_password(user, password)
18
+ RestClient::Resource.new(@api_url,
19
+ :user => user,
20
+ :password => password)
21
+ end
22
+
23
+ {
24
+ :get_token => {
25
+ :path => "authentication/token",
26
+ :method => :get,
27
+ :member => "TokenString",
28
+ },
29
+ :delete_token => {
30
+ :path => "authentication/token",
31
+ :method => :delete,
32
+ :member => "TokenString",
33
+ },
34
+ :projects => {
35
+ :path => "projects",
36
+ :method => :get,
37
+ },
38
+ :items_of_project => {
39
+ :path => "projects/%d/items",
40
+ :method => :get,
41
+ },
42
+ :done_items_of_project => {
43
+ :path => "projects/%d/doneitems",
44
+ :method => :get,
45
+ },
46
+ :filters => {
47
+ :path => "filters",
48
+ :method => :get,
49
+ },
50
+ :items_of_filter => {
51
+ :path => "filters/%d/items",
52
+ :method => :get,
53
+ },
54
+ :items => {
55
+ :path => "items",
56
+ :method => :get,
57
+ },
58
+ :item_by_id => {
59
+ :path => "items/%d",
60
+ :method => :get,
61
+ },
62
+ :create_item => {
63
+ :path => "items",
64
+ :method => :post,
65
+ },
66
+ :delete_item_by_id => {
67
+ :path => "items/%d",
68
+ :method => :delete,
69
+ },
70
+ :update_item_by_id => {
71
+ :path => "items/%d",
72
+ :method => :post,
73
+ },
74
+ }.each do |meth, data|
75
+ class_eval do
76
+ define_method(meth) do |*params|
77
+ if /_(?:by|of)_/ =~ meth
78
+ id, param = params
79
+ path = sprintf(data[:path]+".json", id)
80
+ else
81
+ path = data[:path] + ".json"
82
+ param, = params
83
+ end
84
+ if data[:method] == :post
85
+ json = @api[path].send(data[:method], param.to_json)
86
+ else
87
+ json = @api[path].send(data[:method])
88
+ end
89
+ obj = JSON.parse(json)
90
+ if obj.is_a?(Hash) and obj["ErrorMessage"]
91
+ raise TodolyError, obj["ErrorMessage"]
92
+ end
93
+ if data[:member]
94
+ unless obj.include?(data[:member])
95
+ raise TodolyError, "expected member #{data[:member]} is not contained"
96
+ end
97
+ obj = obj[data[:member]]
98
+ end
99
+ obj
100
+ end
101
+ end
102
+ end
103
+
104
+ def initialize(opt={})
105
+ if ENV["https_proxy"]
106
+ RestClient.proxy = ENV["https_proxy"]
107
+ elsif ENV["http_proxy"]
108
+ RestClient.proxy = ENV["http_proxy"]
109
+ end
110
+ @api_url = opt[:api_url] || TODOLY_API_URL
111
+ if opt[:token]
112
+ @api = rest_client_with_token(token)
113
+ elsif opt[:email] and opt[:password]
114
+ @api = rest_client_with_password(opt[:email], opt[:password])
115
+ @api = rest_client_with_token(get_token)
116
+ else
117
+ raise "Please specify :email and :password or :token"
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'todoly'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Todoly" do
4
+ it "can required" do
5
+ defined?(Todoly).should be_eql("constant")
6
+ end
7
+ end
@@ -0,0 +1,68 @@
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{todoly}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["nagachika"]
12
+ s.date = %q{2010-12-15}
13
+ s.description = %q{todo.ly REST API Library}
14
+ s.email = %q{nagachika00@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/todoly.rb",
29
+ "spec/spec_helper.rb",
30
+ "spec/todoly_spec.rb",
31
+ "todoly.gemspec"
32
+ ]
33
+ s.homepage = %q{http://github.com/nagachika/ruby-todoly}
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{todo.ly REST API Library}
38
+ s.test_files = [
39
+ "spec/spec_helper.rb",
40
+ "spec/todoly_spec.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
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<rest-client>, ["> 0"])
49
+ s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
52
+ s.add_development_dependency(%q<fakeweb>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<rest-client>, ["> 0"])
55
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
58
+ s.add_dependency(%q<fakeweb>, [">= 0"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<rest-client>, ["> 0"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
65
+ s.add_dependency(%q<fakeweb>, [">= 0"])
66
+ end
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: todoly
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 0
9
+ version: 0.0.0
10
+ platform: ruby
11
+ authors:
12
+ - nagachika
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-15 00:00:00 +09:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rest-client
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">"
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 2
42
+ - 1
43
+ - 0
44
+ version: 2.1.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 0
58
+ - 0
59
+ version: 1.0.0
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: jeweler
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 1
72
+ - 5
73
+ - 1
74
+ version: 1.5.1
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: fakeweb
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *id005
91
+ description: todo.ly REST API Library
92
+ email: nagachika00@gmail.com
93
+ executables: []
94
+
95
+ extensions: []
96
+
97
+ extra_rdoc_files:
98
+ - LICENSE.txt
99
+ - README.rdoc
100
+ files:
101
+ - .document
102
+ - .rspec
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE.txt
106
+ - README.rdoc
107
+ - Rakefile
108
+ - VERSION
109
+ - lib/todoly.rb
110
+ - spec/spec_helper.rb
111
+ - spec/todoly_spec.rb
112
+ - todoly.gemspec
113
+ has_rdoc: true
114
+ homepage: http://github.com/nagachika/ruby-todoly
115
+ licenses:
116
+ - MIT
117
+ post_install_message:
118
+ rdoc_options: []
119
+
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 825769427
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ segments:
137
+ - 0
138
+ version: "0"
139
+ requirements: []
140
+
141
+ rubyforge_project:
142
+ rubygems_version: 1.3.7
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: todo.ly REST API Library
146
+ test_files:
147
+ - spec/spec_helper.rb
148
+ - spec/todoly_spec.rb