basecrm 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5944afdba7dc0d91c937ab939bb6e1fb019e058f
4
- data.tar.gz: a1939878b665013a2a9591beea66f448e0b17a78
3
+ metadata.gz: 6e2f77ee02273e60432ee07afc45df2546472675
4
+ data.tar.gz: 23887aee3f8184ec91663fdf95eb0ab67ede5487
5
5
  SHA512:
6
- metadata.gz: 2d5710f54131a3461b6c7ae51fda0bf8e1f83bc8366e0406a2b901acb1853a6520b903b3c2cdfd24feea9c6362d520bbca213abb55cdc9c0f6a3b914e0d429b9
7
- data.tar.gz: 1e537e6befde7c148eb1c570cd602bc1abcd067c2594b06c45a374e516cacb56b19eab9443438f3ec716a0f1832341b6db67d46b631d5120fdcefeb765f69594
6
+ metadata.gz: 2d2ab3ddf64bad4837691302b17768c268c3aeee11d143cb5801eec61bfcd0f9d9dc5660570af6a4256f5a03f97f18dd5374d5909a0f32f70ce7d13ae2bed869
7
+ data.tar.gz: bac89ab72524eb5d5cd81a0d92af9eafd0c911c882d77583a83e80f9f534a6b3305ea2cdb3fc3dfbc7a2ad1c4c8162641546ca7a3a2fc33924920a85c9b5d48f
data/.travis.yml CHANGED
@@ -2,6 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - rbx-18mode
6
- - rbx-19mode
5
+ - 2.1.0
7
6
  script: "bundle exec rspec"
data/README.md CHANGED
@@ -4,9 +4,6 @@
4
4
 
5
5
  New and shiny client for the Base CRM API
6
6
 
7
- NOTE: This is still a very early release. There might be a lot of
8
- breaking changes. You have been warned.
9
-
10
7
  ## Installation
11
8
 
12
9
  The gem available via Rubygems. To install it, use the following command:
data/lib/base_crm.rb CHANGED
@@ -2,6 +2,7 @@ require "api_client"
2
2
  require "base_crm/version"
3
3
  require "base_crm/config"
4
4
  require "base_crm/api_client_ext"
5
+ require "base_crm/custom_fieldable"
5
6
 
6
7
  module BaseCrm
7
8
 
@@ -18,7 +19,6 @@ module BaseCrm
18
19
  autoload :Task, "base_crm/task"
19
20
  autoload :Taskable, "base_crm/taskable"
20
21
  autoload :Lead, "base_crm/lead"
21
- autoload :CustomFieldable, "base_crm/custom_fieldable"
22
22
 
23
23
  end
24
24
 
@@ -4,7 +4,7 @@ module BaseCrm
4
4
  include BaseCrm::Resource
5
5
  include BaseCrm::Noteable
6
6
  include BaseCrm::Taskable
7
- include BaseCrm::CustomFieldable
7
+ include BaseCrm::CustomFieldable('custom_fields')
8
8
 
9
9
  namespace "contact"
10
10
 
@@ -1,35 +1,32 @@
1
1
  module BaseCrm
2
-
3
- module CustomFieldable
4
-
5
- def initialize(attributes, original_scope = nil)
6
- super
7
- simplify_custom_fields
8
- end
9
-
10
- def simplify_custom_fields
11
- fields = self['custom_fields'] || {}
12
- self['custom_fields'] = fields.inject(Hashie::Mash.new) do |memo, field|
13
- name, value = field
14
- memo[name] = value['value']
15
- memo
2
+ def self.CustomFieldable(custom_fields_field_name)
3
+ Module.new do
4
+ def initialize(attributes, original_scope = nil)
5
+ super
6
+ simplify_custom_fields
16
7
  end
17
- end
18
8
 
19
- private
9
+ define_method :simplify_custom_fields do
10
+ fields = self[custom_fields_field_name] || {}
11
+ self[custom_fields_field_name] = fields.inject(Hashie::Mash.new) do |memo, field|
12
+ name, value = field
13
+ memo[name] = value['value']
14
+ memo
15
+ end
16
+ end
20
17
 
21
- # Because custom fields are hashes, and hashes result in
22
- # new instances of BaseCrm::Contact, we end up with a stack level too deep
23
- # because simplify_custom_fields gets fired all the time
24
- def convert_value(val, duping=false) #:nodoc:
25
- if val.is_a?(Hash) or val.is_a?(::Hash)
26
- val
27
- else
28
- super
18
+ private
19
+
20
+ # Because custom fields are hashes, and hashes result in
21
+ # new instances of BaseCrm::Contact, we end up with a stack level too deep
22
+ # because simplify_custom_fields gets fired all the time
23
+ def convert_value(val, duping=false) #:nodoc:
24
+ if val.is_a?(Hash) or val.is_a?(::Hash)
25
+ val
26
+ else
27
+ super
28
+ end
29
29
  end
30
30
  end
31
-
32
31
  end
33
-
34
32
  end
35
-
data/lib/base_crm/lead.rb CHANGED
@@ -4,7 +4,7 @@ module BaseCrm
4
4
  include BaseCrm::Resource
5
5
  include BaseCrm::Noteable
6
6
  include BaseCrm::Taskable
7
- include BaseCrm::CustomFieldable
7
+ include BaseCrm::CustomFieldable('custom_field_values')
8
8
 
9
9
  namespace "lead"
10
10
 
@@ -1,3 +1,3 @@
1
1
  module BaseCrm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -65,10 +65,7 @@ describe BaseCrm::Deal do
65
65
  context "when it is not found" do
66
66
  before do
67
67
  subject.stub(:pass_headers).with(BaseCrm::Source).and_return(scope)
68
- scope.
69
- stub(:find).
70
- with(source_id).
71
- and_raise(ApiClient::Errors::NotFound)
68
+ scope.stub(:find).with(source_id)
72
69
  end
73
70
  it { subject.source.should == nil }
74
71
  end
@@ -109,10 +106,7 @@ describe BaseCrm::Deal do
109
106
  context "when it is not found" do
110
107
  before do
111
108
  subject.stub(:pass_headers).with(BaseCrm::Contact).and_return(scope)
112
- scope.
113
- stub(:find).
114
- with(entity_id).
115
- and_raise(ApiClient::Errors::NotFound)
109
+ scope.stub(:find).with(entity_id)
116
110
  end
117
111
  it { subject.contact.should == nil }
118
112
  end
@@ -22,7 +22,7 @@ describe BaseCrm::Lead do
22
22
  describe "simplify_custom_fields" do
23
23
 
24
24
  it "converts a hash into the value" do
25
- subject.custom_fields = {
25
+ subject.custom_field_values = {
26
26
  'test' => { 'value' => 'yes!' }
27
27
  }
28
28
  result = subject.simplify_custom_fields
@@ -21,9 +21,9 @@ shared_examples "noteable" do |noteable_type|
21
21
  end
22
22
 
23
23
  describe "#notes.create" do
24
- let(:message) { mock }
25
- let(:note) { mock }
26
- let(:fetch_scope) { mock }
24
+ let(:message) { double }
25
+ let(:note) { double }
26
+ let(:fetch_scope) { double }
27
27
 
28
28
  it "passes the token and applies the params" do
29
29
  subject.
@@ -46,9 +46,9 @@ shared_examples "noteable" do |noteable_type|
46
46
  end
47
47
 
48
48
  describe "#create_note" do
49
- let(:message) { mock }
50
- let(:notes) { mock }
51
- let(:note) { mock }
49
+ let(:message) { double }
50
+ let(:notes) { double }
51
+ let(:note) { double }
52
52
 
53
53
  it "creates a new note" do
54
54
  subject.should_receive(:notes).and_return(notes)
@@ -50,9 +50,9 @@ shared_examples "taskable" do |taskable_type|
50
50
  let(:params) do
51
51
  { :content => task_content }
52
52
  end
53
- let(:task_content) { mock }
54
- let(:tasks) { mock }
55
- let(:task) { mock }
53
+ let(:task_content) { double }
54
+ let(:tasks) { double }
55
+ let(:task) { double }
56
56
 
57
57
  it "creates a new task" do
58
58
  subject.should_receive(:tasks).and_return(tasks)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-14 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client