sugarcrm 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +38 -6
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/sugarcrm +26 -0
- data/lib/sugarcrm.rb +2 -2
- data/lib/sugarcrm/associations/association.rb +11 -8
- data/lib/sugarcrm/associations/association_collection.rb +1 -1
- data/lib/sugarcrm/associations/association_methods.rb +1 -1
- data/lib/sugarcrm/attributes/attribute_methods.rb +7 -2
- data/lib/sugarcrm/attributes/attribute_typecast.rb +2 -2
- data/lib/sugarcrm/base.rb +37 -236
- data/lib/sugarcrm/connection/api/get_available_modules.rb +2 -2
- data/lib/sugarcrm/connection/api/get_document_revision.rb +2 -2
- data/lib/sugarcrm/connection/api/get_entries.rb +2 -2
- data/lib/sugarcrm/connection/api/get_entries_count.rb +1 -1
- data/lib/sugarcrm/connection/api/get_entry.rb +2 -2
- data/lib/sugarcrm/connection/api/get_entry_list.rb +2 -2
- data/lib/sugarcrm/connection/api/get_module_fields.rb +2 -2
- data/lib/sugarcrm/connection/api/get_note_attachment.rb +1 -1
- data/lib/sugarcrm/connection/api/get_relationships.rb +2 -2
- data/lib/sugarcrm/connection/api/get_report_entries.rb +1 -1
- data/lib/sugarcrm/connection/api/get_server_info.rb +1 -1
- data/lib/sugarcrm/connection/api/get_user_id.rb +1 -1
- data/lib/sugarcrm/connection/api/get_user_team_id.rb +1 -1
- data/lib/sugarcrm/connection/api/logout.rb +1 -1
- data/lib/sugarcrm/connection/api/seamless_login.rb +1 -1
- data/lib/sugarcrm/connection/api/search_by_module.rb +1 -1
- data/lib/sugarcrm/connection/api/set_campaign_merge.rb +1 -1
- data/lib/sugarcrm/connection/api/set_document_revision.rb +1 -1
- data/lib/sugarcrm/connection/api/set_entries.rb +1 -1
- data/lib/sugarcrm/connection/api/set_entry.rb +1 -1
- data/lib/sugarcrm/connection/api/set_note_attachment.rb +1 -1
- data/lib/sugarcrm/connection/api/set_relationship.rb +1 -1
- data/lib/sugarcrm/connection/api/set_relationships.rb +1 -1
- data/lib/sugarcrm/connection/connection.rb +5 -10
- data/lib/sugarcrm/connection/helper.rb +3 -2
- data/lib/sugarcrm/connection/response.rb +8 -6
- data/lib/sugarcrm/exceptions.rb +3 -0
- data/lib/sugarcrm/finders.rb +2 -0
- data/lib/sugarcrm/{dynamic_finder_match.rb → finders/dynamic_finder_match.rb} +0 -0
- data/lib/sugarcrm/finders/finder_methods.rb +236 -0
- data/lib/sugarcrm/module.rb +35 -11
- data/lib/sugarcrm/module_methods.rb +68 -23
- data/lib/sugarcrm/session.rb +179 -0
- data/test/connection/test_get_available_modules.rb +1 -4
- data/test/connection/test_get_entries.rb +2 -8
- data/test/connection/test_get_entry.rb +1 -2
- data/test/connection/test_get_entry_list.rb +6 -12
- data/test/connection/test_get_module_fields.rb +1 -4
- data/test/connection/test_get_relationships.rb +1 -4
- data/test/connection/test_get_server_info.rb +1 -4
- data/test/connection/test_get_user_id.rb +1 -4
- data/test/connection/test_get_user_team_id.rb +1 -4
- data/test/connection/test_login.rb +3 -5
- data/test/connection/test_logout.rb +1 -4
- data/test/connection/test_set_note_attachment.rb +1 -2
- data/test/connection/test_set_relationship.rb +1 -2
- data/test/helper.rb +6 -8
- data/test/test_association_collection.rb +1 -2
- data/test/test_associations.rb +18 -1
- data/test/test_connection.rb +2 -6
- data/test/test_module.rb +34 -6
- data/test/test_response.rb +2 -3
- data/test/test_session.rb +109 -0
- data/test/test_sugarcrm.rb +58 -7
- metadata +14 -11
- data/lib/sugarcrm/environment.rb +0 -63
- data/test/test_environment.rb +0 -45
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 11
|
9
|
+
version: 0.9.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Carl Hicks
|
@@ -15,8 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-02-18 00:00:00 -08:00
|
19
|
+
default_executable: sugarcrm
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activesupport
|
@@ -104,8 +104,8 @@ dependencies:
|
|
104
104
|
version_requirements: *id006
|
105
105
|
description:
|
106
106
|
email: carl.hicks@gmail.com
|
107
|
-
executables:
|
108
|
-
|
107
|
+
executables:
|
108
|
+
- sugarcrm
|
109
109
|
extensions: []
|
110
110
|
|
111
111
|
extra_rdoc_files:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- README.rdoc
|
119
119
|
- Rakefile
|
120
120
|
- VERSION
|
121
|
+
- bin/sugarcrm
|
121
122
|
- lib/sugarcrm.rb
|
122
123
|
- lib/sugarcrm/associations.rb
|
123
124
|
- lib/sugarcrm/associations/association.rb
|
@@ -161,12 +162,14 @@ files:
|
|
161
162
|
- lib/sugarcrm/connection/helper.rb
|
162
163
|
- lib/sugarcrm/connection/request.rb
|
163
164
|
- lib/sugarcrm/connection/response.rb
|
164
|
-
- lib/sugarcrm/dynamic_finder_match.rb
|
165
|
-
- lib/sugarcrm/environment.rb
|
166
165
|
- lib/sugarcrm/exceptions.rb
|
167
166
|
- lib/sugarcrm/extensions/README.txt
|
167
|
+
- lib/sugarcrm/finders.rb
|
168
|
+
- lib/sugarcrm/finders/dynamic_finder_match.rb
|
169
|
+
- lib/sugarcrm/finders/finder_methods.rb
|
168
170
|
- lib/sugarcrm/module.rb
|
169
171
|
- lib/sugarcrm/module_methods.rb
|
172
|
+
- lib/sugarcrm/session.rb
|
170
173
|
- test/config_test.yaml
|
171
174
|
- test/connection/test_get_available_modules.rb
|
172
175
|
- test/connection/test_get_entries.rb
|
@@ -186,9 +189,9 @@ files:
|
|
186
189
|
- test/test_association_collection.rb
|
187
190
|
- test/test_associations.rb
|
188
191
|
- test/test_connection.rb
|
189
|
-
- test/test_environment.rb
|
190
192
|
- test/test_module.rb
|
191
193
|
- test/test_response.rb
|
194
|
+
- test/test_session.rb
|
192
195
|
- test/test_sugarcrm.rb
|
193
196
|
has_rdoc: true
|
194
197
|
homepage: http://github.com/chicks/sugarcrm
|
@@ -204,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
207
|
requirements:
|
205
208
|
- - ">="
|
206
209
|
- !ruby/object:Gem::Version
|
207
|
-
hash:
|
210
|
+
hash: 2666117297979367978
|
208
211
|
segments:
|
209
212
|
- 0
|
210
213
|
version: "0"
|
@@ -242,7 +245,7 @@ test_files:
|
|
242
245
|
- test/test_association_collection.rb
|
243
246
|
- test/test_associations.rb
|
244
247
|
- test/test_connection.rb
|
245
|
-
- test/test_environment.rb
|
246
248
|
- test/test_module.rb
|
247
249
|
- test/test_response.rb
|
250
|
+
- test/test_session.rb
|
248
251
|
- test/test_sugarcrm.rb
|
data/lib/sugarcrm/environment.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
module SugarCRM; class Environment
|
4
|
-
include Singleton
|
5
|
-
|
6
|
-
attr_reader :config
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@config = {}
|
10
|
-
|
11
|
-
# see README for reasoning behind the priorization
|
12
|
-
config_file_paths.each{|path|
|
13
|
-
load_config path if File.exists? path
|
14
|
-
}
|
15
|
-
extensions_folder = File.join(File.dirname(__FILE__), 'extensions')
|
16
|
-
SugarCRM::Base.establish_connection(@config[:base_url], @config[:username], @config[:password], {:load_environment => false}) if SugarCRM.connection.nil? && connection_info_loaded?
|
17
|
-
end
|
18
|
-
|
19
|
-
def connection_info_loaded?
|
20
|
-
@config[:base_url] && @config[:username] && @config[:password]
|
21
|
-
end
|
22
|
-
|
23
|
-
def load_config(path)
|
24
|
-
validate_path path
|
25
|
-
config = YAML.load_file(path)
|
26
|
-
if config && config["config"]
|
27
|
-
config["config"].each{|k,v|
|
28
|
-
@config[k.to_sym] = v
|
29
|
-
}
|
30
|
-
end
|
31
|
-
@config
|
32
|
-
end
|
33
|
-
|
34
|
-
def update_config(params)
|
35
|
-
params.each{|k,v|
|
36
|
-
@config[k.to_sym] = v
|
37
|
-
}
|
38
|
-
@config
|
39
|
-
end
|
40
|
-
|
41
|
-
# load all the monkey patch extension files in the provided folder
|
42
|
-
def extensions_folder=(folder, dirstring=nil)
|
43
|
-
validate_path folder
|
44
|
-
path = File.expand_path(folder, dirstring)
|
45
|
-
Dir[File.join(path, '**', '*.rb').to_s].each { |f| load(f) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.method_missing(method_id, *args, &block)
|
49
|
-
self.instance.send(method_id, *args, &block)
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
def config_file_paths
|
54
|
-
# see README for reasoning behind the priorization
|
55
|
-
paths = ['/etc/sugarcrm.yaml', File.expand_path('~/.sugarcrm.yaml'), File.join(File.dirname(__FILE__), 'config', 'sugarcrm.yaml')]
|
56
|
-
paths.insert(1, File.join(ENV['USERPROFILE'], 'sugarcrm.yaml')) if ENV['USERPROFILE']
|
57
|
-
paths
|
58
|
-
end
|
59
|
-
|
60
|
-
def validate_path(path)
|
61
|
-
raise "Invalid path: #{path}" unless File.exists? path
|
62
|
-
end
|
63
|
-
end; end
|
data/test/test_environment.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestEnvironment < Test::Unit::TestCase
|
4
|
-
context "A SugarCRM::Environment singleton" do
|
5
|
-
|
6
|
-
should "delegate missing methods to singleton instance" do
|
7
|
-
assert_equal SugarCRM::Environment.instance.config, SugarCRM::Environment.config
|
8
|
-
end
|
9
|
-
|
10
|
-
should "load monkey patch extensions" do
|
11
|
-
SugarCRM::Environment.extensions_folder = File.join(File.dirname(__FILE__), 'extensions_test')
|
12
|
-
assert SugarCRM::Contact.is_extended?
|
13
|
-
assert SugarCRM::Contact.is_extended?
|
14
|
-
end
|
15
|
-
|
16
|
-
should "load config file" do
|
17
|
-
SugarCRM::Environment.load_config File.join(File.dirname(__FILE__), 'config_test.yaml')
|
18
|
-
|
19
|
-
config_contents = {
|
20
|
-
:config => {
|
21
|
-
:base_url => 'http://127.0.0.1/sugarcrm',
|
22
|
-
:username => 'admin',
|
23
|
-
:password => 'letmein'
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
config_contents[:config].each{|k,v|
|
28
|
-
assert_equal v, SugarCRM::Environment.config[k]
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
should "log in to Sugar automatically if credentials are present in config file" do
|
33
|
-
SugarCRM::Environment.load_config File.join(File.dirname(__FILE__), 'config_test.yaml')
|
34
|
-
assert SugarCRM.connection.logged_in?
|
35
|
-
end
|
36
|
-
|
37
|
-
should "update the login credentials on connection" do
|
38
|
-
SugarCRM.connect!(URL, USER, PASS)
|
39
|
-
{:base_url => URL, :username => USER, :password => PASS}.each{|k,v|
|
40
|
-
assert_equal v, SugarCRM::Environment.config[k]
|
41
|
-
}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|