Commit abb1881fa03f354ea0069a24a7886ca260ad9bc7

Authored by João M. M. da Silva + Alessandro Palmeira
Committed by Paulo Meireles
1 parent e68a8596

[Mezuro] Begginning of refactoring design to MVC, created project and repository models

config/initializers/mezuro_plugin.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +require 'savon'
  2 +require 'yaml'
  3 +
  4 +Savon.configure do |config|
  5 + config.log = HTTPI.log = (RAILS_ENV == 'development')
  6 +end
... ...
plugins/mezuro/lib/kalibro/project.rb 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +class Kalibro::Project < Kalibro::Model
  2 + attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :error
  3 +
  4 + def self.all_names
  5 + request(:get_project_names)[:project_name]
  6 + end
  7 +
  8 + def self.find_by_name(project_name)
  9 + attributes = request(:get_project, :project_name => project_name)[:project]
  10 + new attributes
  11 + end
  12 +
  13 + def save
  14 + self.class.request(:save_project, {:project => to_hash})
  15 + end
  16 +
  17 + def repository=(value)
  18 + @repository = (value.kind_of?(Hash)) ? Kalibro::Repository.new(value) : value
  19 + end
  20 +
  21 + private
  22 +
  23 + def self.client
  24 + endpoint = "Project"
  25 + service_address = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/service.yaml")
  26 + Savon::Client.new("#{service_address}#{endpoint}Endpoint/?wsdl")
  27 + end
  28 +
  29 + def self.request(action, request_body = nil)
  30 + response = client.request(:kalibro, action) { soap.body = request_body }
  31 + response.to_hash["#{action}_response".to_sym]
  32 + end
  33 +
  34 +end
  35 +
... ...
plugins/mezuro/lib/kalibro/repository.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class Kalibro::Repository < Kalibro::Model
  2 +
  3 + attr_accessor :type, :address, :username, :password
  4 +
  5 +end
... ...