lib/makit/mp/project_mp.rb in makit-0.0.13 vs lib/makit/mp/project_mp.rb in makit-0.0.16

- old
+ new

@@ -3,52 +3,53 @@ require "yaml" module Makit module V1 class Project - def to_yaml - data = JSON.parse(self.to_pretty_json) - data.to_yaml.sub(/^---\n/, "") - end + #def to_yaml + # data = JSON.parse(self.to_pretty_json) + # data.to_yaml.sub(/^---\n/, "") + #end def self.create project = Makit::V1::Project.new project.set_default_values project end def open(filename) - other = Makit::V1::Project::create_from_file(filename) + other = Makit::Serializer.open(filename, Makit::V1::Project) + #other = Makit::V1::Project::create_from_file(filename) self.name = other.name self.git_remote_url = other.git_remote_url self.dotnet_projects = other.dotnet_projects end - def self.create_from_file(filename) - extension = File.extname(filename) - case extension - when ".yml" - yaml = File.read(filename) - create_from_yaml(yaml) - when ".json" - json = File.read(filename) - create_from_json(json) - else - raise "unsupported file extension: #{extension}" - end - end + #def self.create_from_file(filename) + # extension = File.extname(filename) + # case extension + # when ".yml" + # yaml = File.read(filename) + # create_from_yaml(yaml) + # when ".json" + # json = File.read(filename) + # create_from_json(json) + # else + # raise "unsupported file extension: #{extension}" + # end + #end - def self.create_from_yaml(yaml) - json = JSON.pretty_generate(YAML.load(yaml)) - project = Makit::V1::Project.decode_json(json) - project - end + #def self.create_from_yaml(yaml) + # json = JSON.pretty_generate(YAML.load(yaml)) + # project = Makit::V1::Project.decode_json(json) + # project + #end - def self.create_from_json(json) - project = Makit::V1::Project.decode_json(json) - project - end + #def self.create_from_json(json) + # project = Makit::V1::Project.decode_json(json) + # project + #end def set_default_values #self.language = "csharp" #self.primary_artifact_type = "nuget" if self.git_remote_url.nil? || self.git_remote_url.empty? @@ -77,19 +78,20 @@ def get_capitalized_name(name) name.split(".").map(&:capitalize).join(".") end def save_as(filename) - extension = File.extname(filename) - case extension - when ".json" - File.write(filename, self.to_pretty_json) - when ".yml" - File.write(filename, self.to_yaml) - else - raise "unsupported file extension: #{extension}" - end + Makit::Serializer.save_as(filename, self) + #extension = File.extname(filename) + #case extension + #when ".json" + # File.write(filename, self.to_pretty_json) + #when ".yml" + # File.write(filename, self.to_yaml) + #else + # raise "unsupported file extension: #{extension}" + #end end def with_dotnet_project(template, name, output) if !self.dotnet_projects.any? { |project| project.output == output } project = Makit::V1::DotNetProject.new @@ -105,9 +107,14 @@ end def make setup_dotnet_projects make_dotnet_projects + + # verify the artifacts exist + self.artifacts.each do |artifact| + raise "artifact does not exist: #{artifact}" if !File.exist?(artifact) + end end def build build_dotnet_projects end