alf-doc 0.15.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.
- data/CHANGELOG.md +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +59 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +12 -0
- data/README.md +10 -0
- data/Rakefile +14 -0
- data/lib/alf/doc/loader.rb +1 -0
- data/lib/alf/doc/to_html.rb +47 -0
- data/lib/alf/doc/to_markdown.rb +28 -0
- data/lib/alf/doc/version.rb +16 -0
- data/lib/alf/doc/viewpoint.rb +37 -0
- data/lib/alf/doc.rb +52 -0
- data/lib/alf-doc.rb +1 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/test_doc.rb +32 -0
- data/spec/test_examples.rb +14 -0
- data/spec/test_to_html.rb +30 -0
- data/spec/test_to_markdown.rb +30 -0
- data/tasks/doc.rake +2 -0
- data/tasks/gem.rake +8 -0
- data/tasks/html.rake +39 -0
- data/tasks/man.rake +23 -0
- data/tasks/test.rake +6 -0
- data/tasks/txt.rake +21 -0
- metadata +188 -0
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            source 'http://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            group :runtime do
         | 
| 4 | 
            +
              gem "alf-core", path: "../alf-core"
         | 
| 5 | 
            +
            end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            group :development do
         | 
| 8 | 
            +
              gem "wlang", "~> 2.1"
         | 
| 9 | 
            +
              gem "redcarpet", "~> 3.0"
         | 
| 10 | 
            +
              gem "albino", "~> 1.3"
         | 
| 11 | 
            +
              gem "md2man", "~> 2.0"
         | 
| 12 | 
            +
              gem "rake", "~> 10.0"
         | 
| 13 | 
            +
              gem "rspec", "~> 2.12"
         | 
| 14 | 
            +
            end
         | 
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,59 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: ../alf-core
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                alf-core (0.15.0)
         | 
| 5 | 
            +
                  domain (~> 1.0)
         | 
| 6 | 
            +
                  myrrha (~> 3.0)
         | 
| 7 | 
            +
                  path (~> 1.3)
         | 
| 8 | 
            +
                  sexpr (~> 0.6.0)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            GEM
         | 
| 11 | 
            +
              remote: http://rubygems.org/
         | 
| 12 | 
            +
              specs:
         | 
| 13 | 
            +
                albino (1.3.3)
         | 
| 14 | 
            +
                  posix-spawn (>= 0.3.6)
         | 
| 15 | 
            +
                backports (2.8.2)
         | 
| 16 | 
            +
                binman (3.3.2)
         | 
| 17 | 
            +
                  opener (>= 0.1.0, < 1)
         | 
| 18 | 
            +
                citrus (2.4.1)
         | 
| 19 | 
            +
                diff-lcs (1.2.4)
         | 
| 20 | 
            +
                domain (1.0.0)
         | 
| 21 | 
            +
                md2man (2.0.2)
         | 
| 22 | 
            +
                  binman (~> 3.0)
         | 
| 23 | 
            +
                  redcarpet (~> 3.0)
         | 
| 24 | 
            +
                myrrha (3.0.0)
         | 
| 25 | 
            +
                  domain (~> 1.0)
         | 
| 26 | 
            +
                opener (0.1.0)
         | 
| 27 | 
            +
                path (1.3.3)
         | 
| 28 | 
            +
                posix-spawn (0.3.6)
         | 
| 29 | 
            +
                quickl (0.4.3)
         | 
| 30 | 
            +
                rake (10.1.0)
         | 
| 31 | 
            +
                redcarpet (3.0.0)
         | 
| 32 | 
            +
                rspec (2.14.1)
         | 
| 33 | 
            +
                  rspec-core (~> 2.14.0)
         | 
| 34 | 
            +
                  rspec-expectations (~> 2.14.0)
         | 
| 35 | 
            +
                  rspec-mocks (~> 2.14.0)
         | 
| 36 | 
            +
                rspec-core (2.14.7)
         | 
| 37 | 
            +
                rspec-expectations (2.14.3)
         | 
| 38 | 
            +
                  diff-lcs (>= 1.1.3, < 2.0)
         | 
| 39 | 
            +
                rspec-mocks (2.14.4)
         | 
| 40 | 
            +
                sexpr (0.6.0)
         | 
| 41 | 
            +
                temple (0.6.7)
         | 
| 42 | 
            +
                wlang (2.2.3)
         | 
| 43 | 
            +
                  backports (~> 2.6)
         | 
| 44 | 
            +
                  citrus (~> 2.4.1)
         | 
| 45 | 
            +
                  path (~> 1.3)
         | 
| 46 | 
            +
                  quickl (~> 0.4.3)
         | 
| 47 | 
            +
                  temple (~> 0.6)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            PLATFORMS
         | 
| 50 | 
            +
              ruby
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            DEPENDENCIES
         | 
| 53 | 
            +
              albino (~> 1.3)
         | 
| 54 | 
            +
              alf-core!
         | 
| 55 | 
            +
              md2man (~> 2.0)
         | 
| 56 | 
            +
              rake (~> 10.0)
         | 
| 57 | 
            +
              redcarpet (~> 3.0)
         | 
| 58 | 
            +
              rspec (~> 2.12)
         | 
| 59 | 
            +
              wlang (~> 2.1)
         | 
    
        data/LICENCE.md
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            # The MIT Licence
         | 
| 2 | 
            +
             | 
| 3 | 
            +
                Copyright (c) 2013 - Bernard Lambeau
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
                a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
                "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
                without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
                distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
                permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
                the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
                included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
                EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
                MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
                NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
                LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
                OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
                WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/Manifest.txt
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            # Alf::Doc
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            [](http://travis-ci.org/blambeau/alf-doc)
         | 
| 4 | 
            +
            [](https://gemnasium.com/blambeau/alf-doc)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Documentation of Alf relational algebra
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## Links
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            http://github.com/blambeau/alf
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            $:.unshift(File.expand_path('../lib', __FILE__))
         | 
| 2 | 
            +
            require 'alf-doc'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # Install all tasks found in tasks folder
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            # See .rake files there for complete documentation.
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            Dir["tasks/*.rake"].each do |taskfile|
         | 
| 10 | 
            +
              load taskfile
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            # We run tests by default
         | 
| 14 | 
            +
            task :default => :test
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "alf-core"
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            require 'wlang'
         | 
| 2 | 
            +
            require 'albino'
         | 
| 3 | 
            +
            require 'redcarpet'
         | 
| 4 | 
            +
            require 'base64'
         | 
| 5 | 
            +
            require_relative 'to_markdown'
         | 
| 6 | 
            +
            module Alf
         | 
| 7 | 
            +
              module Doc
         | 
| 8 | 
            +
                class ToHtml
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  class HTMLwithAlbino < Redcarpet::Render::HTML
         | 
| 11 | 
            +
                    def block_code(code, language)
         | 
| 12 | 
            +
                      Albino.colorize(code, language || :ruby)
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def operator(op)
         | 
| 17 | 
            +
                    to_html(ToMarkdown.new.operator(op))
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def aggregator(op)
         | 
| 21 | 
            +
                    to_html(ToMarkdown.new.aggregator(op))
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def predicate(op)
         | 
| 25 | 
            +
                    to_html(ToMarkdown.new.predicate(op))
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def page(md)
         | 
| 29 | 
            +
                    to_html(md)
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def to_html(src)
         | 
| 33 | 
            +
                    src = src.gsub(/([ ]*)```try\n(.*?)\n([ ]*)```/m){|m|
         | 
| 34 | 
            +
                      spacing = $1 || ""
         | 
| 35 | 
            +
                      source  = $2.strip.gsub(/^#{spacing}/, "")
         | 
| 36 | 
            +
                      quoted  = Base64.encode64(source)
         | 
| 37 | 
            +
                      source  = "```\n#{source}\n```"
         | 
| 38 | 
            +
                      source  = source.gsub(/^/, spacing)
         | 
| 39 | 
            +
                      %Q{#{source}\n<div class="try-this"><a href="/?src=#{quoted}" target="_blank">Try it!</a></div>}
         | 
| 40 | 
            +
                    }
         | 
| 41 | 
            +
                    options = {:fenced_code_blocks => true}
         | 
| 42 | 
            +
                    Redcarpet::Markdown.new(HTMLwithAlbino, options).render(src)
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                end # class ToHtml
         | 
| 46 | 
            +
              end # module Doc
         | 
| 47 | 
            +
            end # module Alf
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require 'wlang'
         | 
| 2 | 
            +
            module Alf
         | 
| 3 | 
            +
              module Doc
         | 
| 4 | 
            +
                class ToMarkdown
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  TEMPLATES = Path.backfind('doc/templates')
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def operator(op)
         | 
| 9 | 
            +
                    to_markdown(TEMPLATES/"operator.wlang", op)
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def aggregator(op)
         | 
| 13 | 
            +
                    to_markdown(TEMPLATES/"aggregator.wlang", op)
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def predicate(op)
         | 
| 17 | 
            +
                    to_markdown(TEMPLATES/"predicate.wlang", op)
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                private
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def to_markdown(tpl, context)
         | 
| 23 | 
            +
                    WLang::Html.render(tpl, context)
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                end # class ToMarkdown
         | 
| 27 | 
            +
              end # module Doc
         | 
| 28 | 
            +
            end # module Alf
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            module Alf
         | 
| 2 | 
            +
              module Doc
         | 
| 3 | 
            +
                module Viewpoint
         | 
| 4 | 
            +
                  include Alf::Viewpoint
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def aggregators
         | 
| 7 | 
            +
                    @aggregators ||= load_file("aggregators")
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def operators
         | 
| 11 | 
            +
                    @operators ||= load_file("operators")
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def predicates
         | 
| 15 | 
            +
                    @predicates ||= load_file("predicates")
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def examples
         | 
| 19 | 
            +
                    @examples ||= begin
         | 
| 20 | 
            +
                      ex = (Doc::ROOT/'examples').glob("*.alf").map do |file|
         | 
| 21 | 
            +
                        { source: file.read }
         | 
| 22 | 
            +
                      end
         | 
| 23 | 
            +
                      Relation(ex)
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                private
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def load_file(who)
         | 
| 30 | 
            +
                    folder = Doc::DOC_ROOT/who
         | 
| 31 | 
            +
                    tuples = folder.glob('*.yml').map(&:load)
         | 
| 32 | 
            +
                    Relation(tuples)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                end # class Viewpoint
         | 
| 36 | 
            +
              end # module Doc
         | 
| 37 | 
            +
            end # module Alf
         | 
    
        data/lib/alf/doc.rb
    ADDED
    
    | @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            require_relative 'doc/version'
         | 
| 2 | 
            +
            require_relative 'doc/loader'
         | 
| 3 | 
            +
            require_relative 'doc/viewpoint'
         | 
| 4 | 
            +
            module Alf
         | 
| 5 | 
            +
              module Doc
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                ROOT = Path.dir.parent.parent
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                DOC_ROOT = ROOT/"doc"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                DB = Alf.connect(Path.dir, viewpoint: Viewpoint[])
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def self.query(*args, &bl)
         | 
| 14 | 
            +
                  DB.query(*args, &bl)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def self.all
         | 
| 18 | 
            +
                  query{
         | 
| 19 | 
            +
                    extend(Relation::DEE,
         | 
| 20 | 
            +
                      predicates: predicates,
         | 
| 21 | 
            +
                      operators: operators,
         | 
| 22 | 
            +
                      aggregators: aggregators,
         | 
| 23 | 
            +
                      examples: examples)
         | 
| 24 | 
            +
                  }
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def self.examples
         | 
| 28 | 
            +
                  query{ examples }
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def self.pages
         | 
| 32 | 
            +
                  (DOC_ROOT/'pages').glob("*.md")
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def self.commands
         | 
| 36 | 
            +
                  (DOC_ROOT/'commands').glob("*.md")
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def self.blog
         | 
| 40 | 
            +
                  (DOC_ROOT/'blog').glob("*.md")
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def self.each_api
         | 
| 44 | 
            +
                  [:operators, :predicates, :aggregators].each do |kind|
         | 
| 45 | 
            +
                    Alf::Doc.query(kind).each do |obj|
         | 
| 46 | 
            +
                      yield(kind.to_s[0...-1].to_sym, obj.name, obj)
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              end # module Doc
         | 
| 52 | 
            +
            end # module Alf
         | 
    
        data/lib/alf-doc.rb
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require_relative "alf/doc"
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
         | 
| 2 | 
            +
            require 'alf-doc'
         | 
| 3 | 
            +
            require "rspec"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Helpers
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec.configure do |c|
         | 
| 10 | 
            +
              c.include Helpers
         | 
| 11 | 
            +
              c.extend  Helpers
         | 
| 12 | 
            +
              c.filter_run_excluding :ruby19 => (RUBY_VERSION < "1.9")
         | 
| 13 | 
            +
            end
         | 
    
        data/spec/test_doc.rb
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            module Alf
         | 
| 3 | 
            +
              describe Doc do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                it "should have a version number" do
         | 
| 6 | 
            +
                  Doc.const_defined?(:VERSION).should be_true
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                it 'has valid .yml files' do
         | 
| 10 | 
            +
                  Doc.all.should be_a(Relation)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                it 'has valid predicates' do
         | 
| 14 | 
            +
                  predicates = Doc.query(:predicates)
         | 
| 15 | 
            +
                  predicates.should be_a(Relation)
         | 
| 16 | 
            +
                  predicates.should_not be_empty
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it 'has valid operators' do
         | 
| 20 | 
            +
                  operators = Doc.query(:operators)
         | 
| 21 | 
            +
                  operators.should be_a(Relation)
         | 
| 22 | 
            +
                  operators.should_not be_empty
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                it 'has valid aggregators' do
         | 
| 26 | 
            +
                  aggregators = Doc.query(:aggregators)
         | 
| 27 | 
            +
                  aggregators.should be_a(Relation)
         | 
| 28 | 
            +
                  aggregators.should_not be_empty
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            module Alf
         | 
| 3 | 
            +
              describe "The examples" do
         | 
| 4 | 
            +
                Alf::Doc.examples.each do |ex|
         | 
| 5 | 
            +
                  describe ex.source do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                    it 'runs without any problem on the examples database' do
         | 
| 8 | 
            +
                      Alf.examples.query(ex.source).should be_a(Relation)
         | 
| 9 | 
            +
                    end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'alf/doc/to_html'
         | 
| 3 | 
            +
            module Alf
         | 
| 4 | 
            +
              module Doc
         | 
| 5 | 
            +
                describe ToHtml do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  it 'works on an operator' do
         | 
| 8 | 
            +
                    op = Doc.query{ restrict(operators, name: "project") }.tuple_extract
         | 
| 9 | 
            +
                    lambda{
         | 
| 10 | 
            +
                      ToHtml.new.operator(op)
         | 
| 11 | 
            +
                    }.should_not raise_error
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  it 'works on a predicate' do
         | 
| 15 | 
            +
                    op = Doc.query{ restrict(predicates, name: "eq") }.tuple_extract
         | 
| 16 | 
            +
                    lambda{
         | 
| 17 | 
            +
                      ToHtml.new.predicate(op)
         | 
| 18 | 
            +
                    }.should_not raise_error
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  it 'works on a aggregator' do
         | 
| 22 | 
            +
                    op = Doc.query{ restrict(aggregators, name: "sum") }.tuple_extract
         | 
| 23 | 
            +
                    lambda{
         | 
| 24 | 
            +
                      ToHtml.new.aggregator(op)
         | 
| 25 | 
            +
                    }.should_not raise_error
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
            end
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'alf/doc/to_markdown'
         | 
| 3 | 
            +
            module Alf
         | 
| 4 | 
            +
              module Doc
         | 
| 5 | 
            +
                describe ToMarkdown do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  it 'works on an operator' do
         | 
| 8 | 
            +
                    op = Doc.query{ restrict(operators, name: "project") }.tuple_extract
         | 
| 9 | 
            +
                    lambda{
         | 
| 10 | 
            +
                      ToMarkdown.new.operator(op)
         | 
| 11 | 
            +
                    }.should_not raise_error
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  it 'works on a predicate' do
         | 
| 15 | 
            +
                    op = Doc.query{ restrict(predicates, name: "eq") }.tuple_extract
         | 
| 16 | 
            +
                    lambda{
         | 
| 17 | 
            +
                      ToMarkdown.new.predicate(op)
         | 
| 18 | 
            +
                    }.should_not raise_error
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  it 'works on a aggregator' do
         | 
| 22 | 
            +
                    op = Doc.query{ restrict(aggregators, name: "sum") }.tuple_extract
         | 
| 23 | 
            +
                    lambda{
         | 
| 24 | 
            +
                      ToMarkdown.new.aggregator(op)
         | 
| 25 | 
            +
                    }.should_not raise_error
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
            end
         | 
    
        data/tasks/doc.rake
    ADDED
    
    
    
        data/tasks/gem.rake
    ADDED
    
    | @@ -0,0 +1,8 @@ | |
| 1 | 
            +
            require 'rubygems/package_task'
         | 
| 2 | 
            +
            gemspec_file = File.expand_path('../../alf-doc.gemspec', __FILE__)
         | 
| 3 | 
            +
            gemspec      = Kernel.eval(File.read(gemspec_file))
         | 
| 4 | 
            +
            Gem::PackageTask.new(gemspec) do |t|
         | 
| 5 | 
            +
              t.name = gemspec.name
         | 
| 6 | 
            +
              t.version = gemspec.version
         | 
| 7 | 
            +
              t.package_files = gemspec.files
         | 
| 8 | 
            +
            end
         | 
    
        data/tasks/html.rake
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            namespace :html do
         | 
| 2 | 
            +
              require "alf/doc/to_html"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              ROOT = Path.dir.parent
         | 
| 5 | 
            +
              HTML = ROOT/'compiled/html'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              desc "Generates all API in html"
         | 
| 8 | 
            +
              task :api do
         | 
| 9 | 
            +
                # API
         | 
| 10 | 
            +
                (HTML/'api').mkdir_p
         | 
| 11 | 
            +
                Alf::Doc.each_api do |kind, name, obj|
         | 
| 12 | 
            +
                  target = HTML/"api/#{name}.html"
         | 
| 13 | 
            +
                  puts "#{name} -> #{target}"
         | 
| 14 | 
            +
                  target.write Alf::Doc::ToHtml.new.send(kind, obj)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              desc "Generates pages in HTML"
         | 
| 19 | 
            +
              task :pages do
         | 
| 20 | 
            +
                (HTML/'pages').mkdir_p
         | 
| 21 | 
            +
                Alf::Doc.pages.each do |page|
         | 
| 22 | 
            +
                  target = HTML/"pages/#{page.rm_ext.basename}.html"
         | 
| 23 | 
            +
                  puts "#{page} -> #{target}"
         | 
| 24 | 
            +
                  target.write(Alf::Doc::ToHtml.new.page(page.read))
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              desc "Generates blog in HTML"
         | 
| 29 | 
            +
              task :blog do
         | 
| 30 | 
            +
                (HTML/'blog').mkdir_p
         | 
| 31 | 
            +
                Alf::Doc.blog.each do |page|
         | 
| 32 | 
            +
                  target = HTML/"blog/#{page.rm_ext.basename}.html"
         | 
| 33 | 
            +
                  puts "#{page} -> #{target}"
         | 
| 34 | 
            +
                  target.write(Alf::Doc::ToHtml.new.page(page.read))
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
            desc "Generates all HTML pages"
         | 
| 39 | 
            +
            task :html => [:"html:api", :"html:pages", :"html:blog"]
         | 
    
        data/tasks/man.rake
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            desc "Generate man pages"
         | 
| 2 | 
            +
            task :man do
         | 
| 3 | 
            +
              MAN = Path.dir.parent/'compiled/man'
         | 
| 4 | 
            +
              MAN.mkdir_p
         | 
| 5 | 
            +
              require 'alf/doc/to_markdown'
         | 
| 6 | 
            +
              require 'md2man'
         | 
| 7 | 
            +
              require 'md2man/roff/engine'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              # API
         | 
| 10 | 
            +
              Alf::Doc.each_api do |kind, name, obj|
         | 
| 11 | 
            +
                target = MAN/"#{name}.man"
         | 
| 12 | 
            +
                puts "#{name} -> #{target}"
         | 
| 13 | 
            +
                md = Alf::Doc::ToMarkdown.new.send(kind, obj)
         | 
| 14 | 
            +
                target.write(Md2Man::Roff::ENGINE.render(md))
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              # COMMANDS
         | 
| 18 | 
            +
              Alf::Doc.commands.each do |md|
         | 
| 19 | 
            +
                target = MAN/"#{md.basename.rm_ext}.man"
         | 
| 20 | 
            +
                puts "#{md} -> #{target}"
         | 
| 21 | 
            +
                target.write(Md2Man::Roff::ENGINE.render(md.read))
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        data/tasks/test.rake
    ADDED
    
    
    
        data/tasks/txt.rake
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            desc "Generate .txt pages"
         | 
| 2 | 
            +
            task :txt do
         | 
| 3 | 
            +
              TXT = Path.dir.parent/'compiled/txt'
         | 
| 4 | 
            +
              TXT.mkdir_p
         | 
| 5 | 
            +
              require 'alf/doc/to_markdown'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              # API
         | 
| 8 | 
            +
              Alf::Doc.each_api do |kind, name, obj|
         | 
| 9 | 
            +
                target = TXT/"#{name}.txt"
         | 
| 10 | 
            +
                puts "#{name} -> #{target}"
         | 
| 11 | 
            +
                md = Alf::Doc::ToMarkdown.new.send(kind, obj)
         | 
| 12 | 
            +
                target.write(md.gsub(/^```(try)?\n/, ""))
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              # COMMANDS
         | 
| 16 | 
            +
              Alf::Doc.commands.each do |md|
         | 
| 17 | 
            +
                target = TXT/"#{md.basename.rm_ext}.man"
         | 
| 18 | 
            +
                puts "#{md} -> #{target}"
         | 
| 19 | 
            +
                target.write(md.read)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,188 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: alf-doc
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.15.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Bernard Lambeau
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-10-31 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: wlang
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '2.1'
         | 
| 22 | 
            +
              type: :development
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '2.1'
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: redcarpet
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ~>
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: '3.0'
         | 
| 38 | 
            +
              type: :development
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ~>
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '3.0'
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: albino
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ~>
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '1.3'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ~>
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '1.3'
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: md2man
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ~>
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '2.0'
         | 
| 70 | 
            +
              type: :development
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ~>
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '2.0'
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: rake
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ~>
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '10.0'
         | 
| 86 | 
            +
              type: :development
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '10.0'
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              name: rspec
         | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                none: false
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - ~>
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: '2.12'
         | 
| 102 | 
            +
              type: :development
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - ~>
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '2.12'
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              name: alf-core
         | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                none: false
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ~>
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: 0.15.0
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                none: false
         | 
| 122 | 
            +
                requirements:
         | 
| 123 | 
            +
                - - ~>
         | 
| 124 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                    version: 0.15.0
         | 
| 126 | 
            +
            description: This gem provides support for using the formal documentation of Alf.
         | 
| 127 | 
            +
            email:
         | 
| 128 | 
            +
            - blambeau at gmail.com
         | 
| 129 | 
            +
            executables: []
         | 
| 130 | 
            +
            extensions: []
         | 
| 131 | 
            +
            extra_rdoc_files: []
         | 
| 132 | 
            +
            files:
         | 
| 133 | 
            +
            - CHANGELOG.md
         | 
| 134 | 
            +
            - Gemfile
         | 
| 135 | 
            +
            - Gemfile.lock
         | 
| 136 | 
            +
            - lib/alf/doc/loader.rb
         | 
| 137 | 
            +
            - lib/alf/doc/to_html.rb
         | 
| 138 | 
            +
            - lib/alf/doc/to_markdown.rb
         | 
| 139 | 
            +
            - lib/alf/doc/version.rb
         | 
| 140 | 
            +
            - lib/alf/doc/viewpoint.rb
         | 
| 141 | 
            +
            - lib/alf/doc.rb
         | 
| 142 | 
            +
            - lib/alf-doc.rb
         | 
| 143 | 
            +
            - LICENCE.md
         | 
| 144 | 
            +
            - Manifest.txt
         | 
| 145 | 
            +
            - Rakefile
         | 
| 146 | 
            +
            - README.md
         | 
| 147 | 
            +
            - spec/spec_helper.rb
         | 
| 148 | 
            +
            - spec/test_doc.rb
         | 
| 149 | 
            +
            - spec/test_examples.rb
         | 
| 150 | 
            +
            - spec/test_to_html.rb
         | 
| 151 | 
            +
            - spec/test_to_markdown.rb
         | 
| 152 | 
            +
            - tasks/doc.rake
         | 
| 153 | 
            +
            - tasks/gem.rake
         | 
| 154 | 
            +
            - tasks/html.rake
         | 
| 155 | 
            +
            - tasks/man.rake
         | 
| 156 | 
            +
            - tasks/test.rake
         | 
| 157 | 
            +
            - tasks/txt.rake
         | 
| 158 | 
            +
            homepage: http://github.com/blambeau/alf
         | 
| 159 | 
            +
            licenses: []
         | 
| 160 | 
            +
            post_install_message: 
         | 
| 161 | 
            +
            rdoc_options: []
         | 
| 162 | 
            +
            require_paths:
         | 
| 163 | 
            +
            - lib
         | 
| 164 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 165 | 
            +
              none: false
         | 
| 166 | 
            +
              requirements:
         | 
| 167 | 
            +
              - - ! '>='
         | 
| 168 | 
            +
                - !ruby/object:Gem::Version
         | 
| 169 | 
            +
                  version: '0'
         | 
| 170 | 
            +
                  segments:
         | 
| 171 | 
            +
                  - 0
         | 
| 172 | 
            +
                  hash: -2651068538456684489
         | 
| 173 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 174 | 
            +
              none: false
         | 
| 175 | 
            +
              requirements:
         | 
| 176 | 
            +
              - - ! '>='
         | 
| 177 | 
            +
                - !ruby/object:Gem::Version
         | 
| 178 | 
            +
                  version: '0'
         | 
| 179 | 
            +
                  segments:
         | 
| 180 | 
            +
                  - 0
         | 
| 181 | 
            +
                  hash: -2651068538456684489
         | 
| 182 | 
            +
            requirements: []
         | 
| 183 | 
            +
            rubyforge_project: 
         | 
| 184 | 
            +
            rubygems_version: 1.8.25
         | 
| 185 | 
            +
            signing_key: 
         | 
| 186 | 
            +
            specification_version: 3
         | 
| 187 | 
            +
            summary: Documentation of Alf relational algebra
         | 
| 188 | 
            +
            test_files: []
         |