bpm_manager 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86e2d7be28e92c98e16c7a87d6c43f9cc81597b2
4
- data.tar.gz: b023acd44fd86133128e60d23a4810947713de53
3
+ metadata.gz: c7de81106384f1a90cef720c57234ec35da28121
4
+ data.tar.gz: 96a2e43f832576c16cdc3a4fc18511c7695dd953
5
5
  SHA512:
6
- metadata.gz: c68a47b9fdcec254f2d0b61f587799b28dd46def9f207ac5428fbf2ce577da9a890bca28d9125bcde1d1354395d188e800cbaf4ffa29ddf2aaaf3d675cf3f119
7
- data.tar.gz: d1d3be8b7383dff84aedebee80e2267cf6aab9ebcd03d677be443a904f846b38baba7f0003bc6104895abce06ac6e84c3af6309e90641b3f3479e417657e7ba3
6
+ metadata.gz: 9bfa354a58c4f7819bee7d2063d843ae59600e344ca9f9bf45dfd46fe320b050ebe9ea67283a61396615192b3549ea1f7de62385057a451558d9a17263828bd0
7
+ data.tar.gz: 02a1732d87845bf44e73fb6ed7d501753007df99de3cc49f49e9a37bd8b4b83849adf72e04e26298723b01eda1a86f1844809ad62685d87b45ae14cf759bb7f7
data/README.md CHANGED
@@ -25,14 +25,23 @@ Also do not forget to execute the initializer with:
25
25
 
26
26
  ## Usage
27
27
 
28
- 1. First configure properly the gem using the bpm_manager.rb file in 'config/initializers/bpm_manager.rb'
29
- 2. Assign the Server with:
28
+ 1. First configure properly the gem using the bpm_manager.rb file in 'config/initializers/bpm_manager.rb' or calling
30
29
 
31
- $ @server = BpmManager.new
30
+ ```ruby
31
+ BpmManager.configure({
32
+ :bpm_vendor => 'RedHat' # or 'Oracle'
33
+ :bpm_url => 'bpm.company.com' # without http:// or https://
34
+ :bpm_username => 'scott'
35
+ :bpm_passowrd => 'tiger'
36
+ :bpm_use_ssl => false # use true for https
37
+ })
38
+ ```
32
39
 
33
- 3. Make a call:
40
+ 2. Then make an API call like this:
34
41
 
35
- $ result = @server.get_deployments()
42
+ ```ruby
43
+ result = BpmManager.deployments()
44
+ ```
36
45
 
37
46
  ## Contributing
38
47
 
data/Rakefile CHANGED
@@ -3,5 +3,5 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new('spec')
5
5
 
6
- # If you want to make this the default task
6
+ # Make spec the default task
7
7
  task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/bpm_manager.rb CHANGED
@@ -3,45 +3,39 @@ require "rest-client"
3
3
  require "json"
4
4
 
5
5
  module BpmManager
6
- class Server
7
- @valid_config_keys = @config
8
-
9
- # Initializes the defaults
10
- def initialize
11
- @config = {
12
- :bpm_vendor => "RedHat",
13
- :bpm_url => "bpm.beatcoding.com",
14
- :bpm_username => "Administrator",
15
- :bpm_password => "bc-power",
16
- :bpm_use_ssl => false,
17
- :time_stamp => Time.now.to_i }
18
-
19
- raise LoadError 'BpmManager Gem Configuration file has errors' if @config.values.any?{|v| v.nil?}
20
- end
21
-
22
- # Configure through hash
23
- def configure(opts = {})
24
- opts.each{ |k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
25
- end
26
-
27
- # Returns the configuration hash
28
- def config
29
- @config
30
- end
31
-
32
- # Returns the URI for the server plus a suffix
33
- def uri(suffix)
34
- case @config[:bpm_vendor]
35
- when 'RedHat'
36
- URI.encode('http' + (@config[:bpm_use_ssl] ? 's' : '') + '://' + @config[:bpm_username] + ':' + @config[:bpm_password] + '@' + @config[:bpm_url] + '/business-central/rest' + (suffix.nil? ? '' : suffix))
37
- else
38
- ''
39
- end
6
+ @config = {
7
+ :bpm_vendor => "",
8
+ :bpm_url => "",
9
+ :bpm_username => "",
10
+ :bpm_password => "",
11
+ :bpm_use_ssl => false }
12
+
13
+ @valid_config_keys = @config
14
+
15
+ # Configure through hash
16
+ def self.configure(opts = {})
17
+ opts.each{ |k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
18
+ end
19
+
20
+ # Returns the configuration hash
21
+ def self.config
22
+ @config
23
+ end
24
+
25
+ # Returns the URI for the server plus a suffix
26
+ def self.uri(suffix = '')
27
+ case @config[:bpm_vendor]
28
+ when 'RedHat'
29
+ URI.encode('http' + (@config[:bpm_use_ssl] ? 's' : '') + '://' + @config[:bpm_username] + ':' + @config[:bpm_password] + '@' + @config[:bpm_url] + '/business-central/rest' + (suffix.nil? ? '' : suffix))
30
+ else
31
+ ''
40
32
  end
33
+ end
34
+
35
+ # Gets all server deployments
36
+ def self.deployments()
37
+ raise LoadError 'BpmManager Gem Configuration file has errors' if @config.values.any?{|v| v.nil?}
41
38
 
42
- # Gets all server deployments
43
- def deployments()
44
- return JSON.parse(RestClient.get(uri('/deployment'), :accept => :json))
45
- end
39
+ return JSON.parse(RestClient.get(BpmManager.uri('/deployment'), :accept => :json))
46
40
  end
47
41
  end
data/spec/server_spec.rb CHANGED
@@ -1,50 +1,53 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#uri" do
4
- before :each do
5
- @server = BpmManager::Server.new()
6
- @uri = @server.uri('/test')
3
+ describe "BpmManager" do
4
+ before :all do
5
+ BpmManager.configure({ :bpm_vendor => 'RedHat', :bpm_url => 'bpm.beatcoding.com', :bpm_username => 'Administrator', :bpm_password => 'bc-power' })
7
6
  end
8
7
 
9
- it "expect to be a String" do
10
- expect(@uri).to be_an_instance_of String
11
- end
12
-
13
- it "expect to not be nil" do
14
- expect(@uri).not_to eq(nil)
15
- end
16
- end
17
-
18
- describe "#config" do
19
- before :each do
20
- @server = BpmManager::Server.new
21
- @config = @server.config()
22
- end
8
+ describe "#uri" do
9
+ before :each do
10
+ @uri = BpmManager.uri('/test')
11
+ end
12
+
13
+ it "expect to be a String" do
14
+ expect(@uri).to be_an_instance_of String
15
+ end
23
16
 
24
- it "should be a Hash" do
25
- expect(@config).to be_an_instance_of Hash
17
+ it "expect to not be nil" do
18
+ expect(@uri).not_to eq(nil)
19
+ end
26
20
  end
27
21
 
28
- it 'should not be empty' do
29
- expect(@config.length).to be > 0
30
- end
31
-
32
- it 'must have all the keys' do
33
- expect(@config.has_key? :bpm_vendor).to be true
34
- expect(@config.has_key? :bpm_url).to be true
35
- expect(@config.has_key? :bpm_username).to be true
36
- expect(@config.has_key? :bpm_password).to be true
37
- expect(@config.has_key? :bpm_use_ssl).to be true
38
- end
39
- end
40
-
41
- describe "#deployments" do
42
- before :each do
43
- @server = BpmManager::Server.new()
44
- @deployments = @server.deployments()
22
+ describe "#config" do
23
+ before :each do
24
+ @config = BpmManager.config
25
+ end
26
+
27
+ it "should be a Hash" do
28
+ expect(@config).to be_an_instance_of Hash
29
+ end
30
+
31
+ it 'should not be empty' do
32
+ expect(@config.length).to be > 0
33
+ end
34
+
35
+ it 'must have all the keys' do
36
+ expect(@config.has_key? :bpm_vendor).to be true
37
+ expect(@config.has_key? :bpm_url).to be true
38
+ expect(@config.has_key? :bpm_username).to be true
39
+ expect(@config.has_key? :bpm_password).to be true
40
+ expect(@config.has_key? :bpm_use_ssl).to be true
41
+ end
45
42
  end
46
43
 
47
- it "must return something" do
48
- expect(@deployments.length).to be > 0
44
+ describe "#deployments" do
45
+ before :each do
46
+ @deployments = BpmManager.deployments()
47
+ end
48
+
49
+ it "must return something" do
50
+ expect(@deployments.length).to be > 0
51
+ end
49
52
  end
50
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpm_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-18 00:00:00.000000000 Z
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client