bcx 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bcx.gemspec
4
4
  gemspec
5
-
6
- gem 'rapidash', github: 'paulspringett/rapidash', branch: 'error-handling'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Bcx
2
2
 
3
- > NB. This is still alpha software and may not work as expected. It's also missing a lot of the Basecamp endpoints. Please feel free [to contribute!](#contributing)
3
+ > NB. This gem is missing a lot of the Basecamp endpoints. Please feel free [to contribute!](#contributing)
4
4
 
5
5
  Fully-fledged Ruby API wrapper for Basecamp Next
6
6
 
@@ -47,7 +47,12 @@ You can get a `client_id` and `client_secret` from https://integrate.37signals.c
47
47
 
48
48
  ### Resources
49
49
 
50
- See the [full resource documentation](#todo) for all available API endpoints.
50
+ The following resources are fully implemented and tested.
51
+
52
+ * [People](http://paulspringett.github.io/bcx/docs/person.html)
53
+ * [Projects](http://paulspringett.github.io/bcx/docs/project.html)
54
+ * [Todolists](http://paulspringett.github.io/bcx/docs/todolist.html)
55
+ * [Todos](http://paulspringett.github.io/bcx/docs/todo.html)
51
56
 
52
57
  #### Bang operators
53
58
 
@@ -99,14 +104,8 @@ See the full [annotated source code](http://paulspringett.github.io/bcx).
99
104
  The docs are generated using [Docco](http://jashkenas.github.io/docco/). To generate the docs, run:
100
105
 
101
106
  ```bash
102
- $ git checkout master
103
107
  $ npm install -g docco
104
- $ docco lib/**/*.rb
105
- $ git commit -am "Updated docs"
106
-
107
- $ git checkout gh-pages
108
- $ git checkout master -- docs/ # Copy docs changes across and stage
109
- $ git commit -m "Updated docs on gh-pages"
108
+ $ rake docs:generate
110
109
  ```
111
110
 
112
111
  ### Contributing
data/Rakefile CHANGED
@@ -4,3 +4,5 @@ require 'rspec/core/rake_task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  task default: [:spec]
7
+
8
+ import 'lib/tasks/docs.rake'
data/bcx.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Bcx::VERSION
17
17
 
18
- gem.add_runtime_dependency 'rapidash', '~> 0.2.0'
18
+ gem.add_runtime_dependency 'rapidash', '0.3.0.beta'
19
19
 
20
20
  gem.add_development_dependency 'rake'
21
21
  gem.add_development_dependency 'rspec'
@@ -19,46 +19,11 @@
19
19
  <div id="jump_page">
20
20
 
21
21
 
22
- <a class="source" href="bcx.html">
23
- bcx.rb
24
- </a>
25
-
26
-
27
- <a class="source" href="http.html">
28
- http.rb
29
- </a>
30
-
31
-
32
- <a class="source" href="oauth.html">
33
- oauth.rb
34
- </a>
35
-
36
-
37
22
  <a class="source" href="configuration.html">
38
23
  configuration.rb
39
24
  </a>
40
25
 
41
26
 
42
- <a class="source" href="person.html">
43
- person.rb
44
- </a>
45
-
46
-
47
- <a class="source" href="project.html">
48
- project.rb
49
- </a>
50
-
51
-
52
- <a class="source" href="todo.html">
53
- todo.rb
54
- </a>
55
-
56
-
57
- <a class="source" href="todolist.html">
58
- todolist.rb
59
- </a>
60
-
61
-
62
27
  <a class="source" href="response_error.html">
63
28
  response_error.rb
64
29
  </a>
@@ -19,46 +19,11 @@
19
19
  <div id="jump_page">
20
20
 
21
21
 
22
- <a class="source" href="bcx.html">
23
- bcx.rb
24
- </a>
25
-
26
-
27
- <a class="source" href="http.html">
28
- http.rb
29
- </a>
30
-
31
-
32
- <a class="source" href="oauth.html">
33
- oauth.rb
34
- </a>
35
-
36
-
37
22
  <a class="source" href="configuration.html">
38
23
  configuration.rb
39
24
  </a>
40
25
 
41
26
 
42
- <a class="source" href="person.html">
43
- person.rb
44
- </a>
45
-
46
-
47
- <a class="source" href="project.html">
48
- project.rb
49
- </a>
50
-
51
-
52
- <a class="source" href="todo.html">
53
- todo.rb
54
- </a>
55
-
56
-
57
- <a class="source" href="todolist.html">
58
- todolist.rb
59
- </a>
60
-
61
-
62
27
  <a class="source" href="response_error.html">
63
28
  response_error.rb
64
29
  </a>
data/docs/version.html CHANGED
@@ -19,46 +19,11 @@
19
19
  <div id="jump_page">
20
20
 
21
21
 
22
- <a class="source" href="bcx.html">
23
- bcx.rb
24
- </a>
25
-
26
-
27
- <a class="source" href="http.html">
28
- http.rb
29
- </a>
30
-
31
-
32
- <a class="source" href="oauth.html">
33
- oauth.rb
34
- </a>
35
-
36
-
37
22
  <a class="source" href="configuration.html">
38
23
  configuration.rb
39
24
  </a>
40
25
 
41
26
 
42
- <a class="source" href="person.html">
43
- person.rb
44
- </a>
45
-
46
-
47
- <a class="source" href="project.html">
48
- project.rb
49
- </a>
50
-
51
-
52
- <a class="source" href="todo.html">
53
- todo.rb
54
- </a>
55
-
56
-
57
- <a class="source" href="todolist.html">
58
- todolist.rb
59
- </a>
60
-
61
-
62
27
  <a class="source" href="response_error.html">
63
28
  response_error.rb
64
29
  </a>
@@ -92,7 +57,7 @@
92
57
  </div>
93
58
 
94
59
  <div class="content"><div class='highlight'><pre><span class="class"><span class="keyword">module</span> <span class="title">Bcx</span></span>
95
- <span class="constant">VERSION</span> = <span class="string">"0.0.2"</span>
60
+ <span class="constant">VERSION</span> = <span class="string">"0.1.0"</span>
96
61
  <span class="keyword">end</span></pre></div></div>
97
62
 
98
63
  </li>
@@ -4,7 +4,7 @@ module Bcx
4
4
  method :http
5
5
 
6
6
  extension :json
7
- encode_post_data_with :json
7
+ encode_request_with :json
8
8
 
9
9
  raise_errors
10
10
 
@@ -4,7 +4,7 @@ module Bcx
4
4
  method :oauth
5
5
 
6
6
  extension :json
7
- encode_post_data_with :json
7
+ encode_request_with :json
8
8
 
9
9
  raise_errors
10
10
 
@@ -1,4 +1,5 @@
1
- # `Bcx::Resources::Person`
1
+ # ## People
2
+ #
2
3
  # Provides access to people resource
3
4
  #
4
5
  # #### Get all people on the account
@@ -1,39 +1,39 @@
1
+ # ## Projects
2
+ #
3
+ # Provides access to projects resoource and other nested resources
4
+ #
5
+ # #### Fetch all projects
6
+ # `GET /projects.json`
7
+ #
8
+ # client.projects!
9
+ #
10
+ # #### Fetch archived projects
11
+ # `GET /projects/archived.json`
12
+ #
13
+ # clients.projects.archived!
14
+ #
15
+ # #### Fetch single project with ID of 123
16
+ # `GET /projects/123.json`
17
+ #
18
+ # client.projects!(123)
19
+ #
20
+ # #### Create a project
21
+ # `POST /projects.json`
22
+ #
23
+ # client.projects.create!(name: 'Acme project', description: 'This is a new project')
24
+ #
25
+ # #### Update an existing project
26
+ # `PUT /projects/123.json`
27
+ #
28
+ # client.projects(123).update!(description: 'A new description')
29
+ #
30
+ # #### Delete a project
31
+ # `DELETE /projects/123.json`
32
+ #
33
+ # client.projects(123).delete!
34
+ #
1
35
  module Bcx
2
36
  module Resources
3
-
4
- # Bcx::Resources::Project
5
- # Provides access to projects resoource and other nested resources
6
- #
7
- # Fetch all projects
8
- # GET /projects.json
9
- #
10
- # client.projects!
11
- #
12
- # Fetch archived projects
13
- # GET /projects/archived.json
14
- #
15
- # clients.projects.archived!
16
- #
17
- # Fetch single project with ID of 123
18
- # GET /projects/123.json
19
- #
20
- # client.projects!(123)
21
- #
22
- # Create a project
23
- # POST /projects.json
24
- #
25
- # client.projects.create!(name: 'Acme project', description: 'This is a new project')
26
- #
27
- # Update an existing project
28
- # PUT /projects/123.json
29
- #
30
- # client.projects(123).update!(description: 'A new description')
31
- #
32
- # Delete a project
33
- # DELETE /projects/123.json
34
- #
35
- # client.projects(123).delete!
36
- #
37
37
  class Project < Rapidash::Base
38
38
  resource :todolists
39
39
  resource :todos
@@ -1,36 +1,36 @@
1
+ # ## Todo
2
+ #
3
+ # Provides access to todolist resoource both at the client level and per-project
4
+ #
5
+ # #### Get todos for a todolist
6
+ # `GET /todolists/1.json`
7
+ #
8
+ # todolist = client.todolists!(1)
9
+ # todolist.todos.remaining
10
+ # todolist.todos.completed
11
+ #
12
+ # #### Get a specific todo
13
+ # `GET /projects/1/todos/2.json`
14
+ #
15
+ # client.projects(1).todos!(2)
16
+ #
17
+ # #### Create a todo
18
+ # `POST /projects/1/todolists/2/todos.json`
19
+ #
20
+ # client.projects(1).todolists(2).todos.create!(content: 'Update copy text')
21
+ #
22
+ # #### Update a todo
23
+ # `PUT /projects/1/todos/2.json`
24
+ #
25
+ # client.projects(1).todos(2).update!(completed: true)
26
+ #
27
+ # #### Delete a todo
28
+ # `DELETE /projects/1/todos/2.json`
29
+ #
30
+ # client.projects(1).todos(2).delete!
31
+ #
1
32
  module Bcx
2
33
  module Resources
3
-
4
- # Bcx::Resources::Todo
5
- # Provides access to todolist resoource both at the client level and per-project
6
- #
7
- # Get todos for a todolist
8
- # GET /todolists/1.json
9
- #
10
- # todolist = client.todolists!(1)
11
- # todolist.todos.remaining
12
- # todolist.todos.completed
13
- #
14
- # Get a specific todo
15
- # GET /projects/1/todos/2.json
16
- #
17
- # client.projects(1).todos!(2)
18
- #
19
- # Create a todo
20
- # POST /projects/1/todolists/2/todos.json
21
- #
22
- # client.projects(1).todolists(2).todos.create!(content: 'Update copy text')
23
- #
24
- # Update a todo
25
- # PUT /projects/1/todos/2.json
26
- #
27
- # client.projects(1).todos(2).update!(completed: true)
28
- #
29
- # Delete a todo
30
- # DELETE /projects/1/todos/2.json
31
- #
32
- # client.projects(1).todos(2).delete!
33
- #
34
34
  class Todo < Rapidash::Base
35
35
  end
36
36
  end
@@ -1,49 +1,49 @@
1
+ # ## Todolists
2
+ #
3
+ # Provides access to todolist resoource both at the client level and per-project
4
+ #
5
+ # #### Get all todolists for a project
6
+ # `GET /projects/123/todolists.json`
7
+ #
8
+ # client.projects(123).todolists!
9
+ #
10
+ # #### Get all completed todolists for a project
11
+ # `GET /projects/1/todolists/completed.json`
12
+ #
13
+ # client.projects(123).todolists.completed!
14
+ #
15
+ # #### Get todolists for all projects
16
+ # `GET /todolists.json`
17
+ #
18
+ # client.todolists!
19
+ #
20
+ # #### Get completed todolists for all projects
21
+ # `GET /todolists/completed.json`
22
+ #
23
+ # client.todolists.completed!
24
+ #
25
+ # #### Get specific todolist including the todos
26
+ # `GET /projects/123/todolists/456.json`
27
+ #
28
+ # client.projects(123).todolists!(456)
29
+ #
30
+ # #### Create a new todolist
31
+ # `POST /projects/1/todolists.json`
32
+ #
33
+ # client.projects(123).todolists.create!(name: 'My todolist', description: 'This is a todolist')
34
+ #
35
+ # #### Update an existing todolist
36
+ # `PUT /projects/123/todolists/456.json`
37
+ #
38
+ # client.projects(123).todolists(456).update!(name: 'Updated todolist')
39
+ #
40
+ # #### Delete a todolist
41
+ # `DELETE /projects/123/todolists/456.json`
42
+ #
43
+ # client.projects(123).todolists(456).delete!
44
+ #
1
45
  module Bcx
2
46
  module Resources
3
-
4
- # Bcx::Resources::Todolist
5
- # Provides access to todolist resoource both at the client level and per-project
6
- #
7
- # Get all todolists for a project
8
- # GET /projects/123/todolists.json
9
- #
10
- # client.projects(123).todolists!
11
- #
12
- # Get all completed todolists for a project
13
- # GET /projects/1/todolists/completed.json
14
- #
15
- # client.projects(123).todolists.completed!
16
- #
17
- # Get todolists for all projects
18
- # GET /todolists.json
19
- #
20
- # client.todolists!
21
- #
22
- # Get completed todolists for all projects
23
- # GET /todolists/completed.json
24
- #
25
- # client.todolists.completed!
26
- #
27
- # Get specific todolist including the todos
28
- # GET /projects/123/todolists/456.json
29
- #
30
- # client.projects(123).todolists!(456)
31
- #
32
- # Create a new todolist
33
- # POST /projects/1/todolists.json
34
- #
35
- # client.projects(123).todolists.create!(name: 'My todolist', description: 'This is a todolist')
36
- #
37
- # Update an existing todolist
38
- # PUT /projects/123/todolists/456.json
39
- #
40
- # client.projects(123).todolists(456).update!(name: 'Updated todolist')
41
- #
42
- # Delete a todolist
43
- # DELETE /projects/123/todolists/456.json
44
- #
45
- # client.projects(123).todolists(456).delete!
46
- #
47
47
  class Todolist < Rapidash::Base
48
48
  resource :todos, class_name: 'Bcx::Resources::Todo'
49
49
 
data/lib/bcx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bcx
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/bcx.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'rapidash'
2
+ require 'rapidash/collection'
2
3
  require 'bcx/version'
3
4
 
4
- # # Bcx
5
+ # ## Bcx
5
6
  # Fully-fledged Ruby API wrapper for Basecamp Next
6
7
  #
7
8
  # See the [README](https://github.com/paulspringett/bcx#readme) for usage
@@ -0,0 +1,33 @@
1
+ module Rapidash
2
+ module Collection
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def collection(name, attrs = {})
10
+ path = attrs[:path] || name.to_s
11
+ path.gsub!(/^\//, '')
12
+
13
+ method = attrs[:method] || :get
14
+
15
+ define_method("#{name}!") do
16
+ original_url = @url
17
+
18
+ @url += "/#{path}"
19
+ @options[:method] = method
20
+ result = call!
21
+
22
+ @url = original_url
23
+
24
+ result
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ class Rapidash::Base
32
+ include Rapidash::Collection
33
+ end
@@ -0,0 +1,41 @@
1
+ namespace :docs do
2
+ desc "Generate the latest docs from the source code and add to gh-pages"
3
+ task :generate do
4
+ ensure_clean_git
5
+ run "git checkout #{branch}"
6
+ run "docco lib/**/*.rb"
7
+ run "git commit -am 'Updated documentation'"
8
+ run "git checkout gh-pages"
9
+ run "git checkout #{branch} -- docs/" # Copy docs changes across and stage
10
+ run "git commit -am 'Updated docs on gh-pages'"
11
+ run "git checkout #{branch}"
12
+ end
13
+
14
+ desc "Deploy docs to GitHub pages"
15
+ task :deploy do
16
+ ensure_clean_git
17
+ run "git checkout gh-pages"
18
+ run "git push origin gh-pages"
19
+ run "git checkout #{branch}"
20
+ end
21
+ end
22
+
23
+ def branch
24
+ @branch ||= `git symbolic-ref HEAD 2> /dev/null`.gsub("refs/heads/", "").strip
25
+ end
26
+
27
+ def git_dirty?
28
+ `[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]`
29
+ dirty = $?.success?
30
+ end
31
+
32
+ def ensure_clean_git
33
+ if git_dirty?
34
+ raise "Can't deploy without a clean git status."
35
+ end
36
+ end
37
+
38
+ def run(command)
39
+ puts " #{command}"
40
+ %x{#{command}}
41
+ end