salesforce_ar_sync 1.0.0 → 1.0.1

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.
@@ -3,6 +3,30 @@ module SalesforceArSync
3
3
  initializer "salesforce_ar_sync.load_app_instance_data" do |app|
4
4
  SalesforceArSync.setup do |config|
5
5
  config.app_root = app.root
6
+
7
+ #Load the configuration from the environment or a yaml file or disable it if no config present
8
+ SalesforceArSync.config = Hash.new
9
+
10
+ #load the config file if we have it
11
+ if FileTest.exist?("#{Rails.root}/config/salesforce_ar_sync.yml")
12
+ config = YAML.load_file("#{Rails.root}/config/salesforce_ar_sync.yml")
13
+ config = config[Rails.env]
14
+ if config['organization_id'].present? && config['ip_ranges'].present? && config['sync_enabled'].present?
15
+ SalesforceArSync.config["ORGANIZATION_ID"] = config['organization_id']
16
+ SalesforceArSync.config["SYNC_ENABLED"] = config['sync_enabled']
17
+ SalesforceArSync.config["IP_RANGES"] = config['ip_ranges'].split(',').map{ |ip| ip.strip }
18
+ end
19
+ end
20
+
21
+ #if we have ENV flags prefer them
22
+ SalesforceArSync.config["ORGANIZATION_ID"] = ENV["SALESFORCE_AR_SYNC_ORGANIZATION_ID"] if ENV["SALESFORCE_AR_SYNC_ORGANIZATION_ID"]
23
+ SalesforceArSync.config["SYNC_ENABLED"] = ENV["SALESFORCE_AR_SYNC_SYNC_ENABLED"] if ENV.include? "SALESFORCE_AR_SYNC_SYNC_ENABLED"
24
+ SalesforceArSync.config["IP_RANGES"] = ENV["SALESFORCE_AR_SYNC_IP_RANGES"].split(',').map{ |ip| ip.strip } if ENV["SALESFORCE_AR_SYNC_IP_RANGES"]
25
+
26
+ #do we have valid config options now?
27
+ if !SalesforceArSync.config["ORGANIZATION_ID"].present? || SalesforceArSync.config["ORGANIZATION_ID"].length != 18
28
+ SalesforceArSync.config["SYNC_ENABLED"] = false
29
+ end
6
30
  end
7
31
  end
8
32
  end
@@ -46,7 +46,7 @@ module SalesforceArSync
46
46
  # The salesforce_skip_sync instance variable is also used.
47
47
  # The SALESFORCE_AR_SYNC_ENABLED flag overrides all the others if set to false
48
48
  def salesforce_skip_sync?
49
- return true if SALESFORCE_AR_SYNC_CONFIG["SYNC_ENABLED"] == false
49
+ return true if SalesforceArSync.config["SYNC_ENABLED"] == false
50
50
  return (salesforce_skip_sync || !self.class.salesforce_sync_enabled || send(self.class.salesforce_skip_sync_method)) if self.class.salesforce_skip_sync_method.present?
51
51
  return (salesforce_skip_sync || !self.class.salesforce_sync_enabled)
52
52
  end
@@ -3,7 +3,7 @@ require 'ipaddr'
3
3
  module SalesforceArSync
4
4
  class IPConstraint
5
5
  def initialize
6
- @ip_ranges = SALESFORCE_AR_SYNC_CONFIG["IP_RANGES"]
6
+ @ip_ranges = SalesforceArSync.config["IP_RANGES"]
7
7
  end
8
8
 
9
9
  def matches?(request)
@@ -6,7 +6,7 @@ module SalesforceArSync
6
6
  def initialize organization, options = {}
7
7
  @options = options
8
8
  @xml_hashed = options
9
- @organization = SALESFORCE_AR_SYNC_CONFIG["ORGANIZATION_ID"]
9
+ @organization = SalesforceArSync.config["ORGANIZATION_ID"]
10
10
  @sobjects = collect_sobjects if valid?
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module SalesforceArSync
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -8,6 +8,7 @@ require 'salesforce_ar_sync/ip_constraint'
8
8
 
9
9
  module SalesforceArSync
10
10
  mattr_accessor :app_root
11
+ mattr_accessor :config
11
12
 
12
13
  def self.setup
13
14
  yield self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforce_ar_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-09-17 00:00:00.000000000 Z
16
+ date: 2012-09-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails