pipeline_deals 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa645959e30f4060918bda3bb8c99a3320b02f74
4
- data.tar.gz: 3c60d12af49949beb76d55256d02f4cb70d6a31d
3
+ metadata.gz: a67900528bf5064dfa64ec512223b71339038570
4
+ data.tar.gz: deb94273d3dc4f75a8dcd556d931fe931ab03f3b
5
5
  SHA512:
6
- metadata.gz: cb06fe1c651924150260948a232b0732e768e2f8c5cb1917900d12728060caef6b9abac23387210a12e5029bb136a8bfa762056355ef4a37e148d398cda83728
7
- data.tar.gz: 38f8bbc3365c919fc7b8ecd98c1bf2e4534e950f9ca3a8eeb9550ce15708dc40c3fcb4770b45218b282e197d60a98004a4812346fa7ae5f6640db34cb6161bed
6
+ metadata.gz: 66474587c6d5a7caafa88d5e6f266255dbde36e366da28b8ae37b96d30614f2a1bf3312fb2cb6eb66e00d2296d1167f1d829fcba518da4fb19c9a9bc3e32aad6
7
+ data.tar.gz: 7e5f7cb83b235555c53813c452b7cafedb97ae2dc9ec89c62c87f8a8987b7d64932001cd9a4bddc9bce479ce508836480f2bbef03a1d807c2d95e0c0d7947cc7
data/README.md CHANGED
@@ -21,7 +21,9 @@ Or install it yourself as:
21
21
  First and foremost, register your api key:
22
22
 
23
23
  ```ruby
24
- PipelineDeals.api_key = 'abcd1234'
24
+ PipelineDeals.configure do |config|
25
+ config.api_key = 'abcd1234'
26
+ end
25
27
  ```
26
28
 
27
29
  ## Getting a single deal, person, or company:
@@ -7,19 +7,21 @@ require_relative 'pipeline_deals/resources/definitions'
7
7
  Dir[File.dirname(__FILE__) + '/resources/*.rb'].each {|file| p "requring #{file}"; require file }
8
8
 
9
9
  module PipelineDeals
10
- def self.api_key
11
- @api_key
12
- end
10
+ class << self
11
+ attr_accessor :app_key, :api_key, :app_version
13
12
 
14
- def self.api_key=(api_key)
15
- @api_key = api_key
16
- end
13
+ def site
14
+ PipelineDeals::Resource.site
15
+ end
16
+
17
+ def site=(site)
18
+ PipelineDeals::Resource.site = site
19
+ end
17
20
 
18
- def self.app_key
19
- @app_key
20
21
  end
21
22
 
22
- def self.app_key=(app_key)
23
- @app_key = app_key
23
+ def self.configure
24
+ yield self
25
+ true
24
26
  end
25
27
  end
@@ -4,30 +4,25 @@ module PipelineDeals
4
4
  self.prefix = "/api/v3/"
5
5
  self.collection_parser = PipelineDeals::Collection
6
6
 
7
-
8
7
  def self.find(*arguments)
9
8
  scope = arguments.slice!(0)
10
9
  options = arguments.slice!(0) || {}
11
10
 
12
- self.add_params(options, app_key: PipelineDeals.app_key) if PipelineDeals.app_key
13
- self.add_params(options, api_key: PipelineDeals.api_key)
11
+ add_keys(options[:params] ||= {})
14
12
 
15
13
  super(scope, options)
16
14
  end
17
15
 
18
16
  def save
19
- prefix_options[:app_key] = PipelineDeals.app_key if PipelineDeals.app_key
20
- prefix_options[:api_key] = PipelineDeals.api_key
17
+ PipelineDeals::Resource.add_keys(prefix_options)
21
18
  self.include_root_in_json = true
22
19
  super
23
20
  end
24
21
 
25
- def self.add_params(options, params)
26
- if options[:params]
27
- options[:params].merge!(params)
28
- else
29
- options.merge!({params: params})
30
- end
22
+ def self.add_keys(hash)
23
+ hash[:app_key] = PipelineDeals.app_key if PipelineDeals.app_key
24
+ hash[:app_version] = PipelineDeals.app_version if PipelineDeals.app_version
25
+ hash[:api_key] = PipelineDeals.api_key
31
26
  end
32
27
  end
33
28
  end
@@ -0,0 +1,9 @@
1
+ module PipelineDeals
2
+ class Account < PipelineDeals::Resource
3
+ include ActiveResource::Singleton
4
+ def self.account(options = {})
5
+ add_keys(options[:params] ||= {})
6
+ find(options)
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module PipelineDeals
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe PipelineDeals do
4
+ describe '#configure' do
5
+ it 'honors api_key=' do
6
+ PipelineDeals.configure {|c| c.api_key = 'xyz' }
7
+ expect(PipelineDeals.api_key).to eq 'xyz'
8
+ end
9
+ it 'honors app_key=' do
10
+ PipelineDeals.configure {|c| c.app_key = 'xyz' }
11
+ expect(PipelineDeals.app_key).to eq 'xyz'
12
+ end
13
+ it 'honors site=' do
14
+ PipelineDeals.configure {|c| c.site = 'http://localhost:3000' }
15
+ expect(PipelineDeals::Resource.site.to_s).to eq 'http://localhost:3000'
16
+ end
17
+ end
18
+ end
@@ -14,8 +14,10 @@ require 'support/has_calendar_entries'
14
14
  require 'support/has_people'
15
15
  require 'support/has_deals'
16
16
 
17
- PipelineDeals::Resource.site = ENV['PIPELINEDEALS_URL'] || "http://localhost:3000"
18
- PipelineDeals.api_key = ENV['PIPELINEDEALS_API_KEY'] || 'iJHyFkMUBSfjUovt29'
17
+ PipelineDeals.configure do |c|
18
+ c.site = ENV['PIPELINEDEALS_URL'] || "http://localhost:3000"
19
+ c.api_key = ENV['PIPELINEDEALS_API_KEY'] || 'iJHyFkMUBSfjUovt29'
20
+ end
19
21
 
20
22
  #ActiveResource::Base.logger = Logger.new(STDOUT)
21
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipeline_deals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Ammons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -85,6 +85,7 @@ files:
85
85
  - lib/pipeline_deals/collection.rb
86
86
  - lib/pipeline_deals/resource.rb
87
87
  - lib/pipeline_deals/resources.rb
88
+ - lib/pipeline_deals/resources/account.rb
88
89
  - lib/pipeline_deals/resources/calendar_entry.rb
89
90
  - lib/pipeline_deals/resources/company.rb
90
91
  - lib/pipeline_deals/resources/company_custom_field_label.rb
@@ -152,6 +153,7 @@ files:
152
153
  - spec/pipeline_deals/custom_fields_spec.rb
153
154
  - spec/pipeline_deals/deals_spec.rb
154
155
  - spec/pipeline_deals/people_spec.rb
156
+ - spec/pipeline_deals_spec.rb
155
157
  - spec/spec_helper.rb
156
158
  - spec/support/has_calendar_entries.rb
157
159
  - spec/support/has_deals.rb
@@ -230,6 +232,7 @@ test_files:
230
232
  - spec/pipeline_deals/custom_fields_spec.rb
231
233
  - spec/pipeline_deals/deals_spec.rb
232
234
  - spec/pipeline_deals/people_spec.rb
235
+ - spec/pipeline_deals_spec.rb
233
236
  - spec/spec_helper.rb
234
237
  - spec/support/has_calendar_entries.rb
235
238
  - spec/support/has_deals.rb