Class: ProjectFactory
- Inherits:
-
Object
- Object
- ProjectFactory
- Defined in:
- lib/airbrake/cli/project_factory.rb
Overview
Creates them from XML received.
Instance Method Summary collapse
- #check_project ⇒ Object
- #create_projects_from_xml(xml) ⇒ Object
-
#initialize ⇒ ProjectFactory
constructor
A new instance of ProjectFactory.
- #project ⇒ Object
- #projects ⇒ Object
Constructor Details
#initialize ⇒ ProjectFactory
Returns a new instance of ProjectFactory.
5 6 7 8 |
# File 'lib/airbrake/cli/project_factory.rb', line 5 def initialize @project = Project.new @projects = [] end |
Instance Method Details
#check_project ⇒ Object
29 30 31 32 33 34 |
# File 'lib/airbrake/cli/project_factory.rb', line 29 def check_project if @project.valid? projects << @project @project = Project.new end end |
#create_projects_from_xml(xml) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/airbrake/cli/project_factory.rb', line 14 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 |
#project ⇒ Object
10 11 12 |
# File 'lib/airbrake/cli/project_factory.rb', line 10 def project @project end |
#projects ⇒ Object
36 37 38 |
# File 'lib/airbrake/cli/project_factory.rb', line 36 def projects @projects end |