Sha256: 800197b08d2c9c16eaf8b82cc3fd443a3dbeb654c5696928099d466c3a18e61a

Contents?: true

Size: 833 Bytes

Versions: 18

Compression:

Stored size: 833 Bytes

Contents

require File.expand_path( "../project", __FILE__)
# Responsible for creating projects when needed.
# Creates them from XML received.
class ProjectFactory
  def initialize
    @project = Project.new
    @projects = []
  end

  def project
    @project
  end

  def create_projects_from_xml(xml)
    xml.split("\n").each do |line|
      /<name[^>]*>(.*)<\/name>/ =~ line
      name = $1
      project.name    = name.capitalize if name
      /<id[^>]*>(.*)<\/id>/ =~ line
      id = $1
      project.id      = id              if id
      /<api-key[^>]*>(.*)<\/api-key>/ =~ line
      api_key = $1
      project.api_key = api_key         if api_key
      check_project
    end
  end

  def check_project
    if @project.valid?
      projects << @project
      @project = Project.new
    end
  end

  def projects
    @projects
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
airbrake-4.3.0 lib/airbrake/cli/project_factory.rb
airbrake-4.2.1 lib/airbrake/cli/project_factory.rb
airbrake-4.2.0 lib/airbrake/cli/project_factory.rb
airbrake-4.1.0 lib/airbrake/cli/project_factory.rb
airbrake-4.0.0 lib/airbrake/cli/project_factory.rb
airbrake-3.2.1 lib/airbrake/cli/project_factory.rb
airbrake-3.2.0 lib/airbrake/cli/project_factory.rb
airbrake-3.1.17 lib/airbrake/cli/project_factory.rb
airbrake-3.1.16 lib/airbrake/cli/project_factory.rb
airbrake-3.1.15 lib/airbrake/cli/project_factory.rb
airbrake-3.1.14 lib/airbrake/cli/project_factory.rb
airbrake-3.1.13 lib/airbrake/cli/project_factory.rb
airbrake-3.1.12 lib/airbrake/cli/project_factory.rb
airbrake-3.1.11 lib/airbrake/cli/project_factory.rb
airbrake-3.1.10 lib/airbrake/cli/project_factory.rb
airbrake-3.1.9 lib/airbrake/cli/project_factory.rb
airbrake-3.1.8 lib/airbrake/cli/project_factory.rb
airbrake-3.1.7 lib/airbrake/cli/project_factory.rb