Class: Polyn::Cli::SchemaGenerator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Polyn::Cli::SchemaGenerator
- Includes:
- Thor::Actions
- Defined in:
- lib/polyn/cli/schema_generator.rb
Overview
Generates a new JSON Schema file for a message
Instance Method Summary collapse
- #check_name ⇒ Object
- #create ⇒ Object
- #file_name ⇒ Object
- #name ⇒ Object
- #schema_id ⇒ Object
- #subdir ⇒ Object
Instance Method Details
#check_name ⇒ Object
28 29 30 |
# File 'lib/polyn/cli/schema_generator.rb', line 28 def check_name Polyn::Cli::Naming.(name) end |
#create ⇒ Object
40 41 42 43 |
# File 'lib/polyn/cli/schema_generator.rb', line 40 def create say "Creating new schema for #{file_name}" template "generators/schema.json", File.join(.dir, "schemas/#{file_name}") end |
#file_name ⇒ Object
32 33 34 |
# File 'lib/polyn/cli/schema_generator.rb', line 32 def file_name @file_name ||= File.join(subdir, "#{name}.json") end |
#name ⇒ Object
17 18 19 |
# File 'lib/polyn/cli/schema_generator.rb', line 17 def name @name ||= .split("/").last end |
#schema_id ⇒ Object
36 37 38 |
# File 'lib/polyn/cli/schema_generator.rb', line 36 def schema_id Polyn::Cli::Naming.dot_to_colon(name) end |
#subdir ⇒ Object
21 22 23 24 25 26 |
# File 'lib/polyn/cli/schema_generator.rb', line 21 def subdir @subdir ||= begin split = .split("/") - [name] split.join("/") end end |