basecampx 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3@basecampx
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in basecampx.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Anton Zaytsev
2
+
3
+ MIT License
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.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Basecampx
2
+
3
+ The new Basecamp API Ruby wrapper.
4
+ Currently support only rails, feel free to help me get rid of Rails dependency.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'basecampx'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install basecampx
19
+
20
+ ## If you use Rails
21
+
22
+ Generate config file
23
+
24
+ $ rails g basecampx:install
25
+
26
+ Edit config file (config/basecampx.yaml) with your new basecamp login details
27
+
28
+ ## Usage
29
+
30
+ Get all people from account
31
+
32
+ Basecamp.people
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
41
+
42
+
43
+ ## Usefull links
44
+
45
+ The new Basecamp API https://github.com/37signals/bcx-api
46
+ The Basecamp Classic API https://github.com/37signals/basecamp-classic-api
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/basecampx.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'basecampx/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "basecampx"
8
+ gem.version = Basecampx::VERSION
9
+ gem.authors = ["Anton Zaytsev"]
10
+ gem.email = ["me@antonzaytsev.com"]
11
+ gem.description = %q{Basecamp new ruby api wrapper}
12
+ gem.summary = %q{Provides simple methods to work with basecamp new api}
13
+ gem.homepage = ""
14
+
15
+ gem.rubyforge_project = 'basecampx'
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+
22
+ # Dependencies
23
+ gem.add_runtime_dependency "httparty"
24
+ gem.add_runtime_dependency "json"
25
+ end
@@ -0,0 +1,93 @@
1
+ module Basecampx
2
+ class << self
3
+ def use! project=:default
4
+ @project = project
5
+ @details = YAML.load(File.read(File.join(Rails.root, 'config', 'basecampx.yaml')))
6
+ @connect_details = @details[project.to_s]
7
+ @account_endpoint = "https://basecamp.com/#{@connect_details['project_id']}/api/v#{@connect_details['api_version'] || 1}"
8
+
9
+ test_connection
10
+ end
11
+
12
+ def test_connection
13
+ true
14
+ end
15
+
16
+ def use_custom! username, password, project_id
17
+
18
+ end
19
+
20
+ #def initialize username='', password='', account_endpoint='https://basecamp.com/1908192/api/v1', app='Syllabuster Sync (http://sylly.co)'
21
+ # @username = username
22
+ # @password = password
23
+ # @account_endpoint = account_endpoint
24
+ # @app = app
25
+ #end
26
+
27
+ def params
28
+ account_endpoint
29
+
30
+ {
31
+ :basic_auth => {
32
+ :username => @connect_details['username'],
33
+ :password => @connect_details['password']
34
+ },
35
+ :headers => {
36
+ "User-Agent" => @connect_details['username']
37
+ }
38
+ }
39
+ end
40
+
41
+ def account_endpoint
42
+ if !@account_endpoint
43
+ self.use!
44
+ end
45
+
46
+ @account_endpoint
47
+ end
48
+
49
+ def handle response
50
+ if response.code == 200
51
+ JSON.parse(response.body)
52
+ else
53
+ raise Exception, response
54
+ end
55
+ end
56
+
57
+ def projects
58
+ self.request "#{account_endpoint}/projects.json"
59
+ end
60
+
61
+ def project id
62
+ response = HTTParty.get "#{@account_endpoint}/projects/#{id}.json", params
63
+ handle response
64
+ end
65
+
66
+ def todolists project_id
67
+ self.request "#{account_endpoint}/projects/#{project_id}/todolists.json"
68
+ end
69
+
70
+ def todolist project_id, todolist_id
71
+ response = HTTParty.get "#{@account_endpoint}/projects/#{project_id}/todolists/#{todolist_id}.json", params
72
+ handle response
73
+ end
74
+
75
+ def todos project_id, todo_id
76
+ self.request "#{@account_endpoint}/projects/#{project_id}/todos/#{todo_id}.json"
77
+ end
78
+
79
+ def people
80
+ json = self.request "#{account_endpoint}/people.json"
81
+ self::Person.parse json
82
+ end
83
+
84
+ def person account_id
85
+ json = self.request "#{@account_endpoint}/people/#{account_id}.json"
86
+ self::Person.new json
87
+ end
88
+
89
+ def request url
90
+ handle HTTParty.get url, params
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,42 @@
1
+ module Basecampx
2
+ class Person
3
+
4
+ attr_accessor :id, :name, :email_address, :admin, :created_at, :avatar_url, :url, :identity_id,
5
+ :events, :assigned_todos, :todo_list
6
+
7
+ def self.parse json
8
+ output = []
9
+
10
+ json.each do |user|
11
+ output << self.new(user)
12
+ end
13
+
14
+ output
15
+ end
16
+
17
+ def initialize args
18
+ self.update_details args
19
+ end
20
+
21
+ def update_details args
22
+ args.each do |key, value|
23
+ self.send(key.to_s+'=', value) if self.respond_to?((key.to_s+'=').to_s)
24
+ end
25
+ end
26
+
27
+ def todos
28
+ if self.assigned_todos.nil?
29
+ self.details
30
+ end
31
+
32
+ self.todo_list = Basecampx.request self.assigned_todos['url']
33
+ end
34
+
35
+ def details
36
+ resp = Basecampx.request self.url
37
+ update_details resp
38
+ self
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,6 @@
1
+ module Basecampx
2
+ class Todo
3
+
4
+ #attr_accessor :
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Basecampx
2
+ class TodoList
3
+
4
+ #attr_accessor :
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Basecampx
2
+ VERSION = "0.0.1"
3
+ end
data/lib/basecampx.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'yaml'
4
+
5
+ require "basecampx/version"
6
+ require 'basecampx/base'
7
+ require 'basecampx/resources/person'
8
+ require 'basecampx/resources/todo'
@@ -0,0 +1,27 @@
1
+ require 'rails/generators'
2
+
3
+ module Basecampx
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Copy Basecamp config file"
7
+ #argument :name, :type => :string, :default => "AdminUser"
8
+ #argument :password, :type => :string, :default => "AdminUser"
9
+
10
+ #hook_for :users, :default => "devise", :desc => "Admin user generator to run. Skip with --skip-users"
11
+
12
+ def self.source_root
13
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
14
+ end
15
+
16
+ def copy_initializer
17
+ #@underscored_user_name = name.underscore
18
+ #template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
19
+ end
20
+
21
+ def setup_directory
22
+ template 'basecampx.yaml', 'config/basecampx.yaml'
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ default:
2
+ username: 'Your@username.here'
3
+ password: 'username.password'
4
+ project_id: '1810845' # last part from project url https://basecamp.com/1810845
5
+ api_version: 1
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: basecampx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anton Zaytsev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Basecamp new ruby api wrapper
47
+ email:
48
+ - me@antonzaytsev.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rvmrc
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - basecampx.gemspec
60
+ - lib/basecampx.rb
61
+ - lib/basecampx/base.rb
62
+ - lib/basecampx/resources/person.rb
63
+ - lib/basecampx/resources/todo.rb
64
+ - lib/basecampx/resources/todo_list.rb
65
+ - lib/basecampx/version.rb
66
+ - lib/generators/basecampx/install/install_generator.rb
67
+ - lib/generators/basecampx/install/templates/basecampx.yaml
68
+ homepage: ''
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project: basecampx
88
+ rubygems_version: 1.8.24
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Provides simple methods to work with basecamp new api
92
+ test_files: []