yarrow 0.7.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/lib/{yarrow/extensions → extensions}/mementus.rb +0 -0
- data/lib/yarrow/config.rb +13 -7
- data/lib/yarrow/configuration.rb +2 -4
- data/lib/yarrow/console_runner.rb +28 -55
- data/lib/yarrow/content/graph.rb +1 -1
- data/lib/yarrow/defaults.yml +2 -2
- data/lib/yarrow/generator.rb +18 -6
- data/lib/yarrow/help.txt +35 -0
- data/lib/yarrow/schema/definitions.rb +2 -3
- data/lib/yarrow/schema/entity.rb +16 -1
- data/lib/yarrow/schema/registry.rb +14 -0
- data/lib/yarrow/schema/types.rb +77 -11
- data/lib/yarrow/schema/value.rb +26 -0
- data/lib/yarrow/server.rb +1 -1
- data/lib/yarrow/version.rb +2 -2
- data/lib/yarrow/web/document.rb +37 -0
- data/lib/yarrow/web/generator.rb +57 -0
- data/lib/yarrow/web/manifest.rb +57 -0
- data/lib/yarrow/web/template.rb +21 -1
- data/lib/yarrow.rb +44 -40
- data/yarrow.gemspec +3 -0
- metadata +49 -9
- data/lib/yarrow/content/manifest.rb +0 -61
- data/lib/yarrow/extensions.rb +0 -1
- data/lib/yarrow/output/generator.rb +0 -43
- data/lib/yarrow/output/mapper.rb +0 -23
- data/lib/yarrow/output/result.rb +0 -13
- data/lib/yarrow/web/html_document.rb +0 -9
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8c362ba73bcbfc325bad91668bf1a1a006dd6355579a36ce96cc60323944804b
         | 
| 4 | 
            +
              data.tar.gz: 51db819b1f52b3b75a9b39287359e22dfb6d52833ce0089636694f4d9feeda15
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c7a41bb6ee0a6bcfd27c83d7780cc70f7b41131daaa4decd02e591346f9270318951b1a68d0f390ac81843593e0bf97a8062da51f3f7f1e2be78b6711af132d6
         | 
| 7 | 
            +
              data.tar.gz: 866d6683eb25f9154d9582266b45016b680d622fca57a71c88b55f8c0ee41dc76076e839684026df8759e72ba73cf2597b96cbe05b83d3c877cc5ebcf6252bcf
         | 
    
        data/.gitignore
    CHANGED
    
    
| 
            File without changes
         | 
    
        data/lib/yarrow/config.rb
    CHANGED
    
    | @@ -43,6 +43,12 @@ module Yarrow | |
| 43 43 | 
             
                )
         | 
| 44 44 |  | 
| 45 45 | 
             
                # Top level root config namespace.
         | 
| 46 | 
            +
                class Instance < Yarrow::Schema::Entity
         | 
| 47 | 
            +
                  attribute :source_dir, :path
         | 
| 48 | 
            +
                  attribute :output_dir, :path
         | 
| 49 | 
            +
                  attribute :meta, :any
         | 
| 50 | 
            +
                  attribute :server, :any
         | 
| 51 | 
            +
                end
         | 
| 46 52 | 
             
                #
         | 
| 47 53 | 
             
                # `content_dir` and `output_dir` are placeholders and should be overriden
         | 
| 48 54 | 
             
                # with more fine-grained config for web and book outputs in future.
         | 
| @@ -51,12 +57,12 @@ module Yarrow | |
| 51 57 | 
             
                # server locally.
         | 
| 52 58 | 
             
                #
         | 
| 53 59 | 
             
                # TODO: meta should be union of Type::Optional and Config::Meta
         | 
| 54 | 
            -
                Instance = Yarrow::Schema::Value.new(
         | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
                )
         | 
| 60 | 
            +
                # Instance = Yarrow::Schema::Value.new(
         | 
| 61 | 
            +
                #   project_dir: :path,
         | 
| 62 | 
            +
                #   content_dir: :path,
         | 
| 63 | 
            +
                #   output_dir: :path,
         | 
| 64 | 
            +
                #   meta: :any,
         | 
| 65 | 
            +
                #   server: :any
         | 
| 66 | 
            +
                # )
         | 
| 61 67 | 
             
              end
         | 
| 62 68 | 
             
            end
         | 
    
        data/lib/yarrow/configuration.rb
    CHANGED
    
    | @@ -52,13 +52,11 @@ module Yarrow | |
| 52 52 | 
             
                    # automated as part of the schema types or a default value should be
         | 
| 53 53 | 
             
                    # generated here (eg: `"#{Dir.pwd}/docs"`)
         | 
| 54 54 | 
             
                    out_dir_or_string = config[:output_dir] || ""
         | 
| 55 | 
            -
                    source_dir_or_string = config[: | 
| 56 | 
            -
                    content_dir_or_string = config[:content_dir] || ""
         | 
| 55 | 
            +
                    source_dir_or_string = config[:source_dir] || ""
         | 
| 57 56 |  | 
| 58 57 | 
             
                    Yarrow::Config::Instance.new(
         | 
| 59 58 | 
             
                      output_dir: Pathname.new(File.expand_path(out_dir_or_string)),
         | 
| 60 | 
            -
                       | 
| 61 | 
            -
                      content_dir: Pathname.new(File.expand_path(content_dir_or_string)),
         | 
| 59 | 
            +
                      source_dir: Pathname.new(File.expand_path(source_dir_or_string)),
         | 
| 62 60 | 
             
                      meta: meta_obj,
         | 
| 63 61 | 
             
                      server: server_obj
         | 
| 64 62 | 
             
                    )
         | 
| @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            module Yarrow
         | 
| 2 2 | 
             
              class ConsoleRunner
         | 
| 3 | 
            -
             | 
| 4 3 | 
             
                SUCCESS = 0
         | 
| 5 4 | 
             
                FAILURE = 1
         | 
| 6 5 |  | 
| @@ -12,20 +11,20 @@ module Yarrow | |
| 12 11 | 
             
                }
         | 
| 13 12 |  | 
| 14 13 | 
             
                ALLOWED_CONFIG_FILES = [
         | 
| 15 | 
            -
                   | 
| 16 | 
            -
                   | 
| 14 | 
            +
                  ".yarrowdoc",
         | 
| 15 | 
            +
                  "Yarrowdoc",
         | 
| 16 | 
            +
                  "yarrow.yml"
         | 
| 17 17 | 
             
                ]
         | 
| 18 18 |  | 
| 19 | 
            -
                def initialize( | 
| 19 | 
            +
                def initialize(args, io=STDOUT)
         | 
| 20 | 
            +
                  @arguments = args
         | 
| 20 21 | 
             
                  @out = io
         | 
| 21 | 
            -
                  @arguments = arguments
         | 
| 22 22 | 
             
                  @options = {}
         | 
| 23 23 | 
             
                  @targets = []
         | 
| 24 | 
            -
                  @config = Configuration.load_defaults
         | 
| 25 24 | 
             
                end
         | 
| 26 25 |  | 
| 27 26 | 
             
                def config
         | 
| 28 | 
            -
                  @config
         | 
| 27 | 
            +
                  @config ||= Configuration.load_defaults
         | 
| 29 28 | 
             
                end
         | 
| 30 29 |  | 
| 31 30 | 
             
                def run_application
         | 
| @@ -45,9 +44,7 @@ module Yarrow | |
| 45 44 |  | 
| 46 45 | 
             
                    process_configuration
         | 
| 47 46 |  | 
| 48 | 
            -
                     | 
| 49 | 
            -
             | 
| 50 | 
            -
                    run_output_process
         | 
| 47 | 
            +
                    run_generation_process
         | 
| 51 48 |  | 
| 52 49 | 
             
                    print_footer
         | 
| 53 50 |  | 
| @@ -80,17 +77,29 @@ module Yarrow | |
| 80 77 |  | 
| 81 78 | 
             
                def process_configuration
         | 
| 82 79 | 
             
                  # load_configuration(Dir.pwd)
         | 
| 80 | 
            +
                  default_config = Yarrow::Configuration.load_defaults
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  if @targets.empty?
         | 
| 83 | 
            +
                    @config = default_config
         | 
| 84 | 
            +
                  else
         | 
| 85 | 
            +
                    @config = Yarrow::Config::Instance.new(
         | 
| 86 | 
            +
                      output_dir: default_config.output_dir,
         | 
| 87 | 
            +
                      source_dir: @targets.first,
         | 
| 88 | 
            +
                      meta: default_config.meta,
         | 
| 89 | 
            +
                      server: default_config.meta
         | 
| 90 | 
            +
                    )
         | 
| 91 | 
            +
                  end
         | 
| 83 92 |  | 
| 84 93 | 
             
                  # @targets.each do |input_path|
         | 
| 85 94 | 
             
                  #   @config.deep_merge! load_configuration(input_path)
         | 
| 86 95 | 
             
                  # end
         | 
| 87 96 |  | 
| 88 | 
            -
                  if has_option?(:config)
         | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
                  end
         | 
| 97 | 
            +
                  # if has_option?(:config)
         | 
| 98 | 
            +
                  #   path = @options[:config]
         | 
| 99 | 
            +
                  #   @config.deep_merge! Configuration.load(path)
         | 
| 100 | 
            +
                  # end
         | 
| 92 101 |  | 
| 93 | 
            -
                   | 
| 102 | 
            +
                  #@config.options = @options.to_hash
         | 
| 94 103 |  | 
| 95 104 | 
             
                  # normalize_theme_path
         | 
| 96 105 |  | 
| @@ -139,9 +148,7 @@ module Yarrow | |
| 139 148 |  | 
| 140 149 | 
             
                def run_generation_process
         | 
| 141 150 | 
             
                  generator = Generator.new(@config)
         | 
| 142 | 
            -
                  generator. | 
| 143 | 
            -
                    p manifest
         | 
| 144 | 
            -
                  end
         | 
| 151 | 
            +
                  generator.generate
         | 
| 145 152 | 
             
                end
         | 
| 146 153 |  | 
| 147 154 | 
             
                def print_header
         | 
| @@ -149,7 +156,7 @@ module Yarrow | |
| 149 156 | 
             
                end
         | 
| 150 157 |  | 
| 151 158 | 
             
                def print_footer
         | 
| 152 | 
            -
                  @out.puts "Content generated at { | 
| 159 | 
            +
                  @out.puts "Content generated at #{@config.output_dir}"
         | 
| 153 160 | 
             
                end
         | 
| 154 161 |  | 
| 155 162 | 
             
                def print_error(e)
         | 
| @@ -157,42 +164,8 @@ module Yarrow | |
| 157 164 | 
             
                end
         | 
| 158 165 |  | 
| 159 166 | 
             
                def print_help
         | 
| 160 | 
            -
                   | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
              Usage:
         | 
| 164 | 
            -
             | 
| 165 | 
            -
               $ yarrow [options]
         | 
| 166 | 
            -
               $ yarrow [options] <input>
         | 
| 167 | 
            -
               $ yarrow [options] <input input> <output>
         | 
| 168 | 
            -
             | 
| 169 | 
            -
               Arguments
         | 
| 170 | 
            -
             | 
| 171 | 
            -
               <input>  -  Path to source directory or an individual source file. If not supplied
         | 
| 172 | 
            -
                           defaults to the current working directory. Multiple directories
         | 
| 173 | 
            -
                           can be specified by repeating arguments, separated by whitespace.
         | 
| 174 | 
            -
             | 
| 175 | 
            -
               <output> -  Path to the generated documentation. If not supplied, defaults to
         | 
| 176 | 
            -
                           ./docs in the current working directory. If it does not exist, it
         | 
| 177 | 
            -
                           is created. If it does exist it remains in place, but existing
         | 
| 178 | 
            -
                           files are overwritten by new files with the same name.
         | 
| 179 | 
            -
             | 
| 180 | 
            -
               Options
         | 
| 181 | 
            -
             | 
| 182 | 
            -
               Use -o or --option for boolean switches and --option=value or --option:value
         | 
| 183 | 
            -
               for options that require an explicit value to be set.
         | 
| 184 | 
            -
             | 
| 185 | 
            -
                -h    --help          [switch]    Display this help message and exit
         | 
| 186 | 
            -
                -v    --version       [switch]    Display version header and exit
         | 
| 187 | 
            -
                -c    --config        [string]    Path to a config properties file
         | 
| 188 | 
            -
                -p    --packages   	  [string]    Defines package convention for the model
         | 
| 189 | 
            -
                -t    --theme         [string]    Template theme for generated docs
         | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
            HELP
         | 
| 193 | 
            -
                  @out.puts help
         | 
| 167 | 
            +
                  help_path = Pathname.new(__dir__) + "help.txt"
         | 
| 168 | 
            +
                  @out.puts(help_path.read)
         | 
| 194 169 | 
             
                end
         | 
| 195 | 
            -
             | 
| 196 170 | 
             
              end
         | 
| 197 | 
            -
             | 
| 198 171 | 
             
            end
         | 
    
        data/lib/yarrow/content/graph.rb
    CHANGED
    
    
    
        data/lib/yarrow/defaults.yml
    CHANGED
    
    
    
        data/lib/yarrow/generator.rb
    CHANGED
    
    | @@ -21,17 +21,17 @@ module Yarrow | |
| 21 21 |  | 
| 22 22 | 
             
              class FlattenManifest < Process::StepProcessor
         | 
| 23 23 | 
             
                accepts Content::Graph
         | 
| 24 | 
            -
                provides  | 
| 24 | 
            +
                provides Web::Manifest
         | 
| 25 25 |  | 
| 26 26 | 
             
                def step(content)
         | 
| 27 | 
            -
                   | 
| 27 | 
            +
                  Web::Manifest.build(content.graph)
         | 
| 28 28 | 
             
                end
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 | 
            -
              class BuildOutput < Process::StepProcessor
         | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
              end
         | 
| 31 | 
            +
              # class BuildOutput < Process::StepProcessor
         | 
| 32 | 
            +
              #   accepts Output::Manifest
         | 
| 33 | 
            +
              #   provides Output::Result
         | 
| 34 | 
            +
              # end
         | 
| 35 35 |  | 
| 36 36 | 
             
              # Generates documentation from a model.
         | 
| 37 37 | 
             
              class Generator
         | 
| @@ -50,8 +50,20 @@ module Yarrow | |
| 50 50 | 
             
                  end
         | 
| 51 51 | 
             
                end
         | 
| 52 52 |  | 
| 53 | 
            +
                def generate
         | 
| 54 | 
            +
                  process do |manifest|
         | 
| 55 | 
            +
                    generators.each do |generator|
         | 
| 56 | 
            +
                      generator.generate(manifest)
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 53 61 | 
             
                private
         | 
| 54 62 |  | 
| 55 63 | 
             
                attr_reader :config, :workflow
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                def generators
         | 
| 66 | 
            +
                  [Web::Generator.new(config)]
         | 
| 67 | 
            +
                end
         | 
| 56 68 | 
             
              end
         | 
| 57 69 | 
             
            end
         | 
    
        data/lib/yarrow/help.txt
    ADDED
    
    | @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            See https://github.com/maetl/yarrow for more information.
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Usage: yarrow [options] <source_dir...> <output_dir>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            yarrow [options]
         | 
| 6 | 
            +
            yarrow [options] <source_dir>
         | 
| 7 | 
            +
            yarrow [options] <source_dir> <output_dir>
         | 
| 8 | 
            +
            yarrow [options] <source_dir source_dir> <output_dir>
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Arguments
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            <source_dir> - Path to source directory or an individual source file. If not
         | 
| 13 | 
            +
                           supplied defaults to the current working directory. Multiple
         | 
| 14 | 
            +
                           directories can be specified by repeating arguments, separated
         | 
| 15 | 
            +
                           by whitespace.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            <output_dir> - Path to the generated documentation. If not supplied, defaults
         | 
| 18 | 
            +
                           to `./docs` in the current working directory. If it does not
         | 
| 19 | 
            +
                           exist, it is created. If it does exist it remains in place, but
         | 
| 20 | 
            +
                           existing files are overwritten by new files with the same name.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            Options
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            Use -o or --option for boolean switches and --option=value or --option:value
         | 
| 25 | 
            +
            for options that require an explicit value to be set.
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              -h    --help        [switch]    Display this help message and exit
         | 
| 28 | 
            +
              -v    --version     [switch]    Display version header and exit
         | 
| 29 | 
            +
              -c    --config      [string]    Path to a config properties file
         | 
| 30 | 
            +
              -p    --packages    [string]    Defines package convention for the model
         | 
| 31 | 
            +
              -t    --theme       [string]    Template theme for generated docs
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Not all these options currently work as they date back to when this library
         | 
| 34 | 
            +
            was used for generating documentation for PHP codebases, before it was
         | 
| 35 | 
            +
            generalised into a static site generator.
         | 
| @@ -2,11 +2,10 @@ module Yarrow | |
| 2 2 | 
             
              module Schema
         | 
| 3 3 | 
             
                module Definitions
         | 
| 4 4 | 
             
                  DEFINED_TYPES = {
         | 
| 5 | 
            -
                    #string: Types::String,
         | 
| 6 5 | 
             
                    string: Types::Instance.of(String),
         | 
| 7 | 
            -
                    #integer: Types::Integer,
         | 
| 8 6 | 
             
                    integer: Types::Instance.of(Integer),
         | 
| 9 | 
            -
                     | 
| 7 | 
            +
                    symbol: Types::Instance.of(Symbol),
         | 
| 8 | 
            +
                    path: Types::Instance.of(Pathname).accept(String),
         | 
| 10 9 | 
             
                    any: Types::Any.new
         | 
| 11 10 | 
             
                  }
         | 
| 12 11 |  | 
    
        data/lib/yarrow/schema/entity.rb
    CHANGED
    
    | @@ -33,11 +33,26 @@ module Yarrow | |
| 33 33 |  | 
| 34 34 | 
             
                  def to_h
         | 
| 35 35 | 
             
                    dictionary.attr_names.reduce({}) do |attr_dict, name|
         | 
| 36 | 
            -
                       | 
| 36 | 
            +
                      value = instance_variable_get("@#{name}")
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                      attr_dict[name] = if value.respond_to?(:to_h)
         | 
| 39 | 
            +
                        value.to_h
         | 
| 40 | 
            +
                      else
         | 
| 41 | 
            +
                        value
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
             | 
| 37 44 | 
             
                      attr_dict
         | 
| 38 45 | 
             
                    end
         | 
| 39 46 | 
             
                  end
         | 
| 40 47 |  | 
| 48 | 
            +
                  def merge(other)
         | 
| 49 | 
            +
                    unless other.is_a?(self.class)
         | 
| 50 | 
            +
                      raise ArgumentError.new("cannot merge entities that are not the same type")
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                    self.class.new(to_h.merge(other.to_h))
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 41 56 | 
             
                  private
         | 
| 42 57 |  | 
| 43 58 | 
             
                  def dictionary
         | 
    
        data/lib/yarrow/schema/types.rb
    CHANGED
    
    | @@ -18,20 +18,20 @@ module Yarrow | |
| 18 18 | 
             
                      new("#{t} does not implement #{m}")
         | 
| 19 19 | 
             
                    end
         | 
| 20 20 | 
             
                  end
         | 
| 21 | 
            -
             | 
| 21 | 
            +
             | 
| 22 22 | 
             
                  class TypeClass
         | 
| 23 23 | 
             
                    def self.of(unit_type)
         | 
| 24 24 | 
             
                      new(unit_type)
         | 
| 25 25 | 
             
                    end
         | 
| 26 26 |  | 
| 27 27 | 
             
                    attr_reader :unit, :accepts
         | 
| 28 | 
            -
             | 
| 28 | 
            +
             | 
| 29 29 | 
             
                    def initialize(unit_type=nil)
         | 
| 30 30 | 
             
                      @unit = unit_type
         | 
| 31 31 | 
             
                      @accepts = {}
         | 
| 32 32 | 
             
                    end
         | 
| 33 33 |  | 
| 34 | 
            -
                    def accept(type, constructor)
         | 
| 34 | 
            +
                    def accept(type, constructor=:new)
         | 
| 35 35 | 
             
                      accepts[type] = constructor
         | 
| 36 36 | 
             
                      self
         | 
| 37 37 | 
             
                    end
         | 
| @@ -44,7 +44,7 @@ module Yarrow | |
| 44 44 | 
             
                      constructor = accepts[input.class]
         | 
| 45 45 | 
             
                      unit.send(constructor, input)
         | 
| 46 46 | 
             
                    end
         | 
| 47 | 
            -
             | 
| 47 | 
            +
             | 
| 48 48 | 
             
                    def check_instance_of!(input)
         | 
| 49 49 | 
             
                      unless input.instance_of?(unit)
         | 
| 50 50 | 
             
                        raise CastError.instance_of(input.class, unit)
         | 
| @@ -74,27 +74,27 @@ module Yarrow | |
| 74 74 | 
             
                      check(input)
         | 
| 75 75 | 
             
                    end
         | 
| 76 76 | 
             
                  end
         | 
| 77 | 
            -
             | 
| 77 | 
            +
             | 
| 78 78 | 
             
                  class Any < TypeClass
         | 
| 79 79 | 
             
                    def cast(input)
         | 
| 80 80 | 
             
                      input
         | 
| 81 81 | 
             
                    end
         | 
| 82 82 | 
             
                  end
         | 
| 83 | 
            -
             | 
| 83 | 
            +
             | 
| 84 84 | 
             
                  class Instance < TypeClass
         | 
| 85 85 | 
             
                    def check(input)
         | 
| 86 86 | 
             
                      check_instance_of!(input)
         | 
| 87 87 | 
             
                      input
         | 
| 88 88 | 
             
                    end
         | 
| 89 89 | 
             
                  end
         | 
| 90 | 
            -
             | 
| 90 | 
            +
             | 
| 91 91 | 
             
                  class Kind < TypeClass
         | 
| 92 92 | 
             
                    def check(input)
         | 
| 93 93 | 
             
                      check_kind_of!(input)
         | 
| 94 94 | 
             
                      input
         | 
| 95 95 | 
             
                    end
         | 
| 96 96 | 
             
                  end
         | 
| 97 | 
            -
             | 
| 97 | 
            +
             | 
| 98 98 | 
             
                  class Interface < TypeClass
         | 
| 99 99 | 
             
                    def self.any(*args)
         | 
| 100 100 | 
             
                      interface_type = new(args)
         | 
| @@ -117,13 +117,79 @@ module Yarrow | |
| 117 117 | 
             
                      when :any then check_respond_to_any!(input, members)
         | 
| 118 118 | 
             
                      when :all then check_respond_to_all!(input, members)
         | 
| 119 119 | 
             
                      end
         | 
| 120 | 
            -
             | 
| 120 | 
            +
             | 
| 121 121 | 
             
                      input
         | 
| 122 122 | 
             
                    end
         | 
| 123 123 | 
             
                  end
         | 
| 124 124 |  | 
| 125 | 
            -
                   | 
| 125 | 
            +
                  module CompoundType
         | 
| 126 | 
            +
                    def instance(unit_type)
         | 
| 127 | 
            +
                      @unit = Instance.of(unit_type)
         | 
| 128 | 
            +
                      self
         | 
| 129 | 
            +
                    end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                    def kind(unit_type)
         | 
| 132 | 
            +
                      @unit = Kind.of(unit_type)
         | 
| 133 | 
            +
                      self
         | 
| 134 | 
            +
                    end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                    def interface(*args)
         | 
| 137 | 
            +
                      @unit = Interface.of(args)
         | 
| 138 | 
            +
                      self
         | 
| 139 | 
            +
                    end
         | 
| 140 | 
            +
                  end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                  class List < TypeClass
         | 
| 143 | 
            +
                    include CompoundType
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                    def self.of(unit_type)
         | 
| 146 | 
            +
                      new(Instance.of(unit_type))
         | 
| 147 | 
            +
                    end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                    def cast(input)
         | 
| 150 | 
            +
                      input.map do |item|
         | 
| 151 | 
            +
                        unit.cast(item)
         | 
| 152 | 
            +
                      end
         | 
| 153 | 
            +
                    end
         | 
| 154 | 
            +
                  end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                  class Map < TypeClass
         | 
| 157 | 
            +
                    include CompoundType
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    def self.of(map_spec)
         | 
| 160 | 
            +
                      if map_spec.is_a?(Hash)
         | 
| 161 | 
            +
                        if map_spec.size == 1
         | 
| 162 | 
            +
                          key_type, value_type = map_spec.first
         | 
| 163 | 
            +
                        else
         | 
| 164 | 
            +
                          raise "map requires a single key => value type"
         | 
| 165 | 
            +
                        end
         | 
| 166 | 
            +
                      else
         | 
| 167 | 
            +
                        key_type = Symbol
         | 
| 168 | 
            +
                        value_type = map_spec
         | 
| 169 | 
            +
                      end
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                      new(Instance.of(key_type), Instance.of(value_type))
         | 
| 172 | 
            +
                    end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                    attr_reader :key_type
         | 
| 175 | 
            +
                    alias value_type unit
         | 
| 176 | 
            +
             | 
| 177 | 
            +
                    def initialize(key_type, value_type)
         | 
| 178 | 
            +
                      @key_type = key_type
         | 
| 179 | 
            +
                      super(value_type)
         | 
| 180 | 
            +
                    end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    def check(input)
         | 
| 183 | 
            +
                      keys = input.keys.map do |key|
         | 
| 184 | 
            +
                        key_type.cast(key)
         | 
| 185 | 
            +
                      end
         | 
| 186 | 
            +
                      values = input.values.map do |value|
         | 
| 187 | 
            +
                        value_type.cast(value)
         | 
| 188 | 
            +
                      end
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                      [keys, values].transpose.to_h
         | 
| 191 | 
            +
                    end
         | 
| 126 192 | 
             
                  end
         | 
| 127 193 | 
             
                end
         | 
| 128 194 | 
             
              end
         | 
| 129 | 
            -
            end
         | 
| 195 | 
            +
            end
         | 
    
        data/lib/yarrow/schema/value.rb
    CHANGED
    
    | @@ -50,6 +50,32 @@ module Yarrow | |
| 50 50 | 
             
                      freeze
         | 
| 51 51 | 
             
                    end
         | 
| 52 52 |  | 
| 53 | 
            +
                    struct.define_method(:merge) do |other|
         | 
| 54 | 
            +
                      unless other.is_a?(self.class)
         | 
| 55 | 
            +
                        raise ArgumentError.new("cannot merge incompatible values")
         | 
| 56 | 
            +
                      end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                      kwargs = validator.attr_names.reduce({}) do |data, attr_name|
         | 
| 59 | 
            +
                        current_val = self.send(attr_name)
         | 
| 60 | 
            +
                        other_val = other.send(attr_name)
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                        # TODO: handle optional types better
         | 
| 63 | 
            +
                        # call out to dictionary?
         | 
| 64 | 
            +
                        # validator.merge(attr_name, current_val, other_val)
         | 
| 65 | 
            +
                        data[attr_name] = if current_val.nil?
         | 
| 66 | 
            +
                          other_val
         | 
| 67 | 
            +
                        elsif other_val.nil?
         | 
| 68 | 
            +
                          current_val
         | 
| 69 | 
            +
                        else
         | 
| 70 | 
            +
                          other_val
         | 
| 71 | 
            +
                        end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                        data
         | 
| 74 | 
            +
                      end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                      struct.new(**kwargs)
         | 
| 77 | 
            +
                    end
         | 
| 78 | 
            +
             | 
| 53 79 | 
             
                    struct
         | 
| 54 80 | 
             
                  end
         | 
| 55 81 | 
             
                end
         | 
    
        data/lib/yarrow/server.rb
    CHANGED
    
    
    
        data/lib/yarrow/version.rb
    CHANGED
    
    
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            module Yarrow
         | 
| 2 | 
            +
              module Web
         | 
| 3 | 
            +
                class Document
         | 
| 4 | 
            +
                  # This class is somewhat verbose for simplicity and long-term maintainability
         | 
| 5 | 
            +
                  # (having a clear and easy to follow construction, rather than doing anything
         | 
| 6 | 
            +
                  # too clever which has burned this lib in the past).
         | 
| 7 | 
            +
                  def initialize(item, parent, url_strategy)
         | 
| 8 | 
            +
                    @item = item
         | 
| 9 | 
            +
                    @parent = parent
         | 
| 10 | 
            +
                    @url_strategy = url_strategy
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def name
         | 
| 14 | 
            +
                    @item.props[:name]
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def title
         | 
| 18 | 
            +
                    @item.props[:title]
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def type
         | 
| 22 | 
            +
                    @item.props[:type]
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def url
         | 
| 26 | 
            +
                    case @url_strategy
         | 
| 27 | 
            +
                    when :mirror_source
         | 
| 28 | 
            +
                      unless @parent.nil?
         | 
| 29 | 
            +
                        "/#{@parent.props[:name]}/#{name}"
         | 
| 30 | 
            +
                      else
         | 
| 31 | 
            +
                        "/#{name}/"
         | 
| 32 | 
            +
                      end
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,57 @@ | |
| 1 | 
            +
            module Yarrow
         | 
| 2 | 
            +
              module Web
         | 
| 3 | 
            +
                class Generator
         | 
| 4 | 
            +
                  attr_reader :config
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def initialize(config)
         | 
| 7 | 
            +
                    @config = config
         | 
| 8 | 
            +
                    # Config is here but we haven’t decided on schema for web publishing fields
         | 
| 9 | 
            +
                    # so hard-code the needed values as part of this prototype
         | 
| 10 | 
            +
                    @default_host = "http://example.com"
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def generate(manifest)
         | 
| 14 | 
            +
                    Parallel.each(manifest.documents) do |document|
         | 
| 15 | 
            +
                      write_document(document)
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                    #generate_sitemap(manifest)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def write_document(document)
         | 
| 21 | 
            +
                    template = Template.for_document(document)
         | 
| 22 | 
            +
                    write_output_file(document.url, template.render(document))
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def write_output_file(url, content)
         | 
| 26 | 
            +
                    # If the target path is a directory,
         | 
| 27 | 
            +
                    # generate a default index filename.
         | 
| 28 | 
            +
                    if url[url.length-1] == '/'
         | 
| 29 | 
            +
                      url = "#{url}index"
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    # Construct full path to file in output dir
         | 
| 33 | 
            +
                    path = @config.output_dir.join(url.delete_prefix("/")).sub_ext('.html')
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    # Create directory path if it doesn’t exist
         | 
| 36 | 
            +
                    FileUtils.mkdir_p(path.dirname)
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    # Write out the file
         | 
| 39 | 
            +
                    File.open(path.to_s, 'w+:UTF-8') do |file|
         | 
| 40 | 
            +
                      file.puts(content)
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  def generate_sitemap(manifest)
         | 
| 45 | 
            +
                    # SitemapGenerator::Sitemap.default_host = @default_host
         | 
| 46 | 
            +
                    # SitemapGenerator::Sitemap.public_path = @public_dir
         | 
| 47 | 
            +
                    # SitemapGenerator::Sitemap.create do
         | 
| 48 | 
            +
                    #   manifest.documents.each do |document|
         | 
| 49 | 
            +
                    #     # Options: :changefreq, :lastmod, :priority, :expires
         | 
| 50 | 
            +
                    #     #add(document.url, lastmod: document.published_at)
         | 
| 51 | 
            +
                    #     add(document.url)
         | 
| 52 | 
            +
                    #   end
         | 
| 53 | 
            +
                    # end
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
            end
         | 
    
        data/lib/yarrow/web/manifest.rb
    CHANGED
    
    | @@ -1,8 +1,65 @@ | |
| 1 1 | 
             
            module Yarrow
         | 
| 2 2 | 
             
              module Web
         | 
| 3 3 | 
             
                class Manifest
         | 
| 4 | 
            +
                  def self.build(graph)
         | 
| 5 | 
            +
                    manifest = new
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                    graph.n(:collection).each do |collection|
         | 
| 8 | 
            +
                      # TODO: raise error if both content_only and index_only are set
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      # If the collection is tagged :content_only then skip top level listing/index
         | 
| 11 | 
            +
                      unless collection.props[:content_only]
         | 
| 12 | 
            +
                        manifest.add_document(collection_context(collection))
         | 
| 13 | 
            +
                      end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                      # If the collection is tagged :index_only then skip adding individual documents
         | 
| 16 | 
            +
                      unless collection.props[:index_only]
         | 
| 17 | 
            +
                        collection.out(:item).each do |item|
         | 
| 18 | 
            +
                          #if item[:entity].status.to_sym == :published
         | 
| 19 | 
            +
                          manifest.add_document(item_context(item))
         | 
| 20 | 
            +
                          #end
         | 
| 21 | 
            +
                        end
         | 
| 22 | 
            +
                      end
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    manifest
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  attr_reader :documents, :assets
         | 
| 29 | 
            +
             | 
| 4 30 | 
             
                  def initialize
         | 
| 31 | 
            +
                    @documents = []
         | 
| 32 | 
            +
                    @assets = []
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def self.collection_context(collection)
         | 
| 36 | 
            +
                    # Yarrow::Output::Context.new(
         | 
| 37 | 
            +
                    #   parent: collection.in(:collection).first,
         | 
| 38 | 
            +
                    #   name: collection.props[:name],
         | 
| 39 | 
            +
                    #   #url: collection.props[:url],
         | 
| 40 | 
            +
                    #   title: collection.props[:title],
         | 
| 41 | 
            +
                    #   type: collection.props[:type]
         | 
| 42 | 
            +
                    # )
         | 
| 43 | 
            +
                    Document.new(collection, collection.in(:collection).first, :mirror_source)
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  def self.item_context(item)
         | 
| 47 | 
            +
                    # Yarrow::Output::Context.new(
         | 
| 48 | 
            +
                    #   parent: item.in(:collection).first,
         | 
| 49 | 
            +
                    #   name: item.props[:name],
         | 
| 50 | 
            +
                    #   #url: item.props[:url],
         | 
| 51 | 
            +
                    #   title: item.props[:title],
         | 
| 52 | 
            +
                    #   type: item.props[:type]
         | 
| 53 | 
            +
                    # )
         | 
| 54 | 
            +
                    Document.new(item, item.in(:collection).first, :mirror_source)
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  def add_document(document)
         | 
| 58 | 
            +
                    @documents << document
         | 
| 59 | 
            +
                  end
         | 
| 5 60 |  | 
| 61 | 
            +
                  def add_asset(asset)
         | 
| 62 | 
            +
                    @assets << asset
         | 
| 6 63 | 
             
                  end
         | 
| 7 64 | 
             
                end
         | 
| 8 65 | 
             
              end
         | 
    
        data/lib/yarrow/web/template.rb
    CHANGED
    
    | @@ -1,8 +1,28 @@ | |
| 1 1 | 
             
            module Yarrow
         | 
| 2 2 | 
             
              module Web
         | 
| 3 3 | 
             
                class Template
         | 
| 4 | 
            -
                  def  | 
| 4 | 
            +
                  def self.for_document(document)
         | 
| 5 | 
            +
                    layout_name = if document.respond_to?(:layout)
         | 
| 6 | 
            +
                      document.layout || document.type
         | 
| 7 | 
            +
                    else
         | 
| 8 | 
            +
                      document.type
         | 
| 9 | 
            +
                    end
         | 
| 5 10 |  | 
| 11 | 
            +
                    @template_dir = "./spec/fixtures/templates/doctest"
         | 
| 12 | 
            +
                    @template_ext = ".html"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    template_file = "#{layout_name}#{@template_ext}"
         | 
| 15 | 
            +
                    template_path = Pathname.new(@template_dir) + template_file
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                    new(template_path.read)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def initialize(source)
         | 
| 21 | 
            +
                    @source = source
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def render(document)
         | 
| 25 | 
            +
                    Mustache.render(@source, document)
         | 
| 6 26 | 
             
                  end
         | 
| 7 27 | 
             
                end
         | 
| 8 28 | 
             
              end
         | 
    
        data/lib/yarrow.rb
    CHANGED
    
    | @@ -1,46 +1,50 @@ | |
| 1 | 
            -
            require  | 
| 2 | 
            -
            require  | 
| 1 | 
            +
            require "pathname"
         | 
| 2 | 
            +
            require "yaml"
         | 
| 3 | 
            +
            require "mustache"
         | 
| 4 | 
            +
            require "parallel"
         | 
| 3 5 |  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require 'yarrow/extensions'
         | 
| 6 | 
            -
            require 'yarrow/symbols'
         | 
| 7 | 
            -
            require 'yarrow/logging'
         | 
| 8 | 
            -
            require 'yarrow/schema/types'
         | 
| 9 | 
            -
            require 'yarrow/schema/definitions'
         | 
| 10 | 
            -
            require 'yarrow/schema/dictionary'
         | 
| 11 | 
            -
            require 'yarrow/schema/entity'
         | 
| 12 | 
            -
            require 'yarrow/schema/value'
         | 
| 13 | 
            -
            require 'yarrow/config'
         | 
| 14 | 
            -
            require 'yarrow/configuration'
         | 
| 15 | 
            -
            require 'yarrow/console_runner'
         | 
| 16 | 
            -
            require 'yarrow/tools/front_matter'
         | 
| 17 | 
            -
            require 'yarrow/tools/content_utils'
         | 
| 18 | 
            -
            require 'yarrow/content/graph'
         | 
| 19 | 
            -
            require 'yarrow/content/source'
         | 
| 20 | 
            -
            require 'yarrow/content/expansion'
         | 
| 21 | 
            -
            require 'yarrow/content/expansion_strategy'
         | 
| 22 | 
            -
            require 'yarrow/content/tree_expansion'
         | 
| 23 | 
            -
            require 'yarrow/content/manifest'
         | 
| 24 | 
            -
            require 'yarrow/content/resource'
         | 
| 25 | 
            -
            require 'yarrow/content/model'
         | 
| 26 | 
            -
            require 'yarrow/content/policy'
         | 
| 27 | 
            -
            require 'yarrow/output/mapper'
         | 
| 28 | 
            -
            require 'yarrow/output/generator'
         | 
| 29 | 
            -
            require 'yarrow/output/context'
         | 
| 30 | 
            -
            require 'yarrow/output/result'
         | 
| 31 | 
            -
            require 'yarrow/output/web/indexed_file'
         | 
| 32 | 
            -
            require 'yarrow/content_map'
         | 
| 33 | 
            -
            require 'yarrow/server'
         | 
| 34 | 
            -
            require 'yarrow/server/livereload'
         | 
| 6 | 
            +
            require "extensions/mementus"
         | 
| 35 7 |  | 
| 36 | 
            -
            require  | 
| 37 | 
            -
            require  | 
| 38 | 
            -
            require  | 
| 39 | 
            -
            require  | 
| 40 | 
            -
            require  | 
| 8 | 
            +
            require "yarrow/version"
         | 
| 9 | 
            +
            require "yarrow/symbols"
         | 
| 10 | 
            +
            require "yarrow/logging"
         | 
| 11 | 
            +
            require "yarrow/schema/types"
         | 
| 12 | 
            +
            require "yarrow/schema/definitions"
         | 
| 13 | 
            +
            require "yarrow/schema/dictionary"
         | 
| 14 | 
            +
            require "yarrow/schema/entity"
         | 
| 15 | 
            +
            require "yarrow/schema/value"
         | 
| 16 | 
            +
            require "yarrow/schema/registry"
         | 
| 17 | 
            +
            require "yarrow/config"
         | 
| 18 | 
            +
            require "yarrow/configuration"
         | 
| 19 | 
            +
            require "yarrow/console_runner"
         | 
| 20 | 
            +
            require "yarrow/tools/front_matter"
         | 
| 21 | 
            +
            require "yarrow/tools/content_utils"
         | 
| 22 | 
            +
            require "yarrow/content/graph"
         | 
| 23 | 
            +
            require "yarrow/content/source"
         | 
| 24 | 
            +
            require "yarrow/content/expansion"
         | 
| 25 | 
            +
            require "yarrow/content/expansion_strategy"
         | 
| 26 | 
            +
            require "yarrow/content/tree_expansion"
         | 
| 27 | 
            +
            require "yarrow/content/resource"
         | 
| 28 | 
            +
            require "yarrow/content/model"
         | 
| 29 | 
            +
            require "yarrow/content/policy"
         | 
| 30 | 
            +
            require "yarrow/web/manifest"
         | 
| 31 | 
            +
            require "yarrow/web/document"
         | 
| 32 | 
            +
            require "yarrow/web/generator"
         | 
| 33 | 
            +
            require "yarrow/web/template"
         | 
| 34 | 
            +
            require "yarrow/output/context"
         | 
| 35 | 
            +
            require "yarrow/output/web/indexed_file"
         | 
| 36 | 
            +
            require "yarrow/content_map"
         | 
| 37 | 
            +
            require "yarrow/server"
         | 
| 38 | 
            +
            require "yarrow/server/livereload"
         | 
| 41 39 |  | 
| 42 | 
            -
            require  | 
| 40 | 
            +
            require "yarrow/process/workflow"
         | 
| 41 | 
            +
            require "yarrow/process/step_processor"
         | 
| 42 | 
            +
            require "yarrow/process/expand_content"
         | 
| 43 | 
            +
            require "yarrow/process/extract_source"
         | 
| 44 | 
            +
            require "yarrow/process/project_manifest"
         | 
| 43 45 |  | 
| 44 | 
            -
             | 
| 46 | 
            +
            require "yarrow/generator"
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            # Dir[File.dirname(__FILE__) + "/yarrow/generators/*.rb"].each do |generator|
         | 
| 45 49 | 
             
            #   require generator
         | 
| 46 50 | 
             
            # end
         | 
    
        data/yarrow.gemspec
    CHANGED
    
    | @@ -13,12 +13,15 @@ Gem::Specification.new do |spec| | |
| 13 13 | 
             
              spec.files       = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 14 14 | 
             
              spec.executables << 'yarrow'
         | 
| 15 15 | 
             
              spec.executables << 'yarrow-server'
         | 
| 16 | 
            +
              spec.add_runtime_dependency 'addressable', '~> 2.8'
         | 
| 16 17 | 
             
              spec.add_runtime_dependency 'mementus', '~> 0.8'
         | 
| 17 18 | 
             
              spec.add_runtime_dependency 'rack', '~> 3.0'
         | 
| 18 19 | 
             
              spec.add_runtime_dependency 'rackup', '~> 0.2'
         | 
| 19 20 | 
             
              spec.add_runtime_dependency 'rack-livereload', '~> 0.3'
         | 
| 20 21 | 
             
              spec.add_runtime_dependency 'eventmachine', '~> 1.2'
         | 
| 21 22 | 
             
              spec.add_runtime_dependency 'em-websocket', '~> 0.5.1'
         | 
| 23 | 
            +
              spec.add_runtime_dependency 'mustache', '~> 1.1.1'
         | 
| 24 | 
            +
              spec.add_runtime_dependency 'parallel', '~> 1.22.1'
         | 
| 22 25 | 
             
              spec.add_runtime_dependency 'strings-inflection', '~> 0.1'
         | 
| 23 26 | 
             
              spec.add_runtime_dependency 'strings-case', '~> 0.3'
         | 
| 24 27 | 
             
              spec.add_runtime_dependency 'kramdown', '~> 2.4.0'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: yarrow
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Mark Rickerby
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-11-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: addressable
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '2.8'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '2.8'
         | 
| 13 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 28 | 
             
              name: mementus
         | 
| 15 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -94,6 +108,34 @@ dependencies: | |
| 94 108 | 
             
                - - "~>"
         | 
| 95 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 110 | 
             
                    version: 0.5.1
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: mustache
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: 1.1.1
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: 1.1.1
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: parallel
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "~>"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: 1.22.1
         | 
| 132 | 
            +
              type: :runtime
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: 1.22.1
         | 
| 97 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 140 | 
             
              name: strings-inflection
         | 
| 99 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -210,6 +252,7 @@ files: | |
| 210 252 | 
             
            - SERVER.md
         | 
| 211 253 | 
             
            - bin/yarrow
         | 
| 212 254 | 
             
            - bin/yarrow-server
         | 
| 255 | 
            +
            - lib/extensions/mementus.rb
         | 
| 213 256 | 
             
            - lib/yarrow.rb
         | 
| 214 257 | 
             
            - lib/yarrow/assets.rb
         | 
| 215 258 | 
             
            - lib/yarrow/assets/manifest.rb
         | 
| @@ -220,7 +263,6 @@ files: | |
| 220 263 | 
             
            - lib/yarrow/content/expansion.rb
         | 
| 221 264 | 
             
            - lib/yarrow/content/expansion_strategy.rb
         | 
| 222 265 | 
             
            - lib/yarrow/content/graph.rb
         | 
| 223 | 
            -
            - lib/yarrow/content/manifest.rb
         | 
| 224 266 | 
             
            - lib/yarrow/content/model.rb
         | 
| 225 267 | 
             
            - lib/yarrow/content/policy.rb
         | 
| 226 268 | 
             
            - lib/yarrow/content/resource.rb
         | 
| @@ -228,14 +270,10 @@ files: | |
| 228 270 | 
             
            - lib/yarrow/content/tree_expansion.rb
         | 
| 229 271 | 
             
            - lib/yarrow/content_map.rb
         | 
| 230 272 | 
             
            - lib/yarrow/defaults.yml
         | 
| 231 | 
            -
            - lib/yarrow/extensions.rb
         | 
| 232 | 
            -
            - lib/yarrow/extensions/mementus.rb
         | 
| 233 273 | 
             
            - lib/yarrow/generator.rb
         | 
| 274 | 
            +
            - lib/yarrow/help.txt
         | 
| 234 275 | 
             
            - lib/yarrow/logging.rb
         | 
| 235 276 | 
             
            - lib/yarrow/output/context.rb
         | 
| 236 | 
            -
            - lib/yarrow/output/generator.rb
         | 
| 237 | 
            -
            - lib/yarrow/output/mapper.rb
         | 
| 238 | 
            -
            - lib/yarrow/output/result.rb
         | 
| 239 277 | 
             
            - lib/yarrow/output/web/indexed_file.rb
         | 
| 240 278 | 
             
            - lib/yarrow/process/expand_content.rb
         | 
| 241 279 | 
             
            - lib/yarrow/process/extract_source.rb
         | 
| @@ -245,6 +283,7 @@ files: | |
| 245 283 | 
             
            - lib/yarrow/schema/definitions.rb
         | 
| 246 284 | 
             
            - lib/yarrow/schema/dictionary.rb
         | 
| 247 285 | 
             
            - lib/yarrow/schema/entity.rb
         | 
| 286 | 
            +
            - lib/yarrow/schema/registry.rb
         | 
| 248 287 | 
             
            - lib/yarrow/schema/types.rb
         | 
| 249 288 | 
             
            - lib/yarrow/schema/validations/array.rb
         | 
| 250 289 | 
             
            - lib/yarrow/schema/validations/object.rb
         | 
| @@ -257,7 +296,8 @@ files: | |
| 257 296 | 
             
            - lib/yarrow/tools/content_utils.rb
         | 
| 258 297 | 
             
            - lib/yarrow/tools/front_matter.rb
         | 
| 259 298 | 
             
            - lib/yarrow/version.rb
         | 
| 260 | 
            -
            - lib/yarrow/web/ | 
| 299 | 
            +
            - lib/yarrow/web/document.rb
         | 
| 300 | 
            +
            - lib/yarrow/web/generator.rb
         | 
| 261 301 | 
             
            - lib/yarrow/web/manifest.rb
         | 
| 262 302 | 
             
            - lib/yarrow/web/static_asset.rb
         | 
| 263 303 | 
             
            - lib/yarrow/web/template.rb
         | 
| @@ -1,61 +0,0 @@ | |
| 1 | 
            -
            module Yarrow
         | 
| 2 | 
            -
              module Content
         | 
| 3 | 
            -
                class Manifest
         | 
| 4 | 
            -
                  def self.build(graph)
         | 
| 5 | 
            -
                    manifest = new
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                    graph.n(:collection).each do |collection|
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                      unless collection.props[:content_only]
         | 
| 10 | 
            -
                        manifest.add_document(collection_context(collection))
         | 
| 11 | 
            -
                      end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                      unless collection.props[:index_only]
         | 
| 14 | 
            -
                        collection.out(:item).each do |item|
         | 
| 15 | 
            -
                          #if item[:entity].status.to_sym == :published
         | 
| 16 | 
            -
                          manifest.add_document(item_context(item))
         | 
| 17 | 
            -
                          #end
         | 
| 18 | 
            -
                        end
         | 
| 19 | 
            -
                      end
         | 
| 20 | 
            -
                    end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                    manifest
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                  attr_reader :documents, :assets
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                  def initialize
         | 
| 28 | 
            -
                    @documents = []
         | 
| 29 | 
            -
                    @assets = []
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                  def self.collection_context(collection)
         | 
| 33 | 
            -
                    Yarrow::Output::Context.new(
         | 
| 34 | 
            -
                      parent: collection.in(:collection).first,
         | 
| 35 | 
            -
                      name: collection.props[:name],
         | 
| 36 | 
            -
                      #url: collection.props[:url],
         | 
| 37 | 
            -
                      title: collection.props[:title],
         | 
| 38 | 
            -
                      type: collection.props[:type]
         | 
| 39 | 
            -
                    )
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  def self.item_context(item)
         | 
| 43 | 
            -
                    Yarrow::Output::Context.new(
         | 
| 44 | 
            -
                      parent: item.in(:collection).first,
         | 
| 45 | 
            -
                      name: item.props[:name],
         | 
| 46 | 
            -
                      #url: item.props[:url],
         | 
| 47 | 
            -
                      title: item.props[:title],
         | 
| 48 | 
            -
                      type: item.props[:type]
         | 
| 49 | 
            -
                    )
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                  def add_document(document)
         | 
| 53 | 
            -
                    @documents << document
         | 
| 54 | 
            -
                  end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                  def add_asset(asset)
         | 
| 57 | 
            -
                    @assets << asset
         | 
| 58 | 
            -
                  end
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
              end
         | 
| 61 | 
            -
            end
         | 
    
        data/lib/yarrow/extensions.rb
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            require "yarrow/extensions/mementus"
         | 
| @@ -1,43 +0,0 @@ | |
| 1 | 
            -
            module Yarrow
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                # Generates documentation from an object model.
         | 
| 4 | 
            -
                class Generator
         | 
| 5 | 
            -
                  def initialize(config={})
         | 
| 6 | 
            -
                    @config = config
         | 
| 7 | 
            -
                  end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                  # Mapping between template types and provided object model
         | 
| 10 | 
            -
                  def object_map
         | 
| 11 | 
            -
                    @config[:output][:object_map]
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  # Mapping between template types and provided output templates.
         | 
| 15 | 
            -
                  def template_map
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  # Template converter used by this generator instance.
         | 
| 20 | 
            -
                  def converter
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  def write_output_file(filename, content)
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                  # Builds the output documentation.
         | 
| 28 | 
            -
                  def build_docs
         | 
| 29 | 
            -
                    object_map.each do |index, objects|
         | 
| 30 | 
            -
                      objects.each do |object|
         | 
| 31 | 
            -
                        template_context = {
         | 
| 32 | 
            -
                          #:meta => Site
         | 
| 33 | 
            -
                          index => object
         | 
| 34 | 
            -
                        }
         | 
| 35 | 
            -
                        content = converter.render(template_map[index], template_context)
         | 
| 36 | 
            -
                        filename = converter.filename_for(object)
         | 
| 37 | 
            -
                        write_output_file(filename, content)
         | 
| 38 | 
            -
                      end
         | 
| 39 | 
            -
                    end
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
                end
         | 
| 42 | 
            -
              end
         | 
| 43 | 
            -
            end
         | 
    
        data/lib/yarrow/output/mapper.rb
    DELETED
    
    | @@ -1,23 +0,0 @@ | |
| 1 | 
            -
            module Yarrow
         | 
| 2 | 
            -
              module Output
         | 
| 3 | 
            -
                class Mapper
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                  def initialize(config)
         | 
| 6 | 
            -
                    @config = config
         | 
| 7 | 
            -
                  end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                  def object_map
         | 
| 10 | 
            -
                    @config.output.object_map
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def template_map
         | 
| 14 | 
            -
                    @config.output.template_map
         | 
| 15 | 
            -
                  end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  def model
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
            end
         | 
    
        data/lib/yarrow/output/result.rb
    DELETED