Class: Suma::ExpressSchema
- Inherits:
-
Object
- Object
- Suma::ExpressSchema
- Defined in:
- lib/suma/express_schema.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #filename_plain ⇒ Object
-
#initialize(id:, path:, output_path:) ⇒ ExpressSchema
constructor
A new instance of ExpressSchema.
- #save_exp ⇒ Object
- #to_plain ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(id:, path:, output_path:) ⇒ ExpressSchema
Returns a new instance of ExpressSchema.
11 12 13 14 15 |
# File 'lib/suma/express_schema.rb', line 11 def initialize(id:, path:, output_path:) @path = Pathname.new(path). @id = id @output_path = output_path end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/suma/express_schema.rb', line 9 def id @id end |
#output_path ⇒ Object
Returns the value of attribute output_path.
9 10 11 |
# File 'lib/suma/express_schema.rb', line 9 def output_path @output_path end |
#parsed ⇒ Object
Returns the value of attribute parsed.
9 10 11 |
# File 'lib/suma/express_schema.rb', line 9 def parsed @parsed end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/suma/express_schema.rb', line 9 def path @path end |
Instance Method Details
#filename_plain ⇒ Object
41 42 43 |
# File 'lib/suma/express_schema.rb', line 41 def filename_plain File.join(@output_path, type, id, File.basename(@path)) end |
#save_exp ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/suma/express_schema.rb', line 45 def save_exp relative_path = Pathname.new(filename_plain).relative_path_from(Dir.pwd) Utils.log "Save plain schema: #{relative_path}" # return if File.exist?(filename_plain) FileUtils.mkdir_p(File.dirname(filename_plain)) File.open(filename_plain, "w") do |file| file.write(to_plain) end end |
#to_plain ⇒ Object
37 38 39 |
# File 'lib/suma/express_schema.rb', line 37 def to_plain parsed.to_s(no_remarks: true) end |
#type ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/suma/express_schema.rb', line 17 def type case @path.to_s when %r{.*/resources/.*} "resources" when %r{.*/modules/.*} "modules" else "unknown_type" end end |