campi 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5208d95be646bbea3dab5600ed089881322b719
4
+ data.tar.gz: 2f5226906156de90a203917982f386fe471277e3
5
+ SHA512:
6
+ metadata.gz: 17c570f6c7f8a121303020a50ac50658d1a621b9de4ba211b3cd874fb16e0205c00901b5f7ba7d77b722761643ba31154103982611ccb3741baa7adda79d7433
7
+ data.tar.gz: 1619b11de3def1da0b530e1cd7c95b62ecd8886b6a9c607c9d70589bfb7598130b80e9b9f50b93f442b27dbfbd93a930e6af7dfe998dccb8d65923dfcf335155
@@ -0,0 +1,5 @@
1
+ BASECAMP_ID=99999999
2
+ USERNAME=example@example.com
3
+ PASSWORD=1234567
4
+ APPLICATION_NAME=MyApplication
5
+ APPLICATION_CONTACT=me@example.com
@@ -0,0 +1,19 @@
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
18
+ .idea
19
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in campi.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tomás Augusto Müller
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.
@@ -0,0 +1,40 @@
1
+ # Campi
2
+
3
+ Ruby API Wrapper for the new Basecamp API.
4
+
5
+ The all-new Basecamp has an all-new API. It is not compatible with the Basecamp Classic API.
6
+
7
+ Based on [official Basecamp API documentation](https://github.com/basecamp/bcx-api).
8
+
9
+ ## Campi?
10
+
11
+ *Campi* is the plural form of campus. The goal of this gem is give you all the necessary powers to extend multiply Basecamp.
12
+ So, you get it! In some way, pluralize Basecamp :+1:.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'campi'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install campi
27
+
28
+ ## Usage
29
+
30
+ :warning: **WIP** :warning:
31
+
32
+ Later on, usage instructions will be here.
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( http://github.com/tomasmuller/campi/fork )
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
@@ -0,0 +1,3 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'campi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'campi'
8
+ spec.version = Campi::VERSION.dup
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ['Tomás Augusto Müller']
11
+ spec.email = ['tomas.am@gmail.com']
12
+ spec.summary = %q{Ruby API Wrapper for the new Basecamp API.}
13
+ spec.description = %q{The all-new Basecamp has an all-new API. It is not compatible with the Basecamp Classic API.}
14
+ spec.homepage = 'https://github.com/tomasmuller/campi'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'httparty', '0.13.0'
23
+ spec.add_dependency 'activesupport', '4.0.2'
24
+ spec.add_dependency 'dalli', '2.7.0'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.5'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec', '2.14.1'
29
+ spec.add_development_dependency 'factory_girl', '4.4.0'
30
+ spec.add_development_dependency 'pry', '0.9.12.6'
31
+ spec.add_development_dependency 'awesome_print', '1.2.0'
32
+ spec.add_development_dependency 'dotenv', '0.9.0'
33
+
34
+ end
@@ -0,0 +1,51 @@
1
+ require 'httparty'
2
+ require 'campi/version'
3
+ require 'active_support/dependencies/autoload'
4
+ require 'active_support/cache'
5
+ require 'dalli'
6
+
7
+ module Campi
8
+ extend ActiveSupport::Autoload
9
+ autoload :Client
10
+
11
+ class << self
12
+ attr_accessor :configuration, :cache
13
+ end
14
+
15
+ def self.configure
16
+ self.configuration ||= Configuration.new
17
+ yield(configuration)
18
+ end
19
+
20
+ def self.configure_cache
21
+ self.cache ||= Cache.new
22
+ yield(cache)
23
+ end
24
+
25
+ class Configuration
26
+ attr_accessor :basecamp_id, :username, :password, :application_name, :application_contact
27
+
28
+ def initialize
29
+ @basecamp_id = nil
30
+ @username = nil
31
+ @password = nil
32
+ @application_name = nil
33
+ @application_contact = nil
34
+ end
35
+ end
36
+
37
+ class Cache
38
+ attr_accessor :store_option, :parameters
39
+ attr_reader :store
40
+
41
+ def initialize
42
+ @store_option = nil
43
+ @parameters = nil
44
+ @store = nil
45
+ end
46
+
47
+ def store
48
+ @store ||= ActiveSupport::Cache.lookup_store(@store_option, @parameters)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,69 @@
1
+ module Campi
2
+ class Client
3
+ include HTTParty
4
+
5
+ attr_reader :data
6
+
7
+ ##
8
+ # Valid arguments to build the API arguments path.
9
+ #
10
+ API_ARGUMENTS = [:projects, :calendars]
11
+
12
+ def initialize
13
+ self.class.base_uri "https://basecamp.com/#{Campi.configuration.basecamp_id}/api/v1"
14
+
15
+ self.class.headers(
16
+ 'User-Agent' => "#{Campi.configuration.application_name} (#{Campi.configuration.application_contact})",
17
+ 'Content-Type' => 'application/json')
18
+
19
+ self.class.basic_auth(Campi.configuration.username, Campi.configuration.password)
20
+
21
+ @data = {}
22
+ end
23
+
24
+ def respond_to?(method_name)
25
+ API_ARGUMENTS.include?(method_name) || super
26
+ end
27
+
28
+ def respond_to_missing?(method_name, include_private = false)
29
+ API_ARGUMENTS.include?(method_name) || super
30
+ end
31
+
32
+ def method_missing(method_name, *arguments, &block)
33
+ if API_ARGUMENTS.include?(method_name)
34
+ @data.merge!({method_name => arguments[0]})
35
+ self
36
+ end
37
+ end
38
+
39
+ ##
40
+ # Use merged data to compose the API arguments path.
41
+ #
42
+ def api_arguments
43
+ arguments = ''
44
+ @data.each do |sym, value|
45
+ arguments += "/#{sym.to_s}/#{value}"
46
+ end
47
+ arguments
48
+ end
49
+
50
+ ##
51
+ # client = Campi::Client.new
52
+ # client.project('999999999-my-project').get_accesses
53
+ #
54
+ def get_accesses
55
+ path = "#{api_arguments}/accesses.json"
56
+ get(path)
57
+ end
58
+
59
+ private
60
+
61
+ def get(path, options = {})
62
+ self.class.get(path, options)
63
+ end
64
+
65
+ def post(path, options = {})
66
+ self.class.post(path, options)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ module Campi
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Campi do
4
+
5
+ describe '.configure' do
6
+ it { expect(Campi.configuration.basecamp_id).to eq ENV['BASECAMP_ID'] }
7
+ it { expect(Campi.configuration.basecamp_id).not_to be_nil }
8
+
9
+ it { expect(Campi.configuration.username).to eq ENV['USERNAME'] }
10
+ it { expect(Campi.configuration.username).not_to be_nil }
11
+
12
+ it { expect(Campi.configuration.password).to eq ENV['PASSWORD'] }
13
+ it { expect(Campi.configuration.password).not_to be_nil }
14
+
15
+ it { expect(Campi.configuration.application_name).to eq ENV['APPLICATION_NAME'] }
16
+ it { expect(Campi.configuration.application_name).not_to be_nil }
17
+
18
+ it { expect(Campi.configuration.application_contact).to eq ENV['APPLICATION_CONTACT'] }
19
+ it { expect(Campi.configuration.application_contact).not_to be_nil }
20
+ end
21
+
22
+ describe '.configure_cache' do
23
+ it { expect(Campi.cache.store_option).to eq :mem_cache_store }
24
+
25
+ it { expect(Campi.cache.parameters).to eq ['localhost:11211'] }
26
+
27
+ it { expect(Campi.cache).to be_an_instance_of Campi::Cache }
28
+
29
+ it { expect(Campi.cache.store).to be_an_instance_of ActiveSupport::Cache::MemCacheStore }
30
+ end
31
+
32
+ end
File without changes
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Campi::Client do
4
+
5
+ let(:client) { Campi::Client.new }
6
+
7
+ it { expect(client.class.base_uri).to eq "https://basecamp.com/#{Campi.configuration.basecamp_id}/api/v1" }
8
+
9
+ it { expect(client.class.headers).to eq ({
10
+ 'User-Agent' => "#{Campi.configuration.application_name} (#{Campi.configuration.application_contact})",
11
+ 'Content-Type' => 'application/json'})
12
+ }
13
+
14
+ it { expect(client.class.default_options[:basic_auth]).to eq ({
15
+ username: Campi.configuration.username, password: Campi.configuration.password})
16
+ }
17
+
18
+ describe Campi::Client::API_ARGUMENTS do
19
+ API_ARGUMENTS = [:projects, :calendars]
20
+ API_ARGUMENTS.each do |api_argument|
21
+ it { expect(client.respond_to?(api_argument)).to be_true }
22
+ end
23
+ end
24
+
25
+ describe '#api_arguments' do
26
+ before do
27
+ client.projects('123444-my-project')
28
+ end
29
+ it { expect(client.api_arguments).to eq '/projects/123444-my-project' }
30
+ end
31
+
32
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Campi do
4
+ it { expect(Campi::VERSION).to eq '0.0.2' }
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default, :development)
3
+
4
+ Dotenv.load
5
+
6
+ require 'campi'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each {|file| require file}
11
+
12
+ RSpec.configure do |config|
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.run_all_when_everything_filtered = true
15
+ config.filter_run :focus
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
@@ -0,0 +1,13 @@
1
+ Campi.configure do |config|
2
+ config.basecamp_id = ENV['BASECAMP_ID']
3
+ config.username = ENV['USERNAME']
4
+ config.password = ENV['PASSWORD']
5
+ config.application_name = ENV['APPLICATION_NAME']
6
+ config.application_contact = ENV['APPLICATION_CONTACT']
7
+ end
8
+
9
+ # See: http://api.rubyonrails.org/classes/ActiveSupport/Cache.html
10
+ Campi.configure_cache do |cache|
11
+ cache.store_option = :mem_cache_store
12
+ cache.parameters = ['localhost:11211']
13
+ end
@@ -0,0 +1,7 @@
1
+ # See: https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md
2
+ RSpec.configure do |config|
3
+ config.include FactoryGirl::Syntax::Methods
4
+ config.before(:suite) do
5
+ FactoryGirl.lint
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: campi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tomás Augusto Müller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: dalli
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.7.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.14.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.14.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: factory_girl
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 4.4.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 4.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.12.6
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.9.12.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: awesome_print
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 1.2.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 1.2.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: dotenv
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.9.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.9.0
153
+ description: The all-new Basecamp has an all-new API. It is not compatible with the
154
+ Basecamp Classic API.
155
+ email:
156
+ - tomas.am@gmail.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".env.sample"
162
+ - ".gitignore"
163
+ - ".rspec"
164
+ - Gemfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - campi.gemspec
169
+ - lib/campi.rb
170
+ - lib/campi/client.rb
171
+ - lib/campi/version.rb
172
+ - spec/campi_spec.rb
173
+ - spec/factories/.keep
174
+ - spec/lib/campi/client_spec.rb
175
+ - spec/lib/campi/version_spec.rb
176
+ - spec/spec_helper.rb
177
+ - spec/support/campi.rb
178
+ - spec/support/factory_girl.rb
179
+ homepage: https://github.com/tomasmuller/campi
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.2.2
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: Ruby API Wrapper for the new Basecamp API.
203
+ test_files:
204
+ - spec/campi_spec.rb
205
+ - spec/factories/.keep
206
+ - spec/lib/campi/client_spec.rb
207
+ - spec/lib/campi/version_spec.rb
208
+ - spec/spec_helper.rb
209
+ - spec/support/campi.rb
210
+ - spec/support/factory_girl.rb