highrise_mapper 0.0.2 → 0.0.3
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 +3 -0
- data/.travis.yml +3 -1
- data/Gemfile.lock +80 -0
- data/Rakefile +9 -1
- data/Readme.md +77 -4
- data/highrise_mapper.gemspec +2 -1
- data/lib/highrise_mapper/context.rb +0 -4
- data/lib/highrise_mapper/person.rb +0 -4
- data/lib/highrise_mapper/version.rb +1 -1
- data/spec/highrise_mapper_spec.rb +0 -2
- data/spec/person_spec.rb +23 -20
- data/spec/spec_helper.rb +13 -2
- data/spec/support/contact.rb +6 -1
- data/spec/support/saas_customer.rb +2 -3
- metadata +22 -7
- data/spec/support/helper.rb +0 -3
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
highrise_mapper (0.0.2)
|
5
|
+
highrise (~> 3.1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (4.0.0)
|
11
|
+
activesupport (= 4.0.0)
|
12
|
+
builder (~> 3.1.0)
|
13
|
+
erubis (~> 2.7.0)
|
14
|
+
rack (~> 1.5.2)
|
15
|
+
rack-test (~> 0.6.2)
|
16
|
+
activemodel (4.0.0)
|
17
|
+
activesupport (= 4.0.0)
|
18
|
+
builder (~> 3.1.0)
|
19
|
+
activeresource (4.0.0)
|
20
|
+
activemodel (~> 4.0)
|
21
|
+
activesupport (~> 4.0)
|
22
|
+
rails-observers (~> 0.1.1)
|
23
|
+
activesupport (4.0.0)
|
24
|
+
i18n (~> 0.6, >= 0.6.4)
|
25
|
+
minitest (~> 4.2)
|
26
|
+
multi_json (~> 1.3)
|
27
|
+
thread_safe (~> 0.1)
|
28
|
+
tzinfo (~> 0.3.37)
|
29
|
+
atomic (1.1.10)
|
30
|
+
builder (3.1.4)
|
31
|
+
coderay (1.0.9)
|
32
|
+
diff-lcs (1.2.4)
|
33
|
+
erubis (2.7.0)
|
34
|
+
highrise (3.1.0)
|
35
|
+
activeresource (~> 4.0.0)
|
36
|
+
i18n (0.6.4)
|
37
|
+
method_source (0.8.1)
|
38
|
+
minitest (4.7.5)
|
39
|
+
multi_json (1.7.7)
|
40
|
+
pry (0.9.12.2)
|
41
|
+
coderay (~> 1.0.5)
|
42
|
+
method_source (~> 0.8)
|
43
|
+
slop (~> 3.4)
|
44
|
+
pry-nav (0.2.3)
|
45
|
+
pry (~> 0.9.10)
|
46
|
+
rack (1.5.2)
|
47
|
+
rack-test (0.6.2)
|
48
|
+
rack (>= 1.0)
|
49
|
+
rails-observers (0.1.1)
|
50
|
+
railties (~> 4.0.0.beta)
|
51
|
+
railties (4.0.0)
|
52
|
+
actionpack (= 4.0.0)
|
53
|
+
activesupport (= 4.0.0)
|
54
|
+
rake (>= 0.8.7)
|
55
|
+
thor (>= 0.18.1, < 2.0)
|
56
|
+
rake (10.0.4)
|
57
|
+
rspec (2.13.0)
|
58
|
+
rspec-core (~> 2.13.0)
|
59
|
+
rspec-expectations (~> 2.13.0)
|
60
|
+
rspec-mocks (~> 2.13.0)
|
61
|
+
rspec-core (2.13.1)
|
62
|
+
rspec-expectations (2.13.0)
|
63
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
64
|
+
rspec-mocks (2.13.1)
|
65
|
+
slop (3.4.5)
|
66
|
+
thor (0.18.1)
|
67
|
+
thread_safe (0.1.0)
|
68
|
+
atomic
|
69
|
+
tzinfo (0.3.37)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
highrise_mapper!
|
76
|
+
pry
|
77
|
+
pry-nav
|
78
|
+
rake
|
79
|
+
rspec
|
80
|
+
rspec-mocks
|
data/Rakefile
CHANGED
@@ -4,4 +4,12 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
require "rspec/core/rake_task"
|
5
5
|
RSpec::Core::RakeTask.new
|
6
6
|
|
7
|
-
task :default => :
|
7
|
+
task :default => :travis
|
8
|
+
|
9
|
+
task :travis do
|
10
|
+
["rake spec", "rake build"].each do |cmd|
|
11
|
+
puts "Starting to run #{cmd}..."
|
12
|
+
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
13
|
+
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
14
|
+
end
|
15
|
+
end
|
data/Readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://codeclimate.com/github/lucasmartins/highrise-mapper) [](https://travis-ci.org/lucasmartins/highrise-mapper) [](https://gemnasium.com/lucasmartins/highrise-mapper)
|
1
|
+
[](http://rubygems.org/gems/highrise_mapper) [](https://codeclimate.com/github/lucasmartins/highrise-mapper) [](https://travis-ci.org/lucasmartins/highrise-mapper) [](https://gemnasium.com/lucasmartins/highrise-mapper)
|
2
2
|
|
3
3
|
Highrise Mapper
|
4
4
|
===============
|
@@ -40,6 +40,12 @@ person:
|
|
40
40
|
company_name: company_name
|
41
41
|
email_address: email
|
42
42
|
```
|
43
|
+
Non-Railers should call `HighriseMapper.config(root_directory)` on application bootstrap, where it will be mapped like this:
|
44
|
+
```ruby
|
45
|
+
"#{root_dir}/config/highrise_mapper.yml"
|
46
|
+
```
|
47
|
+
|
48
|
+
### Your model
|
43
49
|
|
44
50
|
In this example, you could have a Person class like this one:
|
45
51
|
|
@@ -62,14 +68,81 @@ class Person
|
|
62
68
|
end
|
63
69
|
end
|
64
70
|
```
|
71
|
+
### HighriseMapper::Person
|
72
|
+
|
73
|
+
When including, the module `HighriseMapper::Person` will check for expected behavior from your class, so you will have to make some changes:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
class Person
|
77
|
+
def name
|
78
|
+
'Albert'
|
79
|
+
end
|
80
|
+
|
81
|
+
def last_name
|
82
|
+
'Einstein'
|
83
|
+
end
|
84
|
+
|
85
|
+
def company_name
|
86
|
+
self.company.name
|
87
|
+
end
|
88
|
+
|
89
|
+
def email
|
90
|
+
'albert.einstein@princeton.edu'
|
91
|
+
end
|
92
|
+
|
93
|
+
def highrise_context
|
94
|
+
#must return an instance that includes HighriseMapper::Context
|
95
|
+
self.highrise_account
|
96
|
+
end
|
97
|
+
|
98
|
+
def highrise_id
|
99
|
+
#must return the id this object has in Highrise
|
100
|
+
112233
|
101
|
+
end
|
102
|
+
|
103
|
+
#must be included after required behavior has been added to the Class
|
104
|
+
include HighriseMapper::Person
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
Check the [specs](https://github.com/lucasmartins/highrise-mapper/tree/master/spec) to see the testing example, it will surely make it clearer.
|
109
|
+
|
65
110
|
Notice that this implementation is database agnostic, there is no database reference whatsoever.
|
66
111
|
|
67
|
-
|
112
|
+
Checkout the [sample rails application](https://github.com/lucasmartins/highrise-mapper-example).
|
113
|
+
|
114
|
+
### HighriseMapper::Context
|
115
|
+
|
116
|
+
When saving to Highrise, `HighriseMapper::Person` will look for the **base url** and **token** to connect to the right account, so you must have a model that represents this account configuration:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
class SaasCustomer
|
120
|
+
def name
|
121
|
+
'Rails na Praia'
|
122
|
+
end
|
123
|
+
|
124
|
+
def highrise_base_url
|
125
|
+
'https://railsnapraia.highrisehq.com'
|
126
|
+
end
|
127
|
+
|
128
|
+
def highrise_token
|
129
|
+
'a11386d68bdd94fe549b8498afafce56'
|
130
|
+
end
|
131
|
+
#must be included after required behavior has been added to the Class
|
132
|
+
include HighriseMapper::Context
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
It is designed this way so your SaaS application (example) can connect to multiple Highrise accounts, then we can have an ERP/CRM SaaS application where each customer sets up their own Highrise account.
|
137
|
+
|
138
|
+
Again, check the [specs](https://github.com/lucasmartins/highrise-mapper/tree/master/spec) and the [sample rails application](https://github.com/lucasmartins/highrise-mapper-example).
|
68
139
|
|
69
140
|
Contribute
|
70
141
|
==========
|
71
142
|
|
72
|
-
Just fork [HighriseMapper](https://github.com/lucasmartins/highrise-mapper), add your feature+spec, and make a pull request.
|
143
|
+
Just fork [HighriseMapper](https://github.com/lucasmartins/highrise-mapper), add your feature+spec, and make a pull request. Do not mess up with the version file though.
|
144
|
+
|
145
|
+
Also, if needed, update the code of the [sample application](https://github.com/lucasmartins/highrise-mapper-example).
|
73
146
|
|
74
147
|
Support
|
75
148
|
=======
|
@@ -79,4 +152,4 @@ This is an opensource project so don't expect premium support, but don't be shy,
|
|
79
152
|
License
|
80
153
|
=======
|
81
154
|
|
82
|
-
|
155
|
+
Highrise Mapper is free software under the [MIT license](http://lucasmartins.mit-license.org).
|
data/highrise_mapper.gemspec
CHANGED
@@ -19,9 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "highrise
|
22
|
+
s.add_dependency "highrise", "~>3.1.0"
|
23
23
|
|
24
24
|
s.add_development_dependency "rspec"
|
25
|
+
s.add_development_dependency "rspec-mocks"
|
25
26
|
s.add_development_dependency "rake"
|
26
27
|
s.add_development_dependency "pry"
|
27
28
|
s.add_development_dependency "pry-nav"
|
@@ -1,9 +1,6 @@
|
|
1
1
|
module HighriseMapper
|
2
2
|
module Context
|
3
3
|
|
4
|
-
module ClassMethods
|
5
|
-
end
|
6
|
-
|
7
4
|
module InstanceMethods
|
8
5
|
def setup_highrise
|
9
6
|
Highrise::Base.site = self.highrise_base_url
|
@@ -13,7 +10,6 @@ module HighriseMapper
|
|
13
10
|
end
|
14
11
|
|
15
12
|
def self.included(receiver)
|
16
|
-
receiver.extend ClassMethods
|
17
13
|
receiver.send :include, InstanceMethods
|
18
14
|
check_expected_behavior(receiver)
|
19
15
|
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
module HighriseMapper
|
2
2
|
module Person
|
3
|
-
|
4
|
-
module ClassMethods
|
5
|
-
end
|
6
3
|
|
7
4
|
module InstanceMethods
|
8
5
|
def save_to_highrise
|
@@ -50,7 +47,6 @@ module HighriseMapper
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def self.included(receiver)
|
53
|
-
receiver.extend ClassMethods
|
54
50
|
receiver.send :include, InstanceMethods
|
55
51
|
check_expected_behavior(receiver)
|
56
52
|
end
|
data/spec/person_spec.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
if highrise_env_available?
|
4
|
+
describe HighriseMapper::Person, "#save_to_highrise" do
|
5
|
+
it "persists the Highrise::Person successfully" do
|
6
|
+
HighriseMapper.config('templates')
|
7
|
+
contact = Contact.new
|
8
|
+
begin
|
9
|
+
result = contact.save_to_highrise
|
10
|
+
result.should be_a_kind_of(Fixnum)
|
11
|
+
ensure
|
12
|
+
Highrise::Person.find(result).destroy
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
|
-
end
|
15
16
|
|
16
|
-
describe HighriseMapper::Person, "#delete_from_highrise" do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
describe HighriseMapper::Person, "#delete_from_highrise" do
|
18
|
+
it "deletes the Highrise::Person successfully" do
|
19
|
+
HighriseMapper.config('templates')
|
20
|
+
contact = Contact.new
|
21
|
+
highrise_person_id = contact.save_to_highrise
|
22
|
+
result = contact.delete_from_highrise(highrise_person_id)
|
23
|
+
result.should be_a_kind_of(Net::HTTPOK)
|
24
|
+
end
|
23
25
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
else
|
27
|
+
describe HighriseMapper::Person, "#save_to_highrise"
|
28
|
+
describe HighriseMapper::Person, "#delete_from_highrise"
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry-nav'
|
1
3
|
require "highrise_mapper"
|
4
|
+
require 'rspec'
|
5
|
+
require 'rspec/mocks'
|
2
6
|
require "pathname"
|
3
7
|
|
4
8
|
SPECDIR = Pathname.new(File.dirname(__FILE__))
|
@@ -7,7 +11,14 @@ TMPDIR = SPECDIR.join("tmp")
|
|
7
11
|
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|r| require r}
|
8
12
|
|
9
13
|
RSpec.configure do |config|
|
10
|
-
config.include(SpecHelper)
|
11
|
-
|
12
14
|
config.before { FileUtils.mkdir_p(TMPDIR) }
|
13
15
|
end
|
16
|
+
|
17
|
+
def highrise_env_available?
|
18
|
+
if ENV['HIGHRISE_TOKEN']!=nil && ENV['HIGHRISE_BASE_URL']!=nil && ENV['HIGHRISE_TOKEN']!='' && ENV['HIGHRISE_BASE_URL']!=''
|
19
|
+
return true
|
20
|
+
else
|
21
|
+
puts 'INFO: No Highrise TOKEN/BASEURL environment variable defined, tests regarding HTTP communication will be ignored.'
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
end
|
data/spec/support/contact.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class Contact
|
2
|
+
extend RSpec::Mocks
|
2
3
|
def name
|
3
4
|
'Albert'
|
4
5
|
end
|
@@ -16,7 +17,11 @@ class Contact
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def highrise_context
|
19
|
-
SaasCustomer.new
|
20
|
+
@saas_customer = SaasCustomer.new
|
21
|
+
@saas_customer.stub(highrise_base_url: 'Rails on the beach' )
|
22
|
+
@saas_customer.stub(highrise_base_url: ENV['HIGHRISE_BASE_URL'] )
|
23
|
+
@saas_customer.stub(highrise_token: ENV['HIGHRISE_TOKEN'] )
|
24
|
+
return @saas_customer
|
20
25
|
end
|
21
26
|
|
22
27
|
def highrise_id
|
@@ -1,15 +1,14 @@
|
|
1
1
|
class SaasCustomer
|
2
|
+
# check the mock in the contact.rb for more information on how this model should behave
|
2
3
|
def name
|
3
|
-
'Rails na Praia'
|
4
4
|
end
|
5
5
|
|
6
6
|
def highrise_base_url
|
7
|
-
'https://railsnapraia.highrisehq.com'
|
8
7
|
end
|
9
8
|
|
10
9
|
def highrise_token
|
11
|
-
'a11386d68bdd94fe549b8498afafce56'
|
12
10
|
end
|
11
|
+
|
13
12
|
#must be included after required behavior has been added to the Class
|
14
13
|
include HighriseMapper::Context
|
15
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highrise_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,17 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: highrise
|
15
|
+
name: highrise
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.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: 3.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
35
|
- - ! '>='
|
20
36
|
- !ruby/object:Gem::Version
|
21
37
|
version: '0'
|
22
|
-
type: :
|
38
|
+
type: :development
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
@@ -28,7 +44,7 @@ dependencies:
|
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
47
|
+
name: rspec-mocks
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
@@ -102,6 +118,7 @@ files:
|
|
102
118
|
- .rspec
|
103
119
|
- .travis.yml
|
104
120
|
- Gemfile
|
121
|
+
- Gemfile.lock
|
105
122
|
- Rakefile
|
106
123
|
- Readme.md
|
107
124
|
- config/locales/en.yml
|
@@ -117,7 +134,6 @@ files:
|
|
117
134
|
- spec/person_spec.rb
|
118
135
|
- spec/spec_helper.rb
|
119
136
|
- spec/support/contact.rb
|
120
|
-
- spec/support/helper.rb
|
121
137
|
- spec/support/saas_customer.rb
|
122
138
|
- templates/config/highrise_mapper.yml
|
123
139
|
homepage: http://rubygems.org/gems/highrise-mapper
|
@@ -150,6 +166,5 @@ test_files:
|
|
150
166
|
- spec/person_spec.rb
|
151
167
|
- spec/spec_helper.rb
|
152
168
|
- spec/support/contact.rb
|
153
|
-
- spec/support/helper.rb
|
154
169
|
- spec/support/saas_customer.rb
|
155
170
|
has_rdoc:
|
data/spec/support/helper.rb
DELETED