Skip to content
This repository
Browse code

add basic generator

  • Loading branch information...
commit 183c1b193e6620431826c3b594c568d4592fb0af 1 parent b5139a0
David Sulc authored
22  lib/rails/generators/sugarcrm/config/config_generator.rb
... ...
@@ -0,0 +1,22 @@
  1
+# encoding: utf-8
  2
+
  3
+module Sugarcrm
  4
+  module Generators
  5
+    class ConfigGenerator < Rails::Generators::Base
  6
+      desc 'Creates a SugarCRM gem configuration file at config/sugarcrm.yml, and an initializer at config/initializers/sugarcrm.rb'
  7
+
  8
+      def self.source_root
  9
+        @_sugarcrm_source_root ||= File.expand_path("../templates", __FILE__)
  10
+      end
  11
+
  12
+      def create_config_file
  13
+        template 'sugarcrm.yml', File.join('config', 'sugarcrm.yml')
  14
+      end
  15
+
  16
+      def create_initializer_file
  17
+        template 'initializer.rb', File.join('config', 'initializers', 'sugarcrm.rb')
  18
+      end
  19
+    end
  20
+  end
  21
+end
  22
+
1  lib/rails/generators/sugarcrm/config/templates/initializer.rb
... ...
@@ -0,0 +1 @@
  1
+SugarCRM::Session.new_from_file(File.join(Rails.root, 'config', 'sugarcrm.yml'))
4  lib/rails/generators/sugarcrm/config/templates/sugarcrm.yml
... ...
@@ -0,0 +1,4 @@
  1
+config:
  2
+  base_url: http://127.0.0.1/sugarcrm # where your SugarCRM instance is located
  3
+  username: admin
  4
+  password: letmein

0 notes on commit 183c1b1

Please sign in to comment.
Something went wrong with that request. Please try again.