├── hybook
├── NOTES.md
├── HISTORY.md
├── test
│ ├── helper.rb
│ └── test_basics.rb
├── .gitignore
├── lib
│ ├── hybook
│ │ ├── builder
│ │ │ ├── album.rb
│ │ │ └── book.rb
│ │ ├── writer
│ │ │ └── jekyll.rb
│ │ ├── type
│ │ │ ├── picture.rb
│ │ │ ├── section.rb
│ │ │ └── album.rb
│ │ ├── helpers
│ │ │ ├── misc.rb
│ │ │ └── markdown.rb
│ │ ├── version.rb
│ │ └── std
│ │ │ └── album.rb
│ └── hybook.rb
├── templates
│ └── album.md
├── Manifest.txt
├── Rakefile
├── ALTERNATIVES.md
└── README.md
├── about
├── lib
│ ├── about
│ │ ├── views
│ │ │ ├── rack.erb
│ │ │ ├── sinatra.erb
│ │ │ ├── env.erb
│ │ │ ├── rails.erb
│ │ │ ├── shared
│ │ │ │ ├── _version.erb
│ │ │ │ └── _debug.erb
│ │ │ ├── debug.erb
│ │ │ ├── ruby.erb
│ │ │ └── layout.erb
│ │ ├── version.rb
│ │ ├── public
│ │ │ └── style.css
│ │ └── server.rb
│ └── about.rb
├── History.md
├── config.ru
├── .gitignore
├── Manifest.txt
├── README.md
└── Rakefile
├── bookfile
├── HISTORY.md
├── test
│ ├── helper.rb
│ ├── test_basics.rb
│ ├── test_beer.rb
│ ├── test_football.rb
│ ├── test_world_templates.rb
│ ├── test_world.rb
│ └── bookfile
│ │ ├── world.rb
│ │ ├── football.rb
│ │ └── beer.rb
├── .gitignore
├── lib
│ ├── bookfile
│ │ ├── book
│ │ │ ├── config.rb
│ │ │ └── book.rb
│ │ ├── version.rb
│ │ ├── builder.rb
│ │ ├── bookfile.rb
│ │ ├── database
│ │ │ └── database.rb
│ │ └── package
│ │ │ └── package.rb
│ └── bookfile.rb
├── Manifest.txt
├── README.md
├── Rakefile
└── attic
│ ├── football.rb
│ └── beer.rb
├── catalogdb
├── HISTORY.md
├── .gitignore
├── test
│ ├── helper.rb
│ ├── test_version.rb
│ └── test_reader.rb
├── Manifest.txt
├── lib
│ ├── catalogdb
│ │ ├── version.rb
│ │ └── reader.rb
│ └── catalogdb.rb
├── README.md
└── Rakefile
├── fizzbuzzer
├── HISTORY.md
├── test
│ ├── helper.rb
│ ├── test_version.rb
│ ├── test_driven.rb
│ └── test_fizzbuzz.rb
├── Manifest.txt
├── bin
│ └── fizzbuzz
├── lib
│ └── fizzbuzzer
│ │ └── version.rb
├── .gitignore
├── Rakefile
└── NOTES.md
├── fotos
├── HISTORY.md
├── Manifest.txt
├── test
│ ├── helper.rb
│ └── test_builder.rb
├── lib
│ ├── fotos.rb
│ └── fotos
│ │ ├── version.rb
│ │ ├── reports
│ │ └── stats.rb
│ │ └── builder.rb
├── README.md
├── Rakefile
└── .gitignore
├── gutenberg
├── HISTORY.md
├── Manifest.txt
├── lib
│ ├── gutenberg.rb
│ └── gutenberg
│ │ └── version.rb
├── .gitignore
├── Rakefile
└── README.md
├── ostructer
├── History.rdoc
├── Manifest.txt
├── .gitignore
├── README.rdoc
├── test
│ ├── customer.json
│ ├── config.xml
│ ├── customer.xml
│ ├── config.json
│ ├── test_customer_json.rb
│ ├── test_misc.rb
│ ├── test_mapper.rb
│ ├── test_status_xml.rb
│ ├── test_customer_xml.rb
│ ├── test_config_json.rb
│ └── test_config_xml.rb
└── Rakefile
├── preproc
├── HISTORY.md
├── Manifest.txt
├── .gitignore
├── test
│ ├── helper.rb
│ └── test_incl.rb
├── lib
│ ├── preproc
│ │ └── version.rb
│ └── preproc.rb
├── README.md
└── Rakefile
├── record
├── HISTORY.md
├── .gitignore
├── Manifest.txt
├── test
│ ├── helper.rb
│ ├── test_version.rb
│ └── test_record.rb
├── lib
│ ├── record.rb
│ └── record
│ │ ├── version.rb
│ │ ├── builder.rb
│ │ ├── field.rb
│ │ └── base.rb
├── Rakefile
└── README.md
├── rubycat
├── .gitignore
├── HISTORY.md
├── test
│ ├── helper.rb
│ ├── test_version.rb
│ ├── test_reader.rb
│ └── test_rubygems.rb
├── Manifest.txt
├── lib
│ ├── rubycat.rb
│ └── rubycat
│ │ ├── version.rb
│ │ ├── service
│ │ └── rubygems.rb
│ │ ├── catalog.rb
│ │ └── card.rb
├── Rakefile
└── README.md
├── typeconv
├── HISTORY.md
├── Manifest.txt
├── lib
│ ├── typeconv.rb
│ └── typeconv
│ │ └── version.rb
├── .gitignore
├── Rakefile
└── README.md
├── almost-sinatra
├── HISTORY.md
├── Manifest.txt
├── samples
│ └── hello.rb
├── .gitignore
├── Rakefile
├── up
│ └── almost_sinatra.rb
└── lib
│ └── almost-sinatra.rb
├── bookman
├── HISTORY.md
├── test
│ ├── helper.rb
│ └── test_basics.rb
├── Manifest.txt
├── .gitignore
├── lib
│ ├── bookman
│ │ ├── version.rb
│ │ ├── config.rb
│ │ ├── beer.rb
│ │ ├── world.rb
│ │ ├── football.rb
│ │ └── bookman.rb
│ └── bookman.rb
├── README.md
└── Rakefile
├── officetxt
├── HISTORY.md
├── bin
│ ├── txt
│ └── officetxt
├── test
│ ├── helper.rb
│ └── test_version.rb
├── Manifest.txt
├── lib
│ ├── officetxt
│ │ └── version.rb
│ └── officetxt.rb
├── .gitignore
└── Rakefile
└── README.md
/hybook/NOTES.md:
--------------------------------------------------------------------------------
1 | # Quick Notes
2 |
3 |
4 |
--------------------------------------------------------------------------------
/about/lib/about/views/rack.erb:
--------------------------------------------------------------------------------
1 |
2 |
Rack
3 |
4 | to be done
5 |
6 |
--------------------------------------------------------------------------------
/about/lib/about/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module About
3 | VERSION = '0.1.0'
4 | end
5 |
--------------------------------------------------------------------------------
/about/History.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2013-10-12
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/about/lib/about/views/sinatra.erb:
--------------------------------------------------------------------------------
1 |
2 | Sinatra
3 |
4 | to be done
5 |
6 |
--------------------------------------------------------------------------------
/bookfile/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-03-03
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/catalogdb/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-06-29
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/fizzbuzzer/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2018-01-22
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/fotos/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-11-22
2 |
3 | * Everything is new. First release.
4 |
5 |
--------------------------------------------------------------------------------
/gutenberg/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2016-03-17
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/hybook/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2014-02-16
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/ostructer/History.rdoc:
--------------------------------------------------------------------------------
1 | === 0.1 / 2011-09-11
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/preproc/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-01-09
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/record/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2018-08-15
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/rubycat/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore ruby rake generated folders
2 |
3 | pkg/
4 | doc/
5 |
6 |
7 |
--------------------------------------------------------------------------------
/rubycat/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-06-30
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/typeconv/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2018-10-18
2 |
3 | * Everything is new. First release
4 |
--------------------------------------------------------------------------------
/almost-sinatra/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 1.0.0 / 2017-12-05
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/bookman/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2015-04-02
2 |
3 | * Everything is new. First release.
4 |
5 |
--------------------------------------------------------------------------------
/catalogdb/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore ruby rake generated folders
2 |
3 | pkg/
4 | doc/
5 |
6 |
7 |
--------------------------------------------------------------------------------
/officetxt/HISTORY.md:
--------------------------------------------------------------------------------
1 | ### 0.0.1 / 2017-07-23
2 |
3 | * Everything is new. First release.
4 |
--------------------------------------------------------------------------------
/officetxt/bin/txt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'officetxt'
4 |
5 | Officetxt.about
6 |
--------------------------------------------------------------------------------
/officetxt/bin/officetxt:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'officetxt'
4 |
5 | Officetxt.about
6 |
--------------------------------------------------------------------------------
/ostructer/Manifest.txt:
--------------------------------------------------------------------------------
1 | History.rdoc
2 | Manifest.txt
3 | README.rdoc
4 | Rakefile
5 | lib/ostructer.rb
6 |
--------------------------------------------------------------------------------
/fotos/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/fotos.rb
6 | lib/fotos/version.rb
7 |
--------------------------------------------------------------------------------
/almost-sinatra/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | LICENSE.md
3 | Manifest.txt
4 | README.md
5 | Rakefile
6 | lib/almost-sinatra.rb
7 |
--------------------------------------------------------------------------------
/preproc/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/preproc.rb
6 | lib/preproc/version.rb
7 |
--------------------------------------------------------------------------------
/typeconv/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/typeconv.rb
6 | lib/typeconv/version.rb
7 |
--------------------------------------------------------------------------------
/gutenberg/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/gutenberg.rb
6 | lib/gutenberg/version.rb
7 |
--------------------------------------------------------------------------------
/preproc/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore generated folders
2 | pkg/
3 | doc/
4 |
5 | # ignore jekyll generated output
6 | site/_site/
7 |
8 |
--------------------------------------------------------------------------------
/ostructer/.gitignore:
--------------------------------------------------------------------------------
1 | # ignore komodo project files
2 | *.kpf
3 | *.komodoproject
4 |
5 | # ignore generated folders
6 | pkg/
7 | doc/
8 |
--------------------------------------------------------------------------------
/catalogdb/test/helper.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ## minitest setup
5 | require 'minitest/autorun'
6 |
7 | ## our own code
8 | require 'catalogdb'
9 |
10 |
--------------------------------------------------------------------------------
/rubycat/test/helper.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ## minitest setup
5 | require 'minitest/autorun'
6 |
7 | ## our own code
8 | require 'rubycat'
9 |
10 |
--------------------------------------------------------------------------------
/about/lib/about/views/env.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Environment
4 |
5 |
6 | <% ENV.each do |key,value| %>
7 | <%= key %> = <%= value %>
8 | <% end %>
9 |
10 |
--------------------------------------------------------------------------------
/bookfile/test/helper.rb:
--------------------------------------------------------------------------------
1 | #encoding: utf-8
2 |
3 | ## minitest setup
4 | require 'minitest/autorun'
5 |
6 |
7 | ## our own code
8 | require 'bookfile'
9 |
10 |
--------------------------------------------------------------------------------
/about/config.ru:
--------------------------------------------------------------------------------
1 |
2 | ### note: for local testing - add to load path pluto.admin/lib
3 |
4 | $LOAD_PATH << './lib'
5 |
6 | require 'about'
7 |
8 |
9 | run About::Server
10 |
--------------------------------------------------------------------------------
/fizzbuzzer/test/helper.rb:
--------------------------------------------------------------------------------
1 | ## $:.unshift(File.dirname(__FILE__))
2 |
3 | ## minitest setup
4 |
5 | require 'minitest/autorun'
6 |
7 |
8 | ## our own code
9 |
10 | require 'fizzbuzzer'
11 |
--------------------------------------------------------------------------------
/fotos/test/helper.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ## minitest setup
4 | require 'minitest/autorun'
5 |
6 |
7 | $RUBYLIBS_DEBUG = true
8 |
9 | ## our own code
10 | require 'fotos'
11 |
12 |
--------------------------------------------------------------------------------
/hybook/test/helper.rb:
--------------------------------------------------------------------------------
1 | ## $:.unshift(File.dirname(__FILE__))
2 |
3 | ## minitest setup
4 |
5 | require 'minitest/autorun'
6 |
7 |
8 | ### our own code
9 | require 'hybook'
10 |
11 |
--------------------------------------------------------------------------------
/bookman/test/helper.rb:
--------------------------------------------------------------------------------
1 | #encoding: utf-8
2 |
3 | ## minitest setup
4 | require 'minitest/autorun'
5 |
6 | ## extra stdlibs
7 | require 'pp'
8 |
9 | ## our own code
10 | require 'bookman'
11 |
12 |
--------------------------------------------------------------------------------
/officetxt/test/helper.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ## minitest setup
4 | require 'minitest/autorun'
5 |
6 |
7 | $RUBYLIBS_DEBUG = true
8 |
9 | ## our own code
10 | require 'officetxt'
11 |
--------------------------------------------------------------------------------
/about/lib/about/views/rails.erb:
--------------------------------------------------------------------------------
1 |
2 | Rails
3 |
4 | to be done
5 |
6 |
--------------------------------------------------------------------------------
/officetxt/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | bin/officetxt
6 | bin/txt
7 | lib/officetxt.rb
8 | lib/officetxt/version.rb
9 | test/helper.rb
10 | test/test_version.rb
11 |
--------------------------------------------------------------------------------
/record/.gitignore:
--------------------------------------------------------------------------------
1 | #######################
2 | # ignore ruby rake generated folders
3 |
4 | /pkg/
5 | /doc/
6 |
7 |
8 | ################
9 | # ignore (top-level) datapackage folders
10 |
11 | /pack/
12 | /.pack/
13 |
--------------------------------------------------------------------------------
/typeconv/lib/typeconv.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require 'pp'
4 |
5 |
6 | ## our own code
7 | require 'typeconv/version' # note: let version always go first
8 |
9 |
10 | pp Typeconv.banner
11 | pp Typeconv.root
12 |
--------------------------------------------------------------------------------
/gutenberg/lib/gutenberg.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require 'pp'
4 |
5 |
6 | ## our own code
7 | require 'gutenberg/version' # note: let version always go first
8 |
9 |
10 | pp Gutenberg.banner
11 | pp Gutenberg.root
12 |
13 |
--------------------------------------------------------------------------------
/preproc/test/helper.rb:
--------------------------------------------------------------------------------
1 | ## $:.unshift(File.dirname(__FILE__))
2 |
3 |
4 | ## minitest setup
5 |
6 | require 'minitest/autorun'
7 |
8 |
9 | ## our own code
10 | require 'preproc'
11 |
12 |
13 | LogUtils::Logger.root.level = :debug
14 |
--------------------------------------------------------------------------------
/fizzbuzzer/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | bin/fizzbuzz
6 | lib/fizzbuzzer.rb
7 | lib/fizzbuzzer/version.rb
8 | test/helper.rb
9 | test/test_driven.rb
10 | test/test_fizzbuzz.rb
11 | test/test_version.rb
12 |
--------------------------------------------------------------------------------
/catalogdb/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/catalogdb.rb
6 | lib/catalogdb/reader.rb
7 | lib/catalogdb/version.rb
8 | test/data/RUBY.md
9 | test/helper.rb
10 | test/test_reader.rb
11 | test/test_version.rb
12 |
--------------------------------------------------------------------------------
/about/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 |
15 | # YARD artifacts
16 | .yardoc
17 | _yardoc
18 | doc/
19 |
--------------------------------------------------------------------------------
/hybook/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 |
15 | # YARD artifacts
16 | .yardoc
17 | _yardoc
18 | doc/
19 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/builder/album.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # album builder
5 |
6 |
7 | class AlbumBuilder
8 |
9 | ## move create_from_code from album here
10 | # keep types "clean" e.g. only data struture
11 |
12 | end
13 |
14 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/writer/jekyll.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # Jekyll book writer / renderer
5 |
6 | class JekyllWriter
7 |
8 | ## to be done
9 | ## see BookBuilder - split code
10 | ##
11 |
12 | end # class JekyllWriter
13 |
14 |
--------------------------------------------------------------------------------
/hybook/templates/album.md:
--------------------------------------------------------------------------------
1 |
2 | ## {{ album.title }}
3 |
4 | {% album.sections.each do |section| %}
5 |
6 | #### {{ section.title }} _({{ section.pictures.size }})_{: .count}
7 |
8 | {{ render_pictures( section.pictures, opts ) }}
9 |
10 | {% end %}
11 |
--------------------------------------------------------------------------------
/record/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | LICENSE.md
3 | Manifest.txt
4 | README.md
5 | Rakefile
6 | lib/record.rb
7 | lib/record/base.rb
8 | lib/record/builder.rb
9 | lib/record/field.rb
10 | lib/record/version.rb
11 | test/helper.rb
12 | test/test_record.rb
13 | test/test_version.rb
14 |
--------------------------------------------------------------------------------
/bookman/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/bookman.rb
6 | lib/bookman/beer.rb
7 | lib/bookman/bookman.rb
8 | lib/bookman/config.rb
9 | lib/bookman/football.rb
10 | lib/bookman/version.rb
11 | lib/bookman/world.rb
12 | test/helper.rb
13 | test/test_basics.rb
14 |
--------------------------------------------------------------------------------
/record/test/helper.rb:
--------------------------------------------------------------------------------
1 | ## $:.unshift(File.dirname(__FILE__))
2 |
3 | ## minitest setup
4 |
5 | require 'minitest/autorun'
6 |
7 |
8 | ## our own code
9 | require 'record'
10 |
11 |
12 |
13 | ## turn on "global" logging
14 | Record::Field.logger.level = :debug
15 | Record::Builder.logger.level = :debug
16 |
--------------------------------------------------------------------------------
/about/lib/about/views/shared/_version.erb:
--------------------------------------------------------------------------------
1 |
2 |
about/<%= About::VERSION %>,
3 | -
4 |
Ruby/<%= "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" %> on
5 |
Sinatra/<%= Sinatra::VERSION %> (<%= ENV['RACK_ENV'] %>)
6 |
7 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/type/picture.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Hybook
4 |
5 |
6 | class Picture
7 | attr_accessor :title
8 | attr_accessor :path
9 |
10 | def initialize( title, path )
11 | @title = title
12 | @path = path
13 | end
14 | end
15 |
16 |
17 | end # module Hybook
18 |
--------------------------------------------------------------------------------
/rubycat/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/rubycat.rb
6 | lib/rubycat/card.rb
7 | lib/rubycat/catalog.rb
8 | lib/rubycat/service/rubygems.rb
9 | lib/rubycat/version.rb
10 | test/data/RUBY.md
11 | test/helper.rb
12 | test/test_reader.rb
13 | test/test_rubygems.rb
14 | test/test_version.rb
15 |
--------------------------------------------------------------------------------
/bookfile/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 |
15 | # YARD artifacts
16 | .yardoc
17 | _yardoc
18 | doc/
19 |
20 |
21 | #####################
22 | # ignore dbs
23 |
24 | *.db
25 |
26 |
--------------------------------------------------------------------------------
/bookman/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | coverage
6 | InstalledFiles
7 | lib/bundler/man
8 | pkg
9 | rdoc
10 | spec/reports
11 | test/tmp
12 | test/version_tmp
13 | tmp
14 |
15 | # YARD artifacts
16 | .yardoc
17 | _yardoc
18 | doc/
19 |
20 |
21 | #####################
22 | # ignore dbs
23 |
24 | *.db
25 |
26 |
--------------------------------------------------------------------------------
/fizzbuzzer/bin/fizzbuzz:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | ###################
4 | # DEV TIPS:
5 | #
6 | # For local testing run like:
7 | #
8 | # ruby -Ilib bin/fizzbuzz
9 | #
10 | # Set the executable bit in Linux. Example:
11 | #
12 | # % chmod a+x bin/fizzbuzz
13 | #
14 |
15 | require 'fizzbuzzer'
16 |
17 | FizzBuzzer.main
18 |
--------------------------------------------------------------------------------
/fotos/lib/fotos.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | # 3rd party gems/libs
5 | require 'logutils'
6 |
7 | # our own code
8 | require 'fotos/version' # note: let version always go first
9 | require 'fotos/builder'
10 |
11 | require 'fotos/reports/stats'
12 |
13 |
14 | # say hello
15 | puts Fotos.banner if defined?( $RUBYLIBS_DEBUG )
16 |
--------------------------------------------------------------------------------
/about/lib/about/views/debug.erb:
--------------------------------------------------------------------------------
1 |
2 | Named Route Helpers
3 |
4 |
5 | root_path: <%= root_path %>
6 | ruby_path: <%= ruby_path %>
7 | env_path: <%= env_path %>
8 | rack_path: <%= rack_path %>
9 | sinatra_path: <%= sinatra_path %>
10 | rails_path: <%= rails_path %>
11 |
12 |
13 | <%= erb :'shared/_debug' %>
14 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/type/section.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Hybook
4 |
5 |
6 | class Section
7 | attr_accessor :title
8 | attr_accessor :pictures
9 |
10 | def initialize( title )
11 | @title = title
12 | @pictures = [] # pictures (images/logos/etec.)
13 | end
14 | end
15 |
16 |
17 | end # module Hybook
18 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/book/config.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookfile
4 |
5 |
6 | class BookConfig
7 | def initialize( hash={} )
8 | @hash = hash
9 | end
10 |
11 | def templates_dir
12 | @hash[:templates_dir]
13 | end
14 |
15 | def pages_dir
16 | @hash[:pages_dir]
17 | end
18 | end
19 |
20 |
21 | end # module Bookfile
22 |
23 |
--------------------------------------------------------------------------------
/about/lib/about.rb:
--------------------------------------------------------------------------------
1 |
2 | # 3rd party gems/libs
3 |
4 | require 'textutils'
5 |
6 |
7 | # our own code
8 |
9 | require 'about/version' # let it always go first
10 |
11 |
12 | module About
13 |
14 | def self.root
15 | "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
16 | end
17 |
18 | end # module About
19 |
20 |
21 | require 'about/server'
22 |
--------------------------------------------------------------------------------
/about/lib/about/views/ruby.erb:
--------------------------------------------------------------------------------
1 |
2 | Ruby
3 |
4 |
5 | version: <%= RUBY_VERSION %>
6 | release_date: <%= RUBY_RELEASE_DATE %>
7 | platform: <%= RUBY_PLATFORM %>
8 |
9 |
10 |
11 | Loadpath
12 |
13 |
14 | <% $LOAD_PATH.each_with_index do |path,index| %>
15 | [<%= index+1 %>] <%= path %>
16 | <% end %>
17 |
18 |
--------------------------------------------------------------------------------
/record/lib/record.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require 'pp'
4 | require 'logger'
5 |
6 |
7 |
8 | ###
9 | # our own code
10 | require 'record/version' # let version always go first
11 | require 'record/field'
12 | require 'record/base'
13 | require 'record/builder'
14 |
15 |
16 | # say hello
17 | puts Record.banner if $DEBUG || (defined?($RUBYCOCO_DEBUG) && $RUBYCOCO_DEBUG)
18 |
--------------------------------------------------------------------------------
/rubycat/test/test_version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_version.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestVersion < MiniTest::Test
11 |
12 | def test_version
13 | assert_equal RubyCat::VERSION, RubyCat.version
14 | assert true # if we get here - test success
15 | end
16 |
17 |
18 | end # class TestVersion
19 |
--------------------------------------------------------------------------------
/catalogdb/test/test_version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_version.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestVersion < MiniTest::Test
11 |
12 | def test_version
13 | assert_equal CatalogDb::VERSION, CatalogDb.version
14 | assert true # if we get here - test success
15 | end
16 |
17 |
18 | end # class TestVersion
19 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 | VERSION = '0.1.0'
5 |
6 | def self.banner
7 | "bookman/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
8 | end
9 |
10 | def self.root
11 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
12 | end
13 | end
14 |
15 | ## add module alias
16 | BookMan = Bookman
17 |
18 |
--------------------------------------------------------------------------------
/record/test/test_version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_version.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestVersion < MiniTest::Test
11 |
12 | def test_version
13 | pp Record::VERSION
14 | pp Record.banner
15 | pp Record.root
16 |
17 | assert true ## assume ok if we get here
18 | end
19 |
20 | end # class TestVersion
21 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/helpers/misc.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | ## todo: change to Hybook::NumberHelper - why? why not??
5 |
6 | module HybookHelper
7 |
8 | ### todo:
9 | ## add to textutils ?? why? why not??
10 | def number_with_delimiter( num )
11 | delimiter = '.'
12 | num.to_s.reverse.gsub( /(\d{3})(?=\d)/, "\\1#{delimiter}").reverse
13 | end
14 |
15 |
16 | end # module HybookHelper
17 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookfile
4 | VERSION = '0.2.1'
5 |
6 | def self.banner
7 | "bookfile/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
8 | end
9 |
10 | def self.root
11 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
12 | end
13 | end
14 |
15 | ## add module alias
16 | BookFile = Bookfile
17 |
18 |
--------------------------------------------------------------------------------
/hybook/test/test_basics.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | require 'helper'
5 |
6 | class TestBasics < MiniTest::Test
7 |
8 | def test_banner
9 |
10 | banner = "hybook/#{Hybook::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
11 |
12 | assert_equal banner, Hybook.banner
13 | assert_equal banner, HyBook.banner ## check module alias
14 |
15 | end
16 |
17 | end # class Basics
18 |
--------------------------------------------------------------------------------
/fizzbuzzer/test/test_version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_version.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestVersion < MiniTest::Test
12 |
13 | def test_version
14 | pp FizzBuzzer.version
15 | pp FizzBuzzer.banner
16 | pp FizzBuzzer.root
17 |
18 | assert true ## (for now) everything ok if we get here
19 | end
20 |
21 | end # class TestVersion
22 |
--------------------------------------------------------------------------------
/ostructer/README.rdoc:
--------------------------------------------------------------------------------
1 | = ostructer - Open Struct Builder in Ruby
2 |
3 | * http://github.com/geraldb/ostructer
4 |
5 | == DESCRIPTION:
6 |
7 | Lets you build open structs from nested hashes, arrays and strings.
8 |
9 | == INSTALL:
10 |
11 | Just install the gem:
12 |
13 | $ sudo gem install ostructer
14 |
15 | == LICENSE:
16 |
17 | The ostructer sources are dedicated to the public domain. Use it as you please with no restrictions whatsoever.
--------------------------------------------------------------------------------
/ostructer/test/customer.json:
--------------------------------------------------------------------------------
1 | { customer:
2 | { id: '12253',
3 | first_name: 'Joe',
4 | last_name: 'Joe',
5 | address:
6 | [{typ: 'home',
7 | line1: '211 Over There',
8 | city: 'Jacksonville',
9 | state: 'FL',
10 | zip_code: '11234'
11 | },
12 | {typ: 'postal',
13 | line1: '3535 Head Office',
14 | city: 'Jacksonville',
15 | state: 'FL',
16 | zip_code: '11234'
17 | }]
18 | }
19 | }
--------------------------------------------------------------------------------
/about/Manifest.txt:
--------------------------------------------------------------------------------
1 | History.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/about.rb
6 | lib/about/public/style.css
7 | lib/about/server.rb
8 | lib/about/version.rb
9 | lib/about/views/debug.erb
10 | lib/about/views/env.erb
11 | lib/about/views/layout.erb
12 | lib/about/views/rack.erb
13 | lib/about/views/rails.erb
14 | lib/about/views/ruby.erb
15 | lib/about/views/shared/_debug.erb
16 | lib/about/views/shared/_version.erb
17 | lib/about/views/sinatra.erb
18 |
--------------------------------------------------------------------------------
/hybook/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/hybook.rb
6 | lib/hybook/builder/album.rb
7 | lib/hybook/builder/book.rb
8 | lib/hybook/helpers/markdown.rb
9 | lib/hybook/helpers/misc.rb
10 | lib/hybook/std/album.rb
11 | lib/hybook/type/album.rb
12 | lib/hybook/type/picture.rb
13 | lib/hybook/type/section.rb
14 | lib/hybook/version.rb
15 | lib/hybook/writer/jekyll.rb
16 | templates/album.md
17 | test/helper.rb
18 | test/test_basics.rb
19 |
--------------------------------------------------------------------------------
/rubycat/lib/rubycat.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | # 3rd party libs (gems)
4 | require 'catalogdb'
5 | require 'fetcher'
6 |
7 |
8 | # our own code
9 |
10 | require 'rubycat/version' ## let version always go first
11 |
12 | require 'rubycat/card'
13 | require 'rubycat/catalog'
14 |
15 | ## services / apis
16 |
17 | require 'rubycat/service/rubygems'
18 |
19 |
20 |
21 | # say hello
22 | puts RubyCat.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
23 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Hybook
5 | VERSION = '0.2.1'
6 |
7 | def self.banner
8 | "hybook/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
9 | end
10 |
11 | def self.root
12 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
13 | end
14 |
15 | def self.templates_path
16 | "#{root}/templates"
17 | end
18 |
19 | end
20 |
21 | ## add module alias
22 |
23 | HyBook = Hybook
24 |
25 |
--------------------------------------------------------------------------------
/bookfile/test/test_basics.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_basics.rb
6 |
7 | require 'helper'
8 |
9 | class TestBasics < MiniTest::Test
10 |
11 | def test_banner
12 |
13 | banner = "bookfile/#{Bookfile::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
14 |
15 | assert_equal banner, Bookfile.banner
16 | assert_equal banner, BookFile.banner ## check module alias
17 |
18 | end
19 |
20 | end # class Basics
21 |
--------------------------------------------------------------------------------
/preproc/test/test_incl.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_incl.rb
6 | # or better
7 | # rake test
8 |
9 |
10 | require 'helper'
11 |
12 |
13 | class TestIncl < MiniTest::Test
14 |
15 | def test_ruby
16 | src = 'https://raw.github.com/feedreader/planet-ruby/master/ruby.ini'
17 | txt = InclPreproc.from_url( src ).read
18 | pp txt
19 |
20 | assert true ## if we get here it should work
21 | end
22 |
23 | end # class TestIncl
24 |
25 |
--------------------------------------------------------------------------------
/typeconv/lib/typeconv/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | class Typeconv
5 |
6 | MAJOR = 0
7 | MINOR = 0
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "typeconv/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module Typeconv
24 |
--------------------------------------------------------------------------------
/bookman/lib/bookman.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ###
5 | # todo: add dependencies
6 | ## - hybook ??
7 | ## - datafile, bookfile ??
8 |
9 |
10 | ####################
11 | # our own code
12 |
13 | require 'bookman/version' # let it always go first
14 |
15 | require 'bookman/bookman'
16 | require 'bookman/config'
17 | require 'bookman/world'
18 | require 'bookman/football'
19 | require 'bookman/beer'
20 |
21 |
22 |
23 | # say hello
24 | puts Bookman.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
25 |
26 |
--------------------------------------------------------------------------------
/gutenberg/lib/gutenberg/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Gutenberg
5 |
6 | MAJOR = 2
7 | MINOR = 0
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "gutenberg/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module Gutenberg
24 |
--------------------------------------------------------------------------------
/fizzbuzzer/lib/fizzbuzzer/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module FizzBuzzer
5 |
6 | MAJOR = 1
7 | MINOR = 1
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "fizzbuzzer/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module FizzBuzzer
24 |
--------------------------------------------------------------------------------
/ostructer/test/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 10.0.0.101
4 | 10.0.1.101
5 |
6 |
7 | 10.0.0.102
8 |
9 |
10 | 10.0.0.103
11 | 10.0.1.103
12 |
13 |
--------------------------------------------------------------------------------
/ostructer/test/customer.xml:
--------------------------------------------------------------------------------
1 |
2 | Joe
3 | Joe
4 |
5 | 211 Over There
6 | Jacksonville
7 | FL
8 | 11234
9 |
10 |
11 | 3535 Head Office
12 | Jacksonville
13 | FL
14 | 11234
15 |
16 |
17 |
--------------------------------------------------------------------------------
/bookfile/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/bookfile.rb
6 | lib/bookfile/book/book.rb
7 | lib/bookfile/book/config.rb
8 | lib/bookfile/bookfile.rb
9 | lib/bookfile/builder.rb
10 | lib/bookfile/database/database.rb
11 | lib/bookfile/package/package.rb
12 | lib/bookfile/version.rb
13 | test/bookfile/beer.rb
14 | test/bookfile/football.rb
15 | test/bookfile/world.rb
16 | test/helper.rb
17 | test/test_basics.rb
18 | test/test_beer.rb
19 | test/test_football.rb
20 | test/test_world.rb
21 | test/test_world_templates.rb
22 |
--------------------------------------------------------------------------------
/ostructer/test/config.json:
--------------------------------------------------------------------------------
1 | { config:
2 | { logdir: '/var/log/foo/',
3 | debugfile: '/tmp/foo.debug',
4 | server:
5 | [{ name: 'sahara',
6 | osname: 'solaris',
7 | osversion: '2.6',
8 | address: ['10.0.0.101','10.0.1.101']},
9 | { name: 'gobi',
10 | osname: 'irix',
11 | osversion: '6.5',
12 | address: ['10.0.0.102']},
13 | { name: 'kalahari',
14 | osname: 'linux',
15 | osversion: '2.0.34',
16 | address: ['10.0.0.103', '10.0.1.103']}
17 | ]
18 | }
19 | }
--------------------------------------------------------------------------------
/fotos/lib/fotos/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Fotos
4 | MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5 | MINOR = 1
6 | PATCH = 0
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "fotos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
15 | end
16 |
17 | def self.root
18 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
19 | end
20 | end # module Fotos
21 |
22 |
--------------------------------------------------------------------------------
/fotos/test/test_builder.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_builder.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestBuilder < MiniTest::Test
12 |
13 |
14 | def test_library
15 |
16 | builder = Fotos::LibraryBuilder.new( "/franzzz/bilder" )
17 | folder = builder.build
18 |
19 | report = Fotos::StatsReport.new( folder )
20 | txt = report.render
21 | puts txt
22 |
23 | assert true
24 | ## assume everything ok if get here
25 | end
26 |
27 | end # class TestBuilder
28 |
--------------------------------------------------------------------------------
/bookfile/README.md:
--------------------------------------------------------------------------------
1 | # bookfile - Book Builder
2 |
3 | bookfile gem - builder for books
4 |
5 | * home :: [github.com/hybook/bookfile](https://github.com/hybook/bookfile)
6 |
7 |
8 | ## Usage
9 |
10 | to be done
11 |
12 | ## License
13 |
14 | The `bookfile` scripts are dedicated to the public domain.
15 | Use it as you please with no restrictions whatsoever.
16 |
17 |
18 | ## Questions? Comments?
19 |
20 | Send them along to the
21 | [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow).
22 | Thanks!
23 |
--------------------------------------------------------------------------------
/fotos/README.md:
--------------------------------------------------------------------------------
1 | # fotos
2 |
3 | fotos gem - manage fotos on the command line
4 |
5 | * home :: [github.com/rubylibs/fotos](https://github.com/rubylibs/fotos)
6 | * bugs :: [github.com/rubylibs/fotos/issues](https://github.com/rubylibs/fotos/issues)
7 | * gem :: [rubygems.org/gems/fotos](https://rubygems.org/gems/fotos)
8 | * rdoc :: [rubydoc.info/gems/fotos](http://rubydoc.info/gems/fotos)
9 |
10 |
11 | ## Usage
12 |
13 | TBD
14 |
15 |
16 | ## License
17 |
18 | The `fotos` scripts are dedicated to the public domain.
19 | Use it as you please with no restrictions whatsoever.
20 |
--------------------------------------------------------------------------------
/about/lib/about/views/layout.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | About / Sys Info
6 |
7 |
8 |
9 |
10 |
11 | About |
12 | <%= link_to 'Ruby', ruby_path %> •
13 | <%= link_to 'Env', env_path %> •
14 | <%= link_to 'Rack', rack_path %> •
15 | <%= link_to 'Sinatra', sinatra_path %> •
16 | <%= link_to 'Rails', rails_path %>
17 |
18 |
19 | <%= yield %>
20 |
21 | <%= erb :'shared/_version' %>
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/catalogdb/lib/catalogdb/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module CatalogDb
4 |
5 | MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6 | MINOR = 1
7 | PATCH = 1
8 | VERSION = [MAJOR,MINOR,PATCH].join('.')
9 |
10 | def self.version
11 | VERSION
12 | end
13 |
14 | def self.banner
15 | "catalogdb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
16 | end
17 |
18 | def self.root
19 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
20 | end
21 |
22 | end # module CatalogDb
23 |
--------------------------------------------------------------------------------
/bookman/README.md:
--------------------------------------------------------------------------------
1 | # bookman - Yet Another Book Builder
2 |
3 | bookman gem - yet another book builder
4 |
5 | * home :: [github.com/hybook/bookman](https://github.com/hybook/bookman)
6 |
7 |
8 | ## Usage
9 |
10 | to be done
11 |
12 | ## License
13 |
14 | The `bookman` scripts are dedicated to the public domain.
15 | Use it as you please with no restrictions whatsoever.
16 |
17 |
18 | ## Questions? Comments?
19 |
20 | Send them along to the
21 | [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow).
22 | Thanks!
23 |
--------------------------------------------------------------------------------
/officetxt/lib/officetxt/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Officetxt
4 | MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5 | MINOR = 1
6 | PATCH = 1
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "officetxt/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
15 | end
16 |
17 | def self.root
18 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
19 | end
20 | end # module Officetxt
21 |
--------------------------------------------------------------------------------
/record/lib/record/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Record
5 |
6 | module Version
7 | MAJOR = 1
8 | MINOR = 2
9 | PATCH = 0
10 | end
11 | VERSION = [Version::MAJOR,
12 | Version::MINOR,
13 | Version::PATCH].join('.')
14 |
15 |
16 | def self.version
17 | VERSION
18 | end
19 |
20 | def self.banner
21 | "record/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
22 | end
23 |
24 | def self.root
25 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
26 | end
27 |
28 | end # module Record
29 |
--------------------------------------------------------------------------------
/ostructer/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/ostructer.rb'
3 |
4 | Hoe.spec 'ostructer' do
5 |
6 | self.version = Ostructer::VERSION
7 |
8 | self.summary = 'Ostructer - Open Struct Builder'
9 | self.url = 'http://github.com/geraldb/ostructer'
10 |
11 | self.author = 'Gerald Bauer'
12 | self.email = 'gerald.bauer@gmail.com'
13 |
14 | self.extra_deps = [
15 | ['xml-simple','>= 1.1.0']
16 | ]
17 |
18 | self.remote_rdoc_dir = 'doc'
19 |
20 | # switch extension to .rdoc for gihub formatting
21 | self.readme_file = 'README.rdoc'
22 | self.history_file = 'History.rdoc'
23 | end
--------------------------------------------------------------------------------
/catalogdb/lib/catalogdb.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | # stdlibs
4 | require 'pp'
5 | require 'date'
6 | require 'strscan' ## StringScanner lib
7 | require 'erb'
8 | require 'uri'
9 | require 'json'
10 |
11 |
12 | # 3rd party libs (gems)
13 | require 'props'
14 | require 'logutils'
15 | require 'textutils'
16 |
17 | require 'props/activerecord'
18 | require 'logutils/activerecord'
19 |
20 |
21 | # our own code
22 |
23 | require 'catalogdb/version' ## let version always go first
24 |
25 | require 'catalogdb/reader'
26 |
27 |
28 |
29 | # say hello
30 | puts CatalogDb.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
31 |
--------------------------------------------------------------------------------
/about/lib/about/views/shared/_debug.erb:
--------------------------------------------------------------------------------
1 | Request
2 |
3 |
4 | request.scheme: <%= request.scheme %>
5 | request.script_name: <%= request.script_name %>
6 | request.path_info: <%= request.path_info %>
7 | request.port: <%= request.port %>
8 | request.request_method: <%= request.request_method %>
9 | request.query_string: <%= request.query_string %>
10 | request.host: <%= request.host %>
11 | request.referrer: <%= request.referrer %>
12 | request.user_agent: <%= request.user_agent %>
13 | request.url: <%= request.url %>
14 | request.path: <%= request.path %>
15 | request.ip: <%= request.ip %>
16 |
17 |
--------------------------------------------------------------------------------
/rubycat/lib/rubycat/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module RubyCat
4 |
5 | MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6 | MINOR = 2
7 | PATCH = 0
8 | VERSION = [MAJOR,MINOR,PATCH].join('.')
9 |
10 | def self.version
11 | VERSION
12 | end
13 |
14 | def self.banner
15 | "rubycat/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
16 | end
17 |
18 | def self.root
19 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
20 | end
21 |
22 | end # module RubyCat
23 |
24 | ## add module alias
25 | Rubycat = RubyCat
26 |
27 |
--------------------------------------------------------------------------------
/preproc/lib/preproc/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Preproc
4 |
5 | MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6 | MINOR = 1
7 | PATCH = 0
8 | VERSION = [MAJOR,MINOR,PATCH].join('.')
9 |
10 | def self.version
11 | VERSION
12 | end
13 |
14 | # version string for generator meta tag (includes ruby version)
15 | def self.banner
16 | "preproc/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module Preproc
24 |
25 |
--------------------------------------------------------------------------------
/rubycat/lib/rubycat/service/rubygems.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ### add to RubyCat module/namespace - why?? why not??
5 |
6 |
7 | class RubyGemsService
8 |
9 | def initialize
10 | @worker = Fetcher::Worker.new
11 | @api_base = 'http://rubygems.org/api/v1'
12 | end
13 |
14 | def info( name )
15 | api_url = "#{@api_base}/gems/#{name}.json"
16 |
17 | ### fix/todo: add read_json! -- !!!! to fetcher
18 | txt = @worker.read_utf8!( api_url )
19 | pp txt
20 |
21 | json = JSON.parse( txt )
22 | ## pp json
23 | json ## return parsed json hash (or raise HTTP excep)
24 | end
25 | end ## class RubyGemsService
26 |
27 |
--------------------------------------------------------------------------------
/about/README.md:
--------------------------------------------------------------------------------
1 | # about gem
2 |
3 | sys info (system information) about your computer, environment, runtime, libs, etc as mountable web app
4 |
5 | * home :: [github.com/rubylibs/about](https://github.com/rubylibs/about)
6 | * bugs :: [github.com/rubylibs/about/issues](https://github.com/rubylibs/about/issues)
7 | * gem :: [rubygems.org/gems/about](https://rubygems.org/gems/about)
8 | * rdoc :: [rubydoc.info/gems/about](http://rubydoc.info/gems/about)
9 |
10 | ## Usage
11 |
12 | TBD
13 |
14 | ## Alternatives
15 |
16 | TBD
17 |
18 | ## License
19 |
20 | The `about` scripts are dedicated to the public domain.
21 | Use it as you please with no restrictions whatsoever.
22 |
--------------------------------------------------------------------------------
/record/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/record/version.rb'
3 |
4 | Hoe.spec 'record' do
5 |
6 | self.version = Record::VERSION
7 |
8 | self.summary = "record - named tuples / records with typed structs / schemas"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubycoco/record']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.licenses = ['Public Domain']
21 |
22 | self.spec_extras = {
23 | required_ruby_version: '>= 2.2.2'
24 | }
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/almost-sinatra/samples/hello.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ####################################
4 | # The Proof of the Pudding - hello.rb
5 | #
6 | # Use
7 | # $ ruby -I ./lib ./samples/hello.rb
8 |
9 |
10 | require 'almost-sinatra'
11 |
12 |
13 | include $n # include "anonymous" Almost Sinatra DSL module
14 |
15 |
16 | get '/hello' do
17 | erb "Hello <%= name %>!", locals: { name: params['name'] }
18 | end
19 |
20 |
21 | get '/' do
22 | markdown <= 1.9.2'
28 | }
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/fotos/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/typeconv/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/fizzbuzzer/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/gutenberg/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/gutenberg/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/gutenberg/version.rb'
3 |
4 | Hoe.spec 'gutenberg' do
5 |
6 | self.version = Gutenberg::VERSION
7 |
8 | self.summary = "gutenberg - the printing press for books (reinvented in ruby)"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubylibs/gutenberg']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 1.9.2'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/officetxt/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/almost-sinatra/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/bookfile/test/test_football.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_football.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestFootball < MiniTest::Test
11 |
12 | def test_football
13 | book_templates_unzip_dir = './tmp/book-football'
14 |
15 | bookfile = Bookfile::Bookfile.load_file( './test/bookfile/football.rb' )
16 |
17 | bookfile.download # download book packages (templates n scripts)
18 | bookfile.unzip( book_templates_unzip_dir )
19 |
20 | bookfile.prepare( book_templates_unzip_dir )
21 | bookfile.connect
22 |
23 | bookfile.build( book_templates_unzip_dir )
24 |
25 | assert true # if we get here - test success
26 | end
27 |
28 | end # class TestFootball
29 |
30 |
--------------------------------------------------------------------------------
/bookfile/test/test_world_templates.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_world_templates.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestWorldTemplates < MiniTest::Test
11 |
12 | def test_unzip
13 | builder = Bookfile::Builder.load_file( './test/bookfile/world.rb' )
14 | bookfile = builder.bookfile
15 |
16 | bookfile.download # download book packages (templates n scripts)
17 | bookfile.unzip # unzip book packages (template)
18 |
19 | bookfile.prepare # require models n helpers
20 |
21 | # bookfile.connect
22 | # bookfile.build
23 |
24 | assert true # if we get here - test success
25 | end
26 |
27 | end # class TestWorldTemplates
28 |
29 |
--------------------------------------------------------------------------------
/typeconv/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/typeconv/version.rb'
3 |
4 | Hoe.spec 'typeconv' do
5 |
6 | self.version = Typeconv::VERSION
7 |
8 | self.summary = "typeconv (type converters) - convert strings to numbers, dates, booleans, nulls and more"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubycoco/typeconv']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.2.2'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/bookfile/test/test_world.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_world.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestWorld < MiniTest::Test
11 |
12 | def test_world
13 | book_templates_unzip_dir = './tmp/book-world'
14 |
15 | bookfile = Bookfile::Bookfile.load_file( './test/bookfile/world.rb' )
16 |
17 | ## bookfile.download # download book packages (templates n scripts)
18 | ## bookfile.unzip( book_templates_unzip_dir )
19 |
20 | bookfile.prepare( book_templates_unzip_dir )
21 | bookfile.connect
22 |
23 | bookfile.build( book_templates_unzip_dir )
24 |
25 | assert true # if we get here - test success
26 | end
27 |
28 | end # class TestWorld
29 |
30 |
--------------------------------------------------------------------------------
/catalogdb/test/test_reader.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_reader.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestReader < MiniTest::Test
12 |
13 | def test_ruby
14 |
15 | r = CatalogDb::CardReader.from_file( "#{CatalogDb.root}/test/data/RUBY.md" )
16 | cards = r.read
17 |
18 | pp cards
19 |
20 | c = cards[0]
21 |
22 | assert_equal [["Rack HQ", "http://rack.github.io"],
23 | [":octocat:", "https://github.com/rack"],
24 | [":gem:", "https://rubygems.org/gems/rack"],
25 | [":book:", "http://rubydoc.info/gems/rack"]], c.links
26 |
27 | assert_equal 'Webframeworks › Rack', c.categories
28 | end
29 |
30 | end # class TestReader
31 |
--------------------------------------------------------------------------------
/preproc/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/preproc/version.rb'
3 |
4 | Hoe.spec 'preproc' do
5 |
6 | self.version = Preproc::VERSION
7 |
8 | self.summary = 'preproc - simple preprocessor (lets you include files in files in files etc.)'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubylibs/preproc']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ['logutils'],
22 | ['fetcher']
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 1.9.2'
29 | }
30 |
31 | end
32 |
--------------------------------------------------------------------------------
/about/lib/about/public/style.css:
--------------------------------------------------------------------------------
1 | /* fix: use sass w/ variables */
2 |
3 | body {
4 | font-family: sans-serif;
5 | background-color: #F4F4F4;
6 | color: #333333;
7 | }
8 |
9 | a, a:visited {
10 | text-decoration: none;
11 | color: maroon;
12 | }
13 |
14 | a:hover {
15 | text-decoration: underline;
16 | color: #1E68A6;
17 | background-color: yellow;
18 | }
19 |
20 |
21 | /* fix: use .small instead */
22 | .smaller {
23 | font-size: 12px;
24 | /* color: #666666; */ /* lighter gray than text gray */
25 | }
26 |
27 |
28 |
29 | /** version block **********/
30 |
31 | .version {
32 | text-align: center;
33 | margin-top: 10px;
34 | color: grey; }
35 | .version a, .version span {
36 | font-size: 12px;
37 | color: grey; }
38 |
39 | /***************************/
--------------------------------------------------------------------------------
/about/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/about/version.rb'
3 |
4 | Hoe.spec 'about' do
5 |
6 | self.version = About::VERSION
7 |
8 | self.summary = 'about - sys info (system information) about your computer, environment, runtime, libs, etc. as mountable web app'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubylibs/about']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'webslideshow@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'History.md'
19 |
20 | self.extra_deps = [
21 | ['logutils', '>= 0.5'],
22 | ['textutils', '>= 0.7']
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | :required_ruby_version => '>= 1.9.2'
29 | }
30 |
31 |
32 | end
--------------------------------------------------------------------------------
/rubycat/test/test_reader.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_reader.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestReader < MiniTest::Test
12 |
13 | def test_ruby
14 |
15 | r = CatalogDb::CardReader.from_file( "#{RubyCat.root}/test/data/RUBY.md" )
16 | cards = r.read
17 |
18 | pp cards
19 |
20 | c = cards[0]
21 |
22 | assert_equal [["Rack HQ", "http://rack.github.io"],
23 | [":octocat:", "https://github.com/rack"],
24 | [":gem:", "https://rubygems.org/gems/rack"],
25 | [":book:", "http://rubydoc.info/gems/rack"]], c.links
26 |
27 | assert_equal 'Webframeworks › Rack', c.categories
28 |
29 | cat = RubyCat::Catalog.new
30 | cat.add( cards )
31 | cat.render
32 | end
33 |
34 | end # class TestReader
35 |
--------------------------------------------------------------------------------
/almost-sinatra/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 | Hoe.spec 'almost-sinatra' do
4 |
5 | self.version = '1.0.0'
6 |
7 | self.summary = 'almost-sinatra - six lines of almost sinatra refactored and bundled up for easy (re)use - build your own webframework from scratch with rack and tilt'
8 | self.description = summary
9 |
10 | self.urls = ['https://github.com/rubylibs/almost-sinatra']
11 |
12 | self.author = ['Konstantin Haase', 'Gerald Bauer']
13 | self.email = 'ruby-talk@ruby-lang.org'
14 |
15 | # switch extension to .markdown for gihub formatting
16 | self.readme_file = 'README.md'
17 | self.history_file = 'HISTORY.md'
18 |
19 | self.extra_deps = [
20 | ['rack', '>= 2.0' ],
21 | ['tilt', '>= 2.0' ],
22 | ]
23 |
24 | self.licenses = ['Public Domain']
25 |
26 | self.spec_extras = {
27 | required_ruby_version: '>= 2.3'
28 | }
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/rubycat/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/rubycat/version.rb'
3 |
4 | Hoe.spec 'rubycat' do
5 |
6 | self.version = RubyCat::VERSION
7 |
8 | self.summary = "rubycat - ruby (library) catalog (cards) command line tool (using the catalog.db machinery)"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/textkit/rubycat']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ['catalogdb', '>= 0.1.1'],
22 | ## 3rd party
23 | ['fetcher', '>= 0.4.5'],
24 | ['sqlite3']
25 | ]
26 |
27 | self.licenses = ['Public Domain']
28 |
29 | self.spec_extras = {
30 | required_ruby_version: '>= 1.9.2'
31 | }
32 |
33 | end
34 |
--------------------------------------------------------------------------------
/typeconv/README.md:
--------------------------------------------------------------------------------
1 | # Type Converters
2 |
3 | typeconv (type converters) library / gem - convert strings to numbers, dates, booleans, nulls and more
4 |
5 | * home :: [github.com/rubycoco/typeconv](https://github.com/rubycoco/typeconv)
6 | * bugs :: [github.com/rubycoco/typeconv/issues](https://github.com/rubycoco/typeconv/issues)
7 | * gem :: [rubygems.org/gems/typeconv](https://rubygems.org/gems/typeconv)
8 | * rdoc :: [rubydoc.info/gems/typeconv](http://rubydoc.info/gems/typeconv)
9 | * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
10 |
11 |
12 | ## Usage
13 |
14 | to be done
15 |
16 |
17 | ## License
18 |
19 | The `typeconv` scripts are dedicated to the public domain.
20 | Use it as you please with no restrictions whatsoever.
21 |
22 |
23 | ## Questions? Comments?
24 |
25 | Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
26 | Thanks!
27 |
--------------------------------------------------------------------------------
/catalogdb/README.md:
--------------------------------------------------------------------------------
1 | # catalog.db
2 |
3 | catalog.db schema 'n' models for easy (re)use
4 |
5 | * home :: [github.com/textkit/catalog.db](https://github.com/textkit/catalog.db)
6 | * bugs :: [github.com/textkit/catalog.db/issues](https://github.com/textkit/catalog.db/issues)
7 | * gem :: [rubygems.org/gems/catalogdb](https://rubygems.org/gems/catalogdb)
8 | * rdoc :: [rubydoc.info/gems/catalogdb](http://rubydoc.info/gems/catalogdb)
9 | * forum :: [ruby-talk@ruby-lang.org](http://www.ruby-lang.org/en/community/mailing-lists)
10 |
11 |
12 | ## Usage
13 |
14 | To be done
15 |
16 |
17 | ## Install
18 |
19 | Just install the gem:
20 |
21 | $ gem install catalogdb
22 |
23 |
24 | ## License
25 |
26 | The `catalogdb` scripts are dedicated to the public domain.
27 | Use it as you please with no restrictions whatsoever.
28 |
29 |
30 | ## Questions? Comments?
31 |
32 | Send them along to the ruby-talk mailing list.
33 | Thanks!
34 |
35 |
--------------------------------------------------------------------------------
/rubycat/README.md:
--------------------------------------------------------------------------------
1 | # rubycat
2 |
3 | ruby (library) catalog (cards) command line tool (using the catalog.db machinery)
4 |
5 |
6 | * home :: [github.com/textkit/rubycat](https://github.com/textkit/rubycat)
7 | * bugs :: [github.com/textkit/rubycat/issues](https://github.com/textkit/rubycat/issues)
8 | * gem :: [rubygems.org/gems/rubycat](https://rubygems.org/gems/rubycat)
9 | * rdoc :: [rubydoc.info/gems/rubycat](http://rubydoc.info/gems/rubycat)
10 | * forum :: [ruby-talk@ruby-lang.org](http://www.ruby-lang.org/en/community/mailing-lists)
11 |
12 |
13 | ## Usage
14 |
15 | To be done
16 |
17 |
18 | ## Install
19 |
20 | Just install the gem:
21 |
22 | $ gem install rubycat
23 |
24 |
25 | ## License
26 |
27 | The `rubycat` scripts are dedicated to the public domain.
28 | Use it as you please with no restrictions whatsoever.
29 |
30 |
31 | ## Questions? Comments?
32 |
33 | Send them along to the ruby-talk mailing list.
34 | Thanks!
35 |
36 |
--------------------------------------------------------------------------------
/gutenberg/README.md:
--------------------------------------------------------------------------------
1 | # gutenberg
2 |
3 | the printing press for books (reinvented in ruby)
4 |
5 | * home :: [github.com/rubylibs/gutenberg](https://github.com/rubylibs/gutenberg)
6 | * bugs :: [github.com/rubylibs/gutenberg/issues](https://github.com/rubylibs/gutenberg/issues)
7 | * gem :: [rubygems.org/gems/gutenberg](https://rubygems.org/gems/gutenberg)
8 | * rdoc :: [rubydoc.info/gems/gutenberg](http://rubydoc.info/gems/gutenberg)
9 | * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
10 |
11 |
12 | ## Usage
13 |
14 | to be done
15 |
16 |
17 |
18 |
19 | ## Install
20 |
21 | Just install the gem:
22 |
23 | $ gem install gutenberg
24 |
25 |
26 | ## License
27 |
28 | The `gutenberg` scripts are dedicated to the public domain.
29 | Use it as you please with no restrictions whatsoever.
30 |
31 |
32 | ## Questions? Comments?
33 |
34 | Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
35 | Thanks!
36 |
37 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/helpers/markdown.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ###
5 | ## todo: change to Hybook::MarkdownHelper -- why, why not????
6 |
7 |
8 | module HybookHelper
9 |
10 | ###########################
11 | # markdown helpers
12 |
13 | ###
14 | # fix: move to Markdown gem
15 | # add to new module
16 | # MarkdownHelper or Markdown::Helper ???
17 |
18 |
19 | def link_to( title, link )
20 | "[#{title}](#{link})"
21 | end
22 |
23 |
24 | def columns_begin( opts={} )
25 | # note: will add columns2 or columns3 etc. depending on columns option passed in
26 |
27 | ## note: default was 2 (columns) for world.db, 300 (px) for beer.db
28 | columns = opts[:columns] || 300
29 |
30 | "\n\n\n"
31 | end
32 |
33 | def columns_end
34 | "\n
\n\n"
35 | end
36 |
37 | ### todo: check if we can use columns simply w/ yield for body ??
38 |
39 |
40 | end # module HybookHelper
41 |
--------------------------------------------------------------------------------
/bookman/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/bookman/version.rb'
3 |
4 | Hoe.spec 'bookman' do
5 |
6 | self.version = Bookman::VERSION
7 |
8 | self.summary = 'bookman - yet another builder for books'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/hybook/bookman']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'webslideshow@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.licenses = ['Public Domain']
21 |
22 | self.extra_deps = [
23 | ['hybook'], # settings / prop(ertie)s / env / INI
24 | ['bookfile'], # logging
25 | ['fetcher'], ## todo: check if included in ??
26 | ['rubyzip'], ## todo: check if included in ??
27 | ### todo: add datafile ???
28 | ]
29 |
30 | self.spec_extras = {
31 | required_ruby_version: '>= 1.9.2'
32 | }
33 |
34 | end
35 |
36 |
--------------------------------------------------------------------------------
/hybook/lib/hybook.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ############
5 | # stdlibs
6 |
7 | require 'pp'
8 |
9 |
10 | ###################
11 | # 3rd party libs
12 |
13 | require 'textutils'
14 |
15 |
16 | #####################
17 | # our own code
18 |
19 | require 'hybook/version' # let it always go first
20 |
21 | require 'hybook/type/album'
22 | require 'hybook/type/picture'
23 | require 'hybook/type/section'
24 |
25 | ##############################################
26 | # builtin std helpers, renderers n builders
27 |
28 | require 'hybook/std/album'
29 | require 'hybook/helpers/markdown'
30 | require 'hybook/helpers/misc'
31 |
32 | ## builders
33 |
34 | require 'hybook/builder/book'
35 | require 'hybook/builder/album'
36 |
37 | ## writers
38 |
39 | require 'hybook/writer/jekyll'
40 |
41 |
42 |
43 |
44 | # say hello
45 | if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
46 | puts Hybook.banner
47 | puts "[hybook] root: #{Hybook.root}"
48 | puts "[hybook] templates_path: #{Hybook.templates_path}"
49 | end
50 |
--------------------------------------------------------------------------------
/bookman/test/test_basics.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_basics.rb
6 |
7 | require 'helper'
8 |
9 | class TestBasics < MiniTest::Test
10 |
11 | def test_banner
12 |
13 | banner = "bookman/#{Bookman::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
14 |
15 | assert_equal banner, Bookman.banner
16 | assert_equal banner, BookMan.banner ## check module alias
17 | end
18 |
19 | def test_football_config
20 | cfg = Bookman::FootballConfig.new( setup: 'at' )
21 | pp cfg
22 | assert true
23 | end
24 |
25 | def test_football_builder
26 | b = Bookman::Bookman.create_football_book_for( 'at' )
27 | assert true
28 | end
29 |
30 | def test_world_builder
31 | b = Bookman::Bookman.create_world_book_for( 'at' )
32 | assert true
33 | end
34 |
35 | def test_beer_builder
36 | b = Bookman::Bookman.create_beer_book_for( 'at' )
37 | assert true
38 | end
39 |
40 | end # class Basics
41 |
--------------------------------------------------------------------------------
/hybook/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/hybook/version.rb'
3 |
4 | Hoe.spec 'hybook' do
5 |
6 | self.version = Hybook::VERSION
7 |
8 | self.summary = 'hybook - hypertext book generator'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/hybook/hybook']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'webslideshow@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.licenses = ['Public Domain']
21 |
22 | self.extra_deps = [
23 | ['props'], # settings / prop(ertie)s / env / INI
24 | ['logutils'], # logging
25 | ['textutils'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
26 | ['markdown'], # markdown helper (e.g. link_to etc.)
27 |
28 | ## 3rd party
29 | ['gli'],
30 | ['activesupport']
31 | ]
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 1.9.2'
35 | }
36 |
37 | end
38 |
--------------------------------------------------------------------------------
/ostructer/test/test_customer_json.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'active_support'
7 |
8 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
9 | # $LOAD_PATH.unshift(LIB_PATH)
10 |
11 | require 'lib/ostructer.rb'
12 |
13 | ## NB: XmlSimple -> ForceArray is true by default (turn it off!!)
14 | ##
15 |
16 | class TestCustomerJson < Test::Unit::TestCase
17 |
18 | def setup
19 | fn = 'test/customer.json'
20 |
21 | @doc = ActiveSupport::JSON.decode( File.read( fn ) )
22 |
23 | logger = Logger.new(STDOUT)
24 | logger.level = Logger::DEBUG
25 |
26 | Ostructer::OsBase.logger = logger
27 |
28 | @doc = @doc.to_openstruct
29 |
30 | puts "=== ostructer:"
31 | pp @doc
32 | end
33 |
34 | def test_readers
35 | assert_equal( 'home', @doc.customer.address[0].typ.to_s ) # attribute
36 | assert_equal( 'Joe', @doc.customer.first_name.to_s )
37 | end
38 |
39 |
40 | end # class TestCustomerJson
--------------------------------------------------------------------------------
/ostructer/test/test_misc.rb:
--------------------------------------------------------------------------------
1 | require 'logger'
2 | require 'pp'
3 |
4 | require 'rubygems'
5 | require 'xmlsimple'
6 |
7 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
8 | # $LOAD_PATH.unshift(LIB_PATH)
9 |
10 | require 'lib/ostructer.rb'
11 |
12 |
13 | def test_keep_root
14 | fn = 'test/config.xml'
15 | opts = { 'ContentKey' => 'text',
16 | 'ForceArray' => false,
17 | 'ForceContent' => true,
18 | 'KeepRoot' => true }
19 |
20 | doc = XmlSimple.xml_in( fn, opts )
21 |
22 | puts "=== xmlsimple:"
23 | pp doc
24 | end
25 |
26 | def test_parse_status
27 | fn = 'test/status.xml'
28 | opts = { 'ContentKey' => 'text',
29 | 'ForceArray' => false }
30 |
31 | statuses = XmlSimple.xml_in( fn, opts )
32 |
33 | puts "=== xmlsimple:"
34 | pp statuses
35 |
36 | statuses = statuses.to_openstruct
37 | puts "=== ostructer:"
38 | pp statuses
39 | end
40 |
41 | if __FILE__ == $0
42 | # test_keep_root()
43 | test_parse_status()
44 | end
45 |
--------------------------------------------------------------------------------
/hybook/ALTERNATIVES.md:
--------------------------------------------------------------------------------
1 | ## Alternatives
2 |
3 | ### EPUB, MOBI (Kindle) Book Generator
4 |
5 | #### Ruby
6 |
7 | - [kitabu gem](https://github.com/fnando/kitabu) - EPUB, MOBI, PDF
8 | - [bookshop gem](https://github.com/blueheadpublishing/bookshop) - EPUB, MOBI, PDF
9 | - [eeepub, eeepub-with-cover-support ](https://github.com/jugyo/eeepub) - by jugyo
10 | - [git-scribe](https://github.com/schacon/git-scribe) - by Scott Chacon (aka schacon)
11 | - [review](https://github.com/kmuto/review) - by Kenshi Muto (aka kmuto)
12 | - [gepub](https://github.com/skoji/gepub) - by Satoshi Kojima (aka skoji)
13 | - [peregrin](https://github.com/joseph/peregrin) - by Joseph Pearson
14 |
15 |
17 |
18 | - [bookie gem](https://github.com/sandal/bookie) - by Gregory Brown (aka sandal); experimental
19 | - [penny](https://github.com/peterc/penny) - by Peter Cooper (aka peterc); experimental
20 | - [eeepub3](https://github.com/bubaz/eeepub3) - by Sergey (aka bubaz)
21 |
22 |
23 | #### Haskell
24 |
25 | - [Pandoc](http://johnmacfarlane.net/pandoc)
26 |
27 |
28 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/config.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 |
5 | class Config
6 |
7 | def initialize( hash )
8 | @hash = hash
9 |
10 | ### add source_url e.g. https://github.com ?? - why, why not???
11 |
12 | @build_dir = hash[:build_dir] || './build' ## note: defaults to ./build
13 | @setup = hash[:setup]
14 | end
15 |
16 | def build_dir() @build_dir; end
17 | def setup() @setup; end ## e.g. at, franken, worldcup, etc.
18 |
19 | ######
20 | # Datafile
21 | # -- local
22 | def datafile_dir() "#{build_dir}/#{collection}/#{setup}"; end
23 | def datafile_path() "#{datafile_dir}/Datafile"; end
24 |
25 | ######
26 | # Bookfile -- allow multiple (more than one) bookfiles - how? why, why not???
27 | # -- local
28 | #
29 | # todo: move bookfile_dir to unzip dir (e.g. move Bookfile into /book) - why, why not???
30 | def bookfile_dir() "#{build_dir}/#{collection}/#{setup}"; end
31 | def bookfile_path() "#{bookfile_dir}/Bookfile"; end
32 | end
33 |
34 | end # module Bookman
35 |
36 |
--------------------------------------------------------------------------------
/bookfile/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/bookfile/version.rb'
3 |
4 | Hoe.spec 'bookfile' do
5 |
6 | self.version = Bookfile::VERSION
7 |
8 | self.summary = 'bookfile - builder for books'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/hybook/bookfile']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'webslideshow@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.licenses = ['Public Domain']
21 |
22 | self.extra_deps = [
23 | ['props'], # settings / prop(ertie)s / env / INI
24 | ['logutils'], # logging
25 | ['textutils'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
26 | ['fetcher'], ## todo: check if included in ??
27 | ['rubyzip'], ## todo: check if included in ??
28 | ['hybook'], ## include props,logutils,textutils ?? already included w/ hybook ??
29 | ]
30 |
31 | self.spec_extras = {
32 | required_ruby_version: '>= 1.9.2'
33 | }
34 |
35 | end
36 |
37 |
--------------------------------------------------------------------------------
/rubycat/test/test_rubygems.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_rubygems.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 |
12 | class TestRubyGems < MiniTest::Test
13 |
14 | def test_ruby
15 |
16 | r = CatalogDb::CardReader.from_file( "#{RubyCat.root}/test/data/RUBY.md" )
17 | cards = r.read
18 |
19 | pp cards
20 |
21 | c = cards[0]
22 |
23 | assert_equal [["Rack HQ", "http://rack.github.io"],
24 | [":octocat:", "https://github.com/rack"],
25 | [":gem:", "https://rubygems.org/gems/rack"],
26 | [":book:", "http://rubydoc.info/gems/rack"]], c.links
27 |
28 | assert_equal 'Webframeworks › Rack', c.categories
29 |
30 | cat = RubyCat::Catalog.new
31 | cat.add( cards )
32 | cat.render
33 |
34 | ## try sync w/ RubyGemsService/API
35 | cat.sync( limit: 2 ) ## only sync first three recs
36 | ## cat.sync
37 |
38 | cat.render ## dump w/ new (updated) values
39 |
40 | assert true # if we get here - test success
41 | end
42 |
43 | end # class TestRubyGems
44 |
--------------------------------------------------------------------------------
/fizzbuzzer/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/fizzbuzzer/version.rb'
3 |
4 | Hoe.spec 'fizzbuzzer' do
5 |
6 | self.version = FizzBuzzer::VERSION
7 |
8 | self.summary = "fizzbuzzer - 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, ... - a collection of algorithms for playing the word game for children that teaches division (one of the four basic arithmetic operations in mathematics) or helps you find the world's best coders in programming job interviews - are you (re)using the fizzbuzzer library? ;-) - don't reinvent the wheel or the feedbuzzer!"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/rubylibs/fizzbuzzer']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ['noaidi'],
22 | ['dry-matcher']
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 2.3'
29 | }
30 |
31 | end
32 |
--------------------------------------------------------------------------------
/officetxt/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/officetxt/version.rb'
3 |
4 | Hoe.spec 'officetxt' do
5 |
6 | self.version = Officetxt::VERSION
7 |
8 | self.summary = "officetxt (Office.TXT) - the free writer's command line tool suite"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/officetxt/officetxt']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ['journaltxt'],
22 | ['jekyll'],
23 | ['jekyll-import'],
24 | ['jekyll-avatar'],
25 | ['jekyll-octopod'],
26 | ['jekyll-planet'],
27 | ['mrhyde-tools'],
28 | ['drjekyll'],
29 | ['slideshow'],
30 | ['pluto'],
31 | ['rouge'],
32 | ['kramdown'],
33 | ['word-to-markdown'],
34 | ['quik']
35 | ]
36 |
37 | self.licenses = ['Public Domain']
38 |
39 | self.spec_extras = {
40 | required_ruby_version: '>= 1.9.2'
41 | }
42 | end
43 |
--------------------------------------------------------------------------------
/catalogdb/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/catalogdb/version.rb'
3 |
4 | Hoe.spec 'catalogdb' do
5 |
6 | self.version = CatalogDb::VERSION
7 |
8 | self.summary = "catalogdb - catalog.db schema 'n' models for easy (re)use"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/textkit/catalog.db']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ['props', '>= 1.1.2'], # settings / prop(ertie)s / env / INI
22 | ['logutils', '>= 0.6.1'], # logging
23 | ['textutils', '>= 1.3.1'],
24 |
25 | ## 3rd party
26 | ['activerecord'], # NB: will include activesupport,etc.
27 |
28 | ## more activerecord utils/addons
29 | ## ['tagutils', '>= 0.3.0'], # tags n categories for activerecord
30 | ## ['activerecord-utils', '>= 0.4.0'],
31 | ['props-activerecord', '>= 0.1.0'],
32 | ['logutils-activerecord', '>= 0.2.1'],
33 | ]
34 |
35 | self.licenses = ['Public Domain']
36 |
37 | self.spec_extras = {
38 | required_ruby_version: '>= 1.9.2'
39 | }
40 |
41 | end
42 |
--------------------------------------------------------------------------------
/rubycat/lib/rubycat/catalog.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module RubyCat
4 |
5 |
6 | class Catalog
7 |
8 | attr_reader :cards
9 |
10 | def initialize
11 | @cards = []
12 | end
13 |
14 | def add( cards )
15 | @cards += cards.map { |card| Card.new(card) } ## convert to RubyCat card
16 | end
17 |
18 | def sync( opts={} ) ## change name to populate/autofill, etc. ??
19 | ## get (extra) data from rubygems via api
20 |
21 | gems = RubyGemsService.new
22 |
23 | @cards.each_with_index do |card,i|
24 |
25 | if card.gem_url
26 | json = gems.info( card.name )
27 | pp json
28 |
29 | card.sync_gems_info( json )
30 | end
31 |
32 | pp card
33 |
34 | ### for debugging/testing; stop after processing x (e.g. 2) recs
35 | break if opts[:limit] && i >= opts[:limit].to_i ## e.g. i > 2 etc.
36 | end
37 | end # method sync
38 |
39 |
40 | def render
41 | ## render to json
42 | puts "--snip--"
43 |
44 | ary = []
45 |
46 | @cards.each do |card|
47 | h = card.to_hash
48 | ## pp h
49 | ary << h
50 | end
51 |
52 | puts "--snip--"
53 | puts JSON.pretty_generate( ary )
54 | end
55 |
56 | end ## class Catalog
57 |
58 |
59 | end # module RubyCat
60 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/beer.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 |
5 | class BeerConfig < Config
6 |
7 | def initialize( hash ) super; end
8 |
9 | def collection() 'beer'; end
10 |
11 | ############
12 | # Bookfile
13 | # -- remote
14 | def bookfile_url()
15 | ## note: for now always return beer.rb
16 | ## use setup/layout-specific bookfiles?? allow selection of package,how?? why,why not??
17 | "http://github.com/book-templates/bookfile/raw/master/beer.rb"
18 | end
19 |
20 | ########
21 | # Datafile
22 | # -- remote
23 | def datafile_url() "http://github.com/openbeer/datafile/raw/master/#{setup}.rb"; end
24 |
25 | #######
26 | # Database
27 | def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
28 | def create_db!() BeerDb.create_all; end
29 |
30 | ####
31 | # Book Templates
32 | ## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
33 | def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
34 |
35 | end # class BeerConfig
36 |
37 |
38 | class Bookman
39 | def self.create_beer_book_for( setup, opts={} )
40 | config = BeerConfig.new( setup: setup )
41 | Bookman.new( config )
42 | end
43 | end # class Bookman
44 |
45 | end # module Bookman
46 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/world.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 |
5 | class WorldConfig < Config
6 |
7 | def initialize( hash ) super; end
8 |
9 | def collection() 'world'; end
10 |
11 | ############
12 | # Bookfile
13 | # -- remote
14 | def bookfile_url()
15 | ## note: for now always return world.rb
16 | ## use country specific bookfiles ?? allow selection of package,how?? why,why not??
17 | "https://github.com/book-templates/bookfile/raw/master/world.rb"
18 | end
19 |
20 | ########
21 | # Datafile
22 | # -- remote
23 | def datafile_url() "https://github.com/openmundi/datafile/raw/master/#{setup}.rb"; end
24 |
25 | #######
26 | # Database
27 | def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
28 | def create_db!() WorldDb.create_all; end
29 |
30 |
31 | ######################
32 | ## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
33 | def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
34 |
35 | end # class WorldConfig
36 |
37 |
38 | class Bookman
39 | def self.create_world_book_for( setup, opts={} )
40 | config = WorldConfig.new( setup: setup )
41 | Bookman.new( config )
42 | end
43 | end # class Bookman
44 |
45 | end # module Bookman
46 |
--------------------------------------------------------------------------------
/fotos/lib/fotos/reports/stats.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Fotos
4 |
5 | class StatsReport
6 |
7 | def initialize( folder )
8 | @folder = folder
9 | end
10 |
11 | def render
12 | @buf = ''
13 | walk( @folder )
14 | @buf.dup # return a duplicate
15 | end # method render
16 |
17 | private
18 | def walk( folder )
19 | puts "walking >#{folder.name}< (#{folder.folders.size}) level #{folder.level}..."
20 |
21 | @buf << "#{'#'*folder.level} #{folder.name}"
22 | @buf << " (#{folder.folders.size})" if folder.folders.size > 0
23 | @buf << "\n"
24 | @buf << "\n"
25 |
26 | if folder.folders.size > 0
27 | subfolder_names = folder.folders.map { |item| item.name }
28 | @buf << subfolder_names.join( ' . ' )
29 | @buf << "\n"
30 | @buf << "\n"
31 | end
32 |
33 | ## group fotos by file extension
34 | fotos_by_ext = folder.fotos.group_by { |foto| File.extname( foto.name.downcase ) }
35 | fotos_by_ext_stats = ''
36 | fotos_by_ext.each do |k,v|
37 | fotos_by_ext_stats << "#{k} (#{v.size}) "
38 | end
39 |
40 | @buf << "#{folder.fotos.size} Fotos - #{fotos_by_ext_stats}"
41 | @buf << "\n"
42 | @buf << "\n"
43 |
44 | folder.folders.each do |subfolder|
45 | walk( subfolder )
46 | end
47 | end # method walk
48 |
49 | end # class StatsReport
50 |
51 |
52 | end # module Fotos
53 |
54 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/football.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 |
5 | class FootballConfig < Config
6 |
7 | def initialize( hash ) super; end
8 |
9 | def collection() 'football'; end
10 |
11 | ############
12 | # Bookfile
13 | # -- remote
14 | def bookfile_url()
15 | ## note: for now always return football.rb
16 | ## use setup/layout-specific bookfiles?? allow selection of package,how?? why,why not??
17 | "http://github.com/book-templates/bookfile/raw/master/football.rb"
18 | end
19 |
20 | ########
21 | # Datafile
22 | # -- remote
23 | def datafile_url() "http://github.com/openfootball/datafile/raw/master/#{setup}.rb"; end
24 |
25 | #######
26 | # Database
27 | def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
28 |
29 | def create_db!()
30 | SportDb.create_all
31 | SportDb.read_builtin ## note: load built-in datasets (e.g. seasons etc.)
32 | end
33 |
34 | ####
35 | # Book Templates
36 | ## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
37 | def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
38 |
39 | end # class FootballConfig
40 |
41 |
42 | class Bookman
43 | def self.create_football_book_for( setup, opts={} )
44 | config = FootballConfig.new( setup: setup )
45 | Bookman.new( config )
46 | end
47 | end # class Bookman
48 |
49 | end # module Bookman
50 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/builder.rb:
--------------------------------------------------------------------------------
1 | #encoding: utf-8
2 |
3 |
4 | module Bookfile
5 |
6 | class Builder
7 |
8 | include LogUtils::Logging
9 |
10 | def self.load_file( path )
11 | code = File.read_utf8( path )
12 | self.load( code )
13 | end
14 |
15 | def self.load( code )
16 | builder = Builder.new
17 | builder.instance_eval( code )
18 | builder
19 | end
20 |
21 |
22 | attr_reader :bookfile
23 |
24 | def initialize
25 | puts "starting new bookfile; lets go"
26 | @bookfile = Bookfile.new
27 | end
28 |
29 |
30 | def package( name, opts={} )
31 | puts "package '#{name}'"
32 | @bookfile.packages << BookPackage.new( name, opts )
33 | end
34 |
35 | ###########################
36 | ## database options
37 | def world( opts={} )
38 | puts "world opts: #{opts.inspect}"
39 | @bookfile.databases << WorldDef.new( opts )
40 | end
41 |
42 | def beer( opts={} )
43 | puts "beer opts: #{opts.inspect}"
44 | ## todo: to avoid name class use BeerDef, WorldDef ?? etc.
45 | @bookfile.databases << BeerDef.new( opts )
46 | end
47 |
48 | def football( opts={} )
49 | puts "football opts: #{opts.inspect}"
50 | @bookfile.databases << FootballDef.new( opts )
51 | end
52 |
53 |
54 |
55 | def book( opts={}, &block )
56 | puts "book opts: #{opts.inspect}"
57 | @bookfile.books << BookDef.new( opts, block )
58 | end
59 |
60 | end # class Builder
61 |
62 | end # module Bookfile
63 |
64 |
--------------------------------------------------------------------------------
/ostructer/test/test_mapper.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'xmlsimple'
7 |
8 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
9 | # $LOAD_PATH.unshift(LIB_PATH)
10 |
11 | require 'lib/ostructer.rb'
12 |
13 | ## NB: XmlSimple -> ForceArray is true by default (turn it off!!)
14 | ##
15 |
16 | class TestMapper < Test::Unit::TestCase
17 |
18 | def setup
19 | fn = 'test/customer.xml'
20 | opts = { 'ContentKey' => 'text',
21 | 'ForceArray' => false,
22 | 'ForceContent' => true }
23 |
24 | @customer = XmlSimple.xml_in( fn, opts )
25 |
26 | puts "=== xmlsimple:"
27 | pp @customer
28 |
29 | logger = Logger.new(STDOUT)
30 | logger.level = Logger::DEBUG
31 |
32 | Ostructer::OsBase.logger = logger
33 |
34 | mapper = Proc.new do |key|
35 | ## puts "calling mapper('#{key}')"
36 | key = 'fn' if key == 'first_name'
37 | key = 'zip' if key == 'zip_code'
38 | key
39 | end
40 |
41 | @customer = @customer.to_openstruct( :mapper => mapper )
42 |
43 | # puts "=== ostructer:"
44 | # pp @customer
45 | end
46 |
47 | def test_readers
48 | assert_equal( 'home', @customer.address[0].typ.to_s ) # attribute
49 | assert_equal( 'Joe', @customer.fn.text.to_s )
50 | assert_equal( 'Joe', @customer.fn.to_s ) # short-cut (.text)
51 | assert_equal( 11234, @customer.address[0].zip.to_i )
52 | end
53 |
54 | end # class TestCustomer
55 |
56 |
--------------------------------------------------------------------------------
/record/lib/record/builder.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ## (record) builder mini language / domain-specific language (dsl)
4 |
5 | module Record
6 |
7 | class Builder # check: rename to RecordDefinition or RecordDsl or similar - why? why not?
8 |
9 | ###################################
10 | ## add simple logger with debug flag/switch
11 | #
12 | # use Parser.debug = true # to turn on
13 | #
14 | # todo/fix: use logutils instead of std logger - why? why not?
15 |
16 | def self.build_logger()
17 | l = Logger.new( STDOUT )
18 | l.level = :info ## set to :info on start; note: is 0 (debug) by default
19 | l
20 | end
21 | def self.logger() @@logger ||= build_logger; end
22 | def logger() self.class.logger; end
23 |
24 |
25 |
26 | def initialize( super_class=Base )
27 | @clazz = Class.new( super_class )
28 | end
29 |
30 | def field( name, type=:string ) ## note: type defaults to string
31 | logger.debug " adding field >#{name}< with type >#{type}<"
32 | @clazz.field( name, type ) ## auto-add getter and setter
33 | end
34 |
35 | def string( name )
36 | logger.debug " adding string field >#{name}<"
37 | field( name, :string )
38 | end
39 |
40 | def integer( name ) ## use number for alias for integer - why? why not???
41 | logger.debug " adding integer number field >#{name}<"
42 | field( name, :integer )
43 | end
44 |
45 | def float( name )
46 | logger.debug " adding float number field >#{name}<"
47 | field( name, :float )
48 | end
49 |
50 |
51 | def to_record ## check: rename to just record or obj or finish or end something?
52 | @clazz
53 | end
54 | end # class Builder
55 | end # module Record
56 |
--------------------------------------------------------------------------------
/ostructer/test/test_status_xml.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'xmlsimple'
7 |
8 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
9 | # $LOAD_PATH.unshift(LIB_PATH)
10 |
11 | require 'lib/ostructer.rb'
12 |
13 |
14 | class TestStatusXml < Test::Unit::TestCase
15 |
16 | def setup
17 | fn = 'test/status.xml'
18 | opts = { 'ContentKey' => 'text',
19 | 'ForceArray' => [ 'status'] }
20 |
21 | @doc = XmlSimple.xml_in( fn, opts )
22 |
23 | logger = Logger.new(STDOUT)
24 | logger.level = Logger::DEBUG
25 |
26 | Ostructer::OsBase.logger = logger
27 |
28 | @doc = @doc.to_openstruct
29 |
30 | puts "=== ostructer:"
31 | pp @doc
32 | end
33 |
34 | def test_readers
35 | assert_equal( 'Sat Aug 09 05:38:12 +0000 2008', @doc.status[0].created_at.to_s )
36 | assert_equal( false, @doc.status[0].truncated.to_bool )
37 | assert_equal( 'John Nunemaker', @doc.status[0].user.name.to_s )
38 | assert_equal( 486, @doc.status[0].user.followers_count.to_i )
39 | end
40 |
41 | def test_full_dot_path
42 | assert_equal( 'status[0].created_at', @doc.status[0].created_at.full_dot_path )
43 | assert_equal( 'status[0].truncated', @doc.status[0].truncated.full_dot_path )
44 | assert_equal( 'status[0].user.name', @doc.status[0].user.name.full_dot_path )
45 | assert_equal( 'status[0].user.followers_count', @doc.status[0].user.followers_count.full_dot_path )
46 | end
47 |
48 | def test_missing
49 | assert_equal( '!one.!two.!three', @doc.one.two.three.full_dot_path )
50 | end
51 |
52 | end # class TestStatusXml
--------------------------------------------------------------------------------
/ostructer/test/test_customer_xml.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'xmlsimple'
7 |
8 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
9 | # $LOAD_PATH.unshift(LIB_PATH)
10 |
11 | require 'lib/ostructer.rb'
12 |
13 | ## NB: XmlSimple -> ForceArray is true by default (turn it off!!)
14 | ##
15 |
16 | class TestCustomerXml < Test::Unit::TestCase
17 |
18 | def setup
19 | fn = 'test/customer.xml'
20 | opts = { 'ContentKey' => 'text',
21 | 'ForceArray' => false,
22 | 'ForceContent' => true }
23 |
24 | @customer = XmlSimple.xml_in( fn, opts )
25 |
26 | puts "=== xmlsimple:"
27 | pp @customer
28 |
29 | logger = Logger.new(STDOUT)
30 | logger.level = Logger::DEBUG
31 |
32 | Ostructer::OsBase.logger = logger
33 |
34 | @customer = @customer.to_openstruct
35 |
36 | puts "=== ostructer:"
37 | pp @customer
38 | end
39 |
40 | def test_readers
41 | assert_equal( 'home', @customer.address[0].typ.to_s ) # attribute
42 | assert_equal( 'Joe', @customer.first_name.text.to_s )
43 | assert_equal( 'Joe', @customer.first_name.to_s ) # short-cut (.text)
44 | end
45 |
46 |
47 | end # class TestCustomer
48 |
49 |
50 | ## from the XmlSimple docs
51 | #
52 | # Elements which only contain text content will simply be represented as a scalar.
53 | # Where an element has both attributes and text content, the element will be represented
54 | # as a hash with the text content in the 'content' key:
55 | #
56 | #
57 | # first
58 | # second
59 | #
60 | #
61 | # {
62 | # 'one' => 'first',
63 | # 'two' => { 'attr' => 'value', 'content' => 'second' }
64 | # }
65 | #
--------------------------------------------------------------------------------
/hybook/lib/hybook/type/album.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Hybook
4 |
5 |
6 | class Album
7 | attr_accessor :title
8 | attr_accessor :sections
9 |
10 | def initialize( title )
11 | @title = title
12 | @sections = [] # sections (for pictures)
13 | end
14 |
15 |
16 | ###
17 | ## fix: move to album builder
18 |
19 |
20 | def self.create_from_folder( root, opts={} )
21 | dirs = Dir[ "#{root}/**/" ] ## get all folders n subfolder
22 | ## pp dirs
23 |
24 | title = opts[:title ] || 'Untitled'
25 |
26 | album = Album.new( title )
27 |
28 | dirs.each do |dir|
29 | section_title = dir[ root.length+1..-2 ] # cut off ROOT_DIR plus leading and trailing /
30 | files = Dir[ "#{dir}/*.{png,gif,jpg}" ]
31 |
32 | ## fix: use logger
33 | puts "dir: #{dir}, title: #{section_title}, files: #{files.size}"
34 | next if files.size == 0 # skip if no image files in folder
35 |
36 | section = Section.new( section_title )
37 | album.sections << section
38 |
39 | ## puts "files:"
40 | ## pp files
41 |
42 | files.each do |filename|
43 | extname = File.extname( filename )
44 | basename = File.basename( filename, extname ) # NB: remove extname (that is, suffix e.g. .png,.jpg,.gif etc.)
45 |
46 | picture_title = basename # use basename
47 | picture_path = filename # TODO/FIX: strip off leading root path ?? why? why not???
48 | ### rename path to source or src or file or filename - why? why not??
49 |
50 |
51 | picture = Picture.new( picture_title, picture_path )
52 | section.pictures << picture
53 | end
54 | end
55 | album # return album struct
56 | end
57 |
58 |
59 | end # class Album
60 |
61 |
62 | end # module Hybook
63 |
--------------------------------------------------------------------------------
/fizzbuzzer/test/test_driven.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_driven.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | describe FizzBuzz do
12 |
13 | include FizzBuzzer::V11b ## add (include) fizzbuzz method using algorithm V11
14 |
15 | describe "number is divisible" do
16 | it "divisible by" do
17 | divisible_by?(15,3).must_equal true
18 | end
19 | it "divisible by 3" do
20 | divisible_by_3?(15).must_equal true
21 | end
22 | it "divisible by 5" do
23 | divisible_by_5?(15).must_equal true
24 | end
25 | end
26 |
27 | describe "number is fizzbuzz" do
28 | before do ## optimize? use before(:all) - why? why not?
29 | @result = fizzbuzz
30 | end
31 |
32 | it "returns 'Fizz' for multiples of 3" do
33 | @result[3-1].must_equal "Fizz"
34 | end
35 |
36 | it "returns 'Buzz' for multiples of 5" do
37 | @result[5-1].must_equal "Buzz"
38 | end
39 |
40 | it "returns 'FizzBuzz' for multiples of 3 and 5" do
41 | @result[15-1].must_equal "FizzBuzz"
42 | end
43 |
44 | it "returns the passed number if not a multiple of 3 or 5" do
45 | @result[1-1].must_equal 1
46 | end
47 | end
48 | end
49 |
50 |
51 |
52 | class TestFizzBuzz < Minitest::Test
53 |
54 | include FizzBuzzer::V11a ## add (include) fizzbuzz method using algorithm V11
55 |
56 | def setup
57 | @result = fizzbuzz
58 | end
59 |
60 | def test_fizz_multiples_of_3
61 | assert_equal "Fizz", @result[3-1]
62 | end
63 |
64 | def test_buzz_for_multiples_of_5
65 | assert_equal "Buzz", @result[5-1]
66 | end
67 |
68 | def test_fizzbuzz_for_multiples_of_3_and_5
69 | assert_equal "FizzBuzz", @result[15-1]
70 | end
71 |
72 | def test_number_if_not_multiple_of_3_or_5
73 | assert_equal 1, @result[1-1]
74 | end
75 | end
76 |
--------------------------------------------------------------------------------
/fotos/lib/fotos/builder.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Fotos
4 |
5 | ##
6 | ## check: .picasaoriginals ???
7 | ## walking >/franzzz/bilder/RolleFamilie< level 2...
8 | ## walking >/franzzz/bilder/RolleFamilie/.picasaoriginals< level 3...
9 |
10 |
11 | class Folder
12 |
13 | attr_reader :name, :level, :parent
14 | attr_accessor :folders
15 | attr_accessor :fotos
16 |
17 | def initialize( name, parent: nil, level: 1 )
18 | @name = name
19 | @level = level
20 | @parent = parent
21 | @folders = []
22 | @fotos = []
23 | end
24 | end
25 |
26 | class Foto
27 |
28 | attr_reader :name, :folder
29 |
30 | def initialize( name, folder: nil )
31 | @name = name
32 | @folder = folder
33 | end
34 | end
35 |
36 |
37 | class LibraryBuilder
38 |
39 | def initialize( root_dir )
40 | @root_dir = root_dir
41 | end
42 |
43 | def build
44 | walk( @root_dir, nil, 1 )
45 | end
46 |
47 | private
48 | def walk( dir, parent, level )
49 | puts "walking >#{dir}< level #{level}..."
50 |
51 | basename = File.basename( dir ) ## todo: add extension - why? why not?
52 | folder = Folder.new( basename, parent: parent, level: level )
53 |
54 | if parent
55 | parent.folders << folder
56 | end
57 |
58 |
59 | files = Dir.entries( dir )
60 | ## pp files
61 | files.each do |file|
62 | next if ['..', '.'].include?( file ) ## skip .. n .
63 |
64 | path = "#{dir}/#{file}"
65 | if File.directory?( path )
66 | walk( path, folder, level+1 )
67 | else
68 | ## assume it's a foto for now
69 | foto = Foto.new( file, folder: folder )
70 | folder.fotos << foto
71 | end
72 | end
73 |
74 | folder ## return folder
75 | end # method build
76 |
77 | end # class LibraryBuilder
78 |
79 | end # module Fotos
80 |
--------------------------------------------------------------------------------
/fizzbuzzer/test/test_fizzbuzz.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_fizzbuzz.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | FIZZBUZZES_1_TO_100 =
12 | [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14,
13 | "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26,
14 | "Fizz", 28, 29, "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38,
15 | "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, "Fizz", 49, "Buzz",
16 | "Fizz", 52, 53, "Fizz", "Buzz", 56, "Fizz", 58, 59, "FizzBuzz", 61, 62,
17 | "Fizz", 64, "Buzz", "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74,
18 | "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, "Fizz", "Buzz", 86,
19 | "Fizz", 88, 89, "FizzBuzz", 91, 92, "Fizz", 94, "Buzz", "Fizz", 97, 98,
20 | "Fizz", "Buzz"]
21 |
22 |
23 |
24 | class TestV1 < MiniTest::Test
25 |
26 | include FizzBuzzer::V1 ## add (include) fizzbuzz method using algorithm V1
27 |
28 | def test_fizzbuzz
29 | assert_equal FIZZBUZZES_1_TO_100, fizzbuzz
30 | end
31 | end # class TestV1
32 |
33 |
34 |
35 | module FizzBuzz
36 |
37 | ## auto-generate test classes (see model/sample above)
38 | def self.test_class_for( m )
39 | Class.new( MiniTest::Test ) do
40 | include m
41 | define_method :test_fizzbuzz do
42 | puts "testing #{m.name}..."
43 | assert_equal FIZZBUZZES_1_TO_100, fizzbuzz
44 | end
45 | end
46 | end
47 |
48 | ALGOS = [ V1, V2a, V2b, V2c, V2d, V3, V4, V5,
49 | V6a, V6b, V7, V8, V9, V10, V11a, V11b, V12a, V12b, V13,
50 | Golf::V1, Golf::V2, Golf::V3, Golf::V4, Golf::V5, Golf::V6, Golf::V7 ]
51 |
52 | def self.build_tests
53 | puts " auto-adding (building) test classes..."
54 | ALGOS.each do |algo|
55 | puts " adding #{algo.name}..."
56 | test_class_for( algo )
57 | end
58 | end
59 | end
60 |
61 |
62 | FizzBuzz.build_tests
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # more tools, libraries & scripts
2 |
3 | Gems:
4 |
5 | - [record](record) - named tuples / records with typed structs / schemas
6 | - [typeconv](typeconv) - type converters library / gem - convert strings to numbers, dates, booleans, nulls and more
7 | - [ostructer](ostructer) - open struct builder
8 |
9 |
10 | - [almost-sinatra](almost-sinatra) - six lines of almost sinatra refactored and bundled up for easy (re)use - build your own webframework from scratch with rack and tilt
11 | - [fizzbuzzer](fizzbuzzer) - 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, ... - a collection of algorithms for playing the word game for children that teaches division e.g. 7/3=? (one of the four basic arithmetic operations in mathematics) or helps you find the world's best coders in programming job interviews - are you (re)using the fizzbuzzer library? ;-) - don't reinvent the wheel or the feedbuzzer!
12 |
13 |
14 |
15 | - [about](about) - sys info (system information) about your computer, environment, runtime, libs, etc as mountable web app
16 |
17 |
18 |
19 |
20 | - [gutenberg](gutenberg) - the printing press for books (reinvented in ruby)
21 | - [fotos](fotos) - manage fotos on the command line
22 | - [preproc](preproc) - simple preprocessor (lets you include files in files in files etc.)
23 |
24 |
25 |
26 | - [catalogdb](catalogdb) - catalog.db schema 'n' models for easy (re)use
27 | - [rubycat](rubycat) - ruby (library) catalog (cards) command line tool (using the catalog.db machinery)
28 |
29 |
30 | Hyper Book (H9) Gems - A Free Hypertext Book Generator in Ruby
31 |
32 | - [hybook](hybook) - hypertext book generator
33 | - [bookman](bookman) - yet another book builder
34 | - [bookfile](bookfile) - builder for books
35 |
36 |
37 |
38 | ## License
39 |
40 | The scripts are dedicated to the public domain.
41 | Use it as you please with no restrictions whatsoever.
42 |
43 |
--------------------------------------------------------------------------------
/ostructer/test/test_config_json.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'active_support'
7 |
8 |
9 |
10 |
11 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
12 | # $LOAD_PATH.unshift(LIB_PATH)
13 |
14 | require 'lib/ostructer.rb'
15 |
16 |
17 | class TestConfigJson < Test::Unit::TestCase
18 |
19 | def setup
20 | fn = 'test/config.json'
21 |
22 | @doc = ActiveSupport::JSON.decode( File.read( fn ) )
23 |
24 | logger = Logger.new(STDOUT)
25 | logger.level = Logger::DEBUG
26 |
27 | Ostructer::OsBase.logger = logger
28 |
29 | @doc = @doc.to_openstruct
30 |
31 | puts "=== ostructer:"
32 | pp @doc
33 | end
34 |
35 | def test_readers
36 | assert_equal( 'sahara', @doc.config.server[0].name.to_s ) # attribute
37 | assert_equal( '10.0.0.101', @doc.config.server[0].address[0].to_s )
38 | assert( '.text shortcut String <=>', @doc.config.server[0].address[0] == '10.0.0.101' )
39 | end
40 |
41 | def test_full_dot_path
42 | assert_equal( 'config.logdir', @doc.config.logdir.full_dot_path )
43 | assert_equal( 'config.server', @doc.config.server.full_dot_path )
44 | assert_equal( 'config.server[0]', @doc.config.server[0].full_dot_path )
45 | assert_equal( 'config.server[0].name', @doc.config.server[0].name.full_dot_path )
46 | assert_equal( 'config.server[0].address', @doc.config.server[0].address.full_dot_path )
47 | assert_equal( 'config.server[0].address[0]', @doc.config.server[0].address[0].full_dot_path )
48 | end
49 |
50 | def test_missing
51 | assert_equal( '!one.!two.!three', @doc.one.two.three.full_dot_path )
52 | end
53 |
54 | def test_read_only
55 | assert_raises( NoMethodError ) { @doc.config.server[0].name = 'gobi' } # write access existing field
56 | assert_raises( NoMethodError ) { @doc.config.one.two.three = 'missing' } # write access missing field
57 | end
58 |
59 | end # class TestConfig
60 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/std/album.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Hybook
4 | module AlbumHelper
5 |
6 | def render_pictures( pics, opts )
7 | buf = ''
8 |
9 | ### sort by title for now
10 | pics.sort { |l,r| l.title <=> r.title }.each_with_index do |pic,i|
11 | buf << ' • ' if i > 0
12 | buf << render_picture( pic, opts )
13 | end
14 |
15 | buf
16 | end
17 |
18 |
19 | def render_picture( pic, opts )
20 |
21 | size = opts[:size]
22 | assets_path = opts[:assets_path] || 'vendor/assets/images/logos'
23 |
24 | ## puts "[picture] size=#{size}" # NOTE: opts[:size] required for now!!!
25 | ## puts "[picture] assets_path=#{assets_path}"
26 | ##
27 | ## puts "opts:"
28 | ## pp opts
29 |
30 | extname = File.extname( pic.path )
31 | basename_in = File.basename( pic.path, extname ) # NB: remove extname (that is, suffix e.g. .png,.jpg,.gif etc.)
32 |
33 | # strip leading 1-west- (optional for organizing logos)
34 | # e.g. 3-west-austrias becomes austrias
35 | basename_out = basename_in.gsub( /[0-9a-z]+-/, '' )
36 |
37 | ## puts "path: #{path}, basename_in: #{basename_in}, basename_out: #{basename_out}, extname: #{extname}"
38 |
39 | path = "#{assets_path}/#{size}x#{size}/#{basename_out}.png"
40 |
41 | buf = ''
42 | buf << "_#{pic.title}_{: .key} "
43 | buf << ""
44 | buf
45 | end
46 |
47 | def render_album( album, opts )
48 | ###
49 | ## TODO/FIX:
50 | ## use TextUtils::PageTemplate.read( path ).render( binding ) - one line
51 |
52 | tmpl = File.read_utf8( "#{Hybook.templates_path}/album.md" )
53 | TextUtils::PageTemplate.new( tmpl ).render( binding )
54 | end
55 |
56 | end # module AblumHelper
57 |
58 |
59 | # make helpers available as class methods for now e.g. Hybook.render_album etc.
60 | extend AlbumHelper
61 | end # module Hybook
62 |
--------------------------------------------------------------------------------
/about/lib/about/server.rb:
--------------------------------------------------------------------------------
1 | ######
2 | # NB: use rackup to startup Sinatra service (see config.ru)
3 | #
4 | # e.g. config.ru:
5 | # require './boot'
6 | # run About::Server
7 |
8 |
9 | # 3rd party libs/gems
10 |
11 | require 'sinatra/base'
12 |
13 |
14 | module About
15 |
16 | class Server < Sinatra::Base
17 |
18 | def self.banner
19 | "about #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})"
20 | end
21 |
22 | PUBLIC_FOLDER = "#{About.root}/lib/about/public"
23 | VIEWS_FOLDER = "#{About.root}/lib/about/views"
24 |
25 | puts "[boot] about - setting public folder to: #{PUBLIC_FOLDER}"
26 | puts "[boot] about - setting views folder to: #{VIEWS_FOLDER}"
27 |
28 | set :public_folder, PUBLIC_FOLDER # set up the static dir (with images/js/css inside)
29 | set :views, VIEWS_FOLDER # set up the views dir
30 |
31 | set :static, true # set up static file routing
32 |
33 |
34 | #######################
35 | # Models
36 |
37 | # -- to be done
38 |
39 | #################
40 | # Helpers
41 |
42 | include TextUtils::HypertextHelper # e.g. lets us use link_to, sanitize, etc.
43 |
44 | def path_prefix
45 | request.script_name # request.env['SCRIPT_NAME']
46 | end
47 |
48 | def ruby_path
49 | "#{path_prefix}/ruby"
50 | end
51 |
52 | def rack_path
53 | "#{path_prefix}/rack"
54 | end
55 |
56 | def env_path
57 | "#{path_prefix}/env"
58 | end
59 |
60 | def sinatra_path
61 | "#{path_prefix}/sinatra"
62 | end
63 |
64 | def rails_path
65 | "#{path_prefix}/rails"
66 | end
67 |
68 | def root_path
69 | "#{path_prefix}/"
70 | end
71 |
72 |
73 | ##############################################
74 | # Controllers / Routing / Request Handlers
75 |
76 | ###
77 | ## todo: add page for gems/gem ?? why? why not?
78 |
79 | ## todo: add page for threads/thread list ?? why? why not?
80 |
81 | get '/' do
82 | redirect( ruby_path )
83 | end
84 |
85 | get '/ruby' do
86 | erb :ruby
87 | end
88 |
89 | get '/env' do
90 | erb :env
91 | end
92 |
93 | get '/rack' do
94 | erb :rack
95 | end
96 |
97 | get '/sinatra' do
98 | erb :sinatra
99 | end
100 |
101 | get '/rails' do
102 | erb :rails
103 | end
104 |
105 |
106 | get '/d*' do
107 | erb :debug
108 | end
109 |
110 |
111 | end # class Server
112 | end # module About
113 |
114 |
115 | # say hello
116 | puts About::Server.banner
117 |
--------------------------------------------------------------------------------
/bookfile/test/bookfile/world.rb:
--------------------------------------------------------------------------------
1 |
2 | package 'book-templates/world'
3 | ## use package or templates or theme (instead of ???)
4 | ## will auto-include all helpers etc. from _scripts/ folder (hierachy/tree)
5 |
6 |
7 | world adapter: 'sqlite3', database: './world.db'
8 | ## will connect to database;
9 | ## will require all libs
10 | ## will include all models
11 |
12 |
13 | ## page 'index', title: 'Contents',
14 | ## id: 'index' do |p|
15 | ## p.write render_toc() ## render_toc( opts )
16 | ## ## render :toc -- auto includes opts???
17 | ## end
18 |
19 | =begin
20 | book do |b|
21 |
22 | puts "before first page"
23 |
24 | b.page 'index', title: 'Contents',
25 | id: 'index' do |p|
26 | puts "enter index"
27 | puts "leave index"
28 | end
29 | end
30 | =end
31 |
32 |
33 | #################
34 | # self.class.name (in top level): Bookfile::Builder
35 | # self.class.name (in book block): Bookfile::Builder
36 | # self.class.name (in page block): Bookfile::Builder
37 |
38 | puts "self.class.name (in top level): #{self.class.name}"
39 |
40 |
41 | book do |b|
42 |
43 | ## todo/fix:
44 | ## find a way to pass along opts - why, why not??
45 | opts = {}
46 |
47 | puts "before first page"
48 | puts "self.class.name (in book block): #{self.class.name}"
49 |
50 | b.page 'index', title: 'Contents',
51 | id: 'index' do |page|
52 | puts "enter index"
53 | page.write "render_toc()" ## render_toc() ## render_toc( opts )
54 | page.write "render_toc() 2x"
55 | page.write "render_toc() 3x"
56 |
57 | page.render_toc( opts )
58 | ## render :toc -- auto includes opts???
59 |
60 | puts "self.class.name (in page block): #{self.class.name}"
61 | page.write "continent.count: #{Continent.count}"
62 | puts "leave index"
63 |
64 | puts "continent.count: #{Continent.count}"
65 | end
66 |
67 |
68 | ### generate pages for countries
69 | # note: use same order as table of contents
70 |
71 | Continent.order(:id).each do |continent|
72 | continent.countries.order(:name).limit(1).each do |country|
73 |
74 | puts "build country page #{country.key}..."
75 | path = country.to_path
76 | puts "path=#{path}"
77 |
78 | b.page path, title: "#{country.name} (#{country.code})",
79 | id: country.key do |page|
80 | page.write "render_country(#{country.name})" ## render_country( country ) ## render_country( country, opts )
81 | page.render_country( country, opts ) ### fix: auto-include opts in render - how??
82 | end
83 | end
84 | end
85 | end
86 |
87 |
--------------------------------------------------------------------------------
/bookfile/test/bookfile/football.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | package 'book-templates/football'
4 |
5 |
6 | football adapter: 'sqlite3', database: './football.db'
7 |
8 |
9 |
10 | book do |b|
11 |
12 | opts = {}
13 |
14 | ### generate table of contents (toc)
15 |
16 | b.page( 'index', title: 'Contents',
17 | id: 'index' ) do |page|
18 | page.render_cover( opts )
19 | page.render_about( opts )
20 | page.render_toc( opts )
21 | end
22 |
23 |
24 | # note: use same order as table of contents
25 | event_count = 0
26 | League.order(:id).each do |league|
27 | next if league.events.count == 0
28 |
29 | league.events.each do |event|
30 | puts " build event page [#{event_count+1}] #{event.key} #{event.title}..."
31 |
32 | key = event.key.gsub( '/', '_' )
33 | b.page( "events/#{key}", title: "#{event.title}",
34 | id: "#{key}" ) do |page|
35 | page.render_event( event, opts )
36 | end
37 | ## b.divider() ## -- todo: add for inline version
38 | event_count += 1
39 | end
40 | end
41 |
42 | ## ### generate events index
43 | ## b.page( 'events', title: 'Events',
44 | ## id: 'events' ) do |page|
45 | ## page.render_events( opts )
46 | ## end
47 |
48 |
49 | # note: use same order as table of contents
50 | country_count = 0
51 | Continent.order(:id).each do |continent|
52 | continent.countries.order(:name).each do |country|
53 | next if country.teams.count == 0 # skip country w/o teams
54 |
55 | puts " build country page [#{country_count+1}] #{country.key} #{country.title}..."
56 |
57 | path = country.to_path
58 | puts " path=#{path}"
59 | b.page( "teams/#{path}", title: "#{country.title} (#{country.code})",
60 | id: "#{country.key}" ) do |page|
61 | page.render_country( country, opts )
62 | end
63 |
64 | country_count += 1
65 | end
66 | end
67 |
68 |
69 | b.page( 'stadiums', title: 'Stadiums',
70 | id: 'stadiums' ) do |page|
71 | page.render_grounds( opts )
72 | end
73 |
74 |
75 | ### generate national teams a-z index
76 | b.page( 'national-teams', title: 'National Teams A-Z Index',
77 | id: 'national-teams' ) do |page|
78 | page.render_national_teams_idx( opts )
79 | end
80 |
81 | ### generate teams a-z index
82 | b.page( 'clubs', title: 'Clubs A-Z Index',
83 | id: 'clubs' ) do |page|
84 | page.render_clubs_idx( opts )
85 | end
86 |
87 | b.page( 'back', title: 'Back',
88 | id: 'back' ) do |page|
89 | page.render_back( opts )
90 | end
91 |
92 | end # block book
93 |
94 |
--------------------------------------------------------------------------------
/ostructer/test/test_config_xml.rb:
--------------------------------------------------------------------------------
1 | require 'test/unit'
2 | require 'logger'
3 | require 'pp'
4 |
5 | require 'rubygems'
6 | require 'xmlsimple'
7 |
8 | # LIB_PATH = File.expand_path( File.dirname( 'lib' ) )
9 | # $LOAD_PATH.unshift(LIB_PATH)
10 |
11 | require 'lib/ostructer.rb'
12 |
13 | ## notes:
14 | ## add note about faster_xml_simple (drop-in replacement for xml_in only using libxml)
15 |
16 | ## todo: check if root is simple root if forceArray is true!!
17 |
18 | # NB: ContentKey text only added if at least one attribute present!!
19 | # otherwise value is used-as-is in place (not as a hash)
20 | # use ForceContent => true options to force creation of hash
21 | #
22 | #
23 | #
24 |
25 | class TestConfigXml < Test::Unit::TestCase
26 |
27 | def setup
28 | fn = 'test/config.xml'
29 | opts = { 'ContentKey' => 'text',
30 | 'ForceArray' => ['address'],
31 | 'ForceContent' => true,
32 | 'KeepRoot' => true }
33 |
34 | @doc = XmlSimple.xml_in( fn, opts )
35 |
36 | # puts "=== xmlsimple:"
37 | # pp @doc
38 |
39 | logger = Logger.new(STDOUT)
40 | logger.level = Logger::DEBUG
41 |
42 | Ostructer::OsBase.logger = logger
43 |
44 | @doc = @doc.to_openstruct
45 |
46 | puts "=== ostructer:"
47 | pp @doc
48 | end
49 |
50 | def test_readers
51 | assert_equal( 'sahara', @doc.config.server[0].name.to_s ) # attribute
52 | assert_equal( '10.0.0.101', @doc.config.server[0].address[0].text.to_s ) # contentKey
53 | assert_equal( '10.0.0.101', @doc.config.server[0].address[0].to_s ) # contentKey shortcut (no .text)
54 | assert( '.text shortcut String <=>', @doc.config.server[0].address[0] == '10.0.0.101' )
55 | end
56 |
57 | def test_full_dot_path
58 | assert_equal( 'config.logdir', @doc.config.logdir.full_dot_path )
59 | assert_equal( 'config.server', @doc.config.server.full_dot_path )
60 | assert_equal( 'config.server[0]', @doc.config.server[0].full_dot_path )
61 | assert_equal( 'config.server[0].name', @doc.config.server[0].name.full_dot_path )
62 | assert_equal( 'config.server[0].address', @doc.config.server[0].address.full_dot_path )
63 | assert_equal( 'config.server[0].address[0]', @doc.config.server[0].address[0].full_dot_path )
64 | assert_equal( 'config.server[0].address[0].text', @doc.config.server[0].address[0].text.full_dot_path )
65 | end
66 |
67 | def test_missing
68 | assert_equal( '!one.!two.!three', @doc.one.two.three.full_dot_path )
69 | end
70 |
71 | def test_read_only
72 | assert_raises( NoMethodError ) { @doc.config.server[0].name = 'gobi' } # write access existing field
73 | assert_raises( NoMethodError ) { @doc.config.one.two.three = 'missing' } # write access missing field
74 | end
75 |
76 | end # class TestConfigXml
77 |
--------------------------------------------------------------------------------
/hybook/README.md:
--------------------------------------------------------------------------------
1 | # hybook - Hyper Book (H9)
2 |
3 | hybook gem - hypertext book generator
4 |
5 | * home :: [github.com/hybook/hybook](https://github.com/hybook/hybook)
6 | * bugs :: [github.com/hybook/hybook/issues](https://github.com/hybook/hybook/issues)
7 | * gem :: [rubygems.org/gems/hybook](https://rubygems.org/gems/hybook)
8 | * rdoc :: [rubydoc.info/gems/hybook](http://rubydoc.info/gems/hybook)
9 |
10 |
11 | ## Usage
12 |
13 | Hyper Book (H9) generates pages from plain text wiki-style templates
14 | for a hypertext book in two versions,
15 | that is, a single-page version and a multi-page version.
16 |
17 |
18 | ## Goals
19 |
20 | - Hyper Book offers book models / structs
21 | (e.g. Book, Part, Chapter, Appendix)
22 | and types
23 | (Album, Slide Show, etc.).
24 |
25 | - Hyper Book offers template packs and plugins.
26 |
27 | - Hyper Book offers a template pack and plugin manager
28 | (e.g. `hybook install almanac`, `hybook install table`, etc.).
29 |
30 |
31 |
32 | ## Non-Goals
33 |
34 | - Hyper Book is **NOT** a static site generator / server.
35 | => Use your static site generator of choice (e.g. Jekyll and friends)
36 | to convert the generated pages into a complete hypertext book or web site.
37 |
38 | - Hyper Book is **NOT** a HTML to PDF converter.
39 | => Use your HTML to PDF converter of choice (e.g. print ot PDF, `wkhtmltopdf`, etc.).
40 |
41 | - Hyper Book is **NOT** a EPUB generator or checker.
42 | => Use your EPUB generator or checker of choice.
43 |
44 | - Hyper Book is **NOT** a MOBI generator.
45 | => Use your MOBI generator of choice (e.g. `kindlegen`, etc.).
46 |
47 |
48 |
49 | ## Building Blocks
50 |
51 | - [`textutils` gem](https://github.com/rubylibs/textutils) -- Text filters n helpers
52 | - [`markdown` gem](https://github.com/rubylibs/markdown) -- Markdown helpers
53 | - [`pakman` gem](https://github.com/rubylibs/pakman) -- Template Pack(age) manager
54 | - [`props` gem](https://github.com/rubylibs/props) -- Setting Hierachies (Commandline, User, Home, Defaults, etc.)
55 |
56 |
57 |
58 |
59 | - Jekyll -- static site generator
60 | - `kramdown` -- Markdown converter
61 |
62 |
63 | ## Hypertext Markup (HTML) to PDF Conversion Options
64 |
65 | - Use Google Chrome (Print to PDF)
66 | - `wkhtmltopdf`
67 | - `phantom.js` Renderer
68 |
69 |
70 | ## Real World Book Examples
71 |
72 | - [The Free World Football Almanac](https://github.com/openfootball/book)
73 | - [The Free World Beer Book](https://github.com/openbeer/book)
74 | - [The Free World Fact Book](https://github.com/openmundi/book)
75 |
76 |
77 | ## License
78 |
79 | The `hybook` scripts are dedicated to the public domain.
80 | Use it as you please with no restrictions whatsoever.
81 |
82 |
83 | ## Questions? Comments?
84 |
85 | Send them along to the
86 | [Free Web Slide Show Alternatives (S5, S6, S9, Slidy And Friends) Forum/Mailing List](http://groups.google.com/group/webslideshow).
87 | Thanks!
88 |
--------------------------------------------------------------------------------
/record/README.md:
--------------------------------------------------------------------------------
1 | # record - named tuples / records with typed structs / schemas
2 |
3 | * home :: [github.com/rubycoco/record](https://github.com/rubycoco/record)
4 | * bugs :: [github.com/rubycoco/record/issues](https://github.com/rubycoco/record/issues)
5 | * gem :: [rubygems.org/gems/record](https://rubygems.org/gems/record)
6 | * rdoc :: [rubydoc.info/gems/record](http://rubydoc.info/gems/record)
7 | * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
8 |
9 |
10 |
11 | ## Usage
12 |
13 |
14 | Step 1: Define a (typed) struct for your records / named tuples. Example:
15 |
16 | ```ruby
17 | require 'record'
18 |
19 | Beer = Record.define do
20 | field :brewery ## note: default type is :string
21 | field :city
22 | field :name
23 | field :abv, Float ## allows type specified as class (or use :float)
24 | end
25 | ```
26 |
27 | or in "classic" style:
28 |
29 | ```ruby
30 | class Beer < Record::Base
31 | field :brewery
32 | field :city
33 | field :name
34 | field :abv, Float
35 | end
36 | ```
37 |
38 |
39 |
40 | Step 2: Use the new class to create new (typed) records. Example:
41 |
42 |
43 | ``` ruby
44 | beer = Beer.new( 'Andechser Klosterbrauerei',
45 | 'Andechs',
46 | 'Doppelbock Dunkel',
47 | '7%' )
48 |
49 | # -or-
50 |
51 | values = ['Andechser Klosterbrauerei', 'Andechs', 'Doppelbock Dunkel', '7%']
52 | beer = Beer.new( values )
53 |
54 | # -or-
55 |
56 | beer = Beer.new( brewery: 'Andechser Klosterbrauerei',
57 | city: 'Andechs',
58 | name: 'Doppelbock Dunkel',
59 | abv: '7%' )
60 |
61 | # -or-
62 |
63 | hash = { brewery: 'Andechser Klosterbrauerei',
64 | city: 'Andechs',
65 | name: 'Doppelbock Dunkel',
66 | abv: '7%' }
67 | beer = Beer.new( hash )
68 |
69 |
70 | # -or-
71 |
72 | beer = Beer.new
73 | beer.update( brewery: 'Andechser Klosterbrauerei',
74 | city: 'Andechs',
75 | name: 'Doppelbock Dunkel' )
76 | beer.update( abv: 7.0 )
77 |
78 | # -or-
79 |
80 | beer = Beer.new
81 | beer.parse( ['Andechser Klosterbrauerei', 'Andechs', 'Doppelbock Dunkel', '7%'] )
82 |
83 | # -or-
84 |
85 | beer = Beer.new
86 | beer.parse( 'Andechser Klosterbrauerei,Andechs,Doppelbock Dunkel,7%' )
87 |
88 | # -or-
89 |
90 | beer = Beer.new
91 | beer.brewery = 'Andechser Klosterbrauerei'
92 | beer.name = 'Doppelbock Dunkel'
93 | beer.abv = 7.0
94 | ```
95 |
96 |
97 | And so on. That's it.
98 |
99 |
100 |
101 |
102 | ## License
103 |
104 | 
105 |
106 | The `record` scripts are dedicated to the public domain.
107 | Use it as you please with no restrictions whatsoever.
108 |
109 | ## Questions? Comments?
110 |
111 | Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
112 | Thanks!
113 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/bookfile.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookfile
4 |
5 | class Bookfile
6 |
7 | include LogUtils::Logging
8 |
9 | ## convenience method - use like Bookfile.load_file()
10 | def self.load_file( path='./Bookfile' )
11 | # Note: return datafile (of course, NOT the builder)
12 | # if you want a builder use Bookfile::Builder ;-)
13 | builder = Builder.load_file( path )
14 | builder.bookfile
15 | end
16 |
17 | ## another convenience method - use like Bookfile.load()
18 | def self.load( code )
19 | # Note: return datafile (of course, NOT the builder)
20 | # if you want a builder use Bookfile::Builder ;-)
21 | builder = Builder.load( code )
22 | builder.bookfile
23 | end
24 |
25 |
26 |
27 | attr_reader :packages
28 | attr_reader :databases
29 | attr_reader :books
30 |
31 | def initialize
32 | @packages = [] # only allow single package - why, why not??
33 | @databases = [] # only allow single database - why, why not??
34 | @books = [] # only allow single book - why, why not??
35 | end
36 |
37 |
38 | def download
39 | puts "[bookfile] dowload book packages"
40 | @packages.each do |package|
41 | package.download
42 | end
43 | end
44 |
45 | ###
46 | ## todo/fix - add unzip_dir as an option/config to constructor - why, why not??
47 | ## location needs to get (re)used in prepare too
48 | ## for now pass along unzip_dir again ???
49 | def unzip( unzip_dir )
50 | puts "[bookfile] unzip book packages"
51 | ### fix: for multiple packages use a number?? - how to make path unique
52 | ## for now is ./book
53 | @packages.each do |package|
54 | package.unzip( unzip_dir )
55 | end
56 | end
57 |
58 |
59 | =begin
60 | def setup
61 | puts "[bookfile] setup database connections n models"
62 | @databases.each do |database|
63 | database.setup
64 | end
65 | end
66 | =end
67 |
68 | def connect
69 | puts "[bookfile] connect to database(s)"
70 | @databases.each do |database|
71 | database.connect
72 | end
73 | end
74 |
75 |
76 | def prepare( unzip_dir )
77 | @databases.each do |database|
78 | database.prepare ## require models and include in builder/page ctx
79 | end
80 | @packages.each do |package|
81 | package.prepare( unzip_dir ) ## require helpers and include in builder/page ctx
82 | end
83 | end
84 |
85 |
86 | def build( unzip_dir )
87 | puts "[bookfile] build books"
88 | @books.each do |book|
89 | book.build( unzip_dir )
90 | end
91 | end
92 |
93 |
94 |
95 | def dump
96 | ## ## for debugging dump datasets (note: will/might also check if zip exits)
97 | ## logger.info( "[datafile] dump datasets (for debugging)" )
98 | ## @datasets.each do |dataset|
99 | ## dataset.dump()
100 | ## end
101 | end
102 |
103 |
104 | end # class Bookfile
105 | end # module Bookfile
106 |
107 |
--------------------------------------------------------------------------------
/officetxt/test/test_version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_version.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestVersion < MiniTest::Test
12 |
13 |
14 | def test_version
15 |
16 | puts Officetxt::VERSION
17 |
18 | puts " jekyll/#{Jekyll::VERSION}"
19 | puts " jekyll-import/#{JekyllImport::VERSION}"
20 | puts " jekyll-avatar/#{Jekyll::Avatar::VERSION}"
21 |
22 | puts " jekyll-planet/#{JekyllPlanet::VERSION}"
23 |
24 | =begin
25 | puts " jekyll-feed/#{Jekyll::Feed::VERSION}"
26 | no: version in ruby just in gemspec e.g.
27 | Gem::Specification.new do |spec|
28 | spec.name = "jekyll-feed"
29 | spec.version = "0.9.2"
30 |
31 | todo: try to get info from gemspec??
32 | =end
33 |
34 |
35 | puts " octopod/#{Jekyll::Octopod::VERSION::STRING}"
36 |
37 |
38 | =begin
39 | ## fix Octopod
40 |
41 | puts " jekyll-octopod/#{Jekyll::Octopod::VERSION}"
42 |
43 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:68:in `require': C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:32: void value expression (SyntaxError)
44 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:33: syntax error, unexpected '<', expecting keyword_end
45 |
49 | ^
50 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:37: syntax error, unexpected tSTRING_BEG, expecting keyword_end
51 | ...ipts/podigee-podcast-player.js">
52 | ... ^
53 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:37: unterminated string meets end of file
54 | =end
55 |
56 | puts " quik/#{Quik::VERSION}"
57 | puts Quik.banner
58 |
59 | puts " mrhyde/#{MrHyde::VERSION}"
60 | puts MrHyde.banner
61 |
62 | puts " drjekyll/#{DrJekyll::VERSION}"
63 | puts DrJekyll.banner
64 |
65 | puts " slideshow/#{SlideshowCli::VERSION}" ## note: Slideshow::VERSION is for models
66 | puts SlideshowCli.banner
67 |
68 | puts " journaltxt/#{Journaltxt::VERSION}"
69 | puts Journaltxt.banner
70 |
71 | puts " pluto/#{PlutoCli::VERSION}" ## note: Pluto::VERSION is for models
72 | puts PlutoCli.banner
73 |
74 |
75 | puts " rouge/#{Rouge.version}" ## incl. rougify
76 | puts " kramdown/#{Kramdown::VERSION}"
77 | puts " word-to-markdown/#{WordToMarkdown::VERSION}"
78 |
79 |
80 | ###
81 | ## ## fix: hexapdf requires Ruby version >= 2.3.
82 | ## puts " hexapdf/#{HexaPDF::VERSION}"
83 |
84 | Officetxt.about
85 |
86 |
87 | assert true
88 | ## assume everything ok if get here
89 | end
90 |
91 | end # class TestVersion
92 |
--------------------------------------------------------------------------------
/hybook/lib/hybook/builder/book.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # book builder
5 | #
6 | # - fix: build book structure in memory only (and use JekyllWriter to write/render to disk!!!)
7 | # -- independent of jekyll (e.g. static site compiler)
8 |
9 | #
10 | #
11 | # -- fix: use our own Page model or better Part / Section / etc. !!!!
12 | # -- do NOT use TextUtils::Page --> use in writer/render when content gets mapped!!!
13 |
14 | #
15 | #
16 | # fix: remove jekyll specific stuff
17 | # -- move to jekyll writer
18 |
19 | class BookBuilder
20 |
21 | def inline?() @inline; end
22 | def title() @title; end
23 | def layout() @layout; end
24 | def pages_dir() @pages_dir; end
25 |
26 |
27 | def initialize( user_pages_dir, opts={} )
28 |
29 | #
30 | #
31 | # fix: move user_pages_dir to opts ?? or remove
32 | # only use for writer/renderer later
33 |
34 | @pages_dir = user_pages_dir # add user_ to avoid conflict w/ attrib
35 |
36 | @inline = opts[:inline ] == true ? true : false # all-in-one page version or multi-page?
37 |
38 | @title = opts[:title] || 'Book Title Here'
39 | @layout = opts[:layout] || 'default'
40 |
41 |
42 | ## if @inline create all-in-one book(.html) page
43 | if inline?
44 | path = "#{pages_dir}/book.md"
45 | puts "[book] create all-in-one book page (#{path})"
46 |
47 | ## add frontmatter
48 |
49 | page_opts = { frontmatter: {
50 | layout: layout,
51 | title: title,
52 | permalink: '/book.html' } }
53 |
54 | TextUtils::Page.create( path, page_opts ) do |page|
55 | ## do nothing for now
56 | end
57 | end
58 | end
59 |
60 |
61 | ### fix: change to part/chapter/section/etc. ??
62 |
63 | def page( name, opts={} )
64 |
65 | # add fallbacks/defaults
66 | opts[:title] ||= 'Page Title Here'
67 | opts[:id] ||= TextUtils.slugify( @title ) ## add page/section counter to generated fallback id/anchor
68 |
69 | if inline?
70 | path = "#{pages_dir}/book.md"
71 | puts "[book] update all-in-one book page -- #{name} (#{path})"
72 |
73 | page_opts = {}.merge( opts ) ## for now pass along all opts; no built-in/auto-added opts -- in the future add page/section counter or similar, for example?
74 | TextUtils::Page.update( path, page_opts ) do |page|
75 | yield( page )
76 | end
77 | else
78 | path = "#{pages_dir}/#{name}.md"
79 | puts "[book] create page #{name} (#{path})"
80 |
81 | page_opts = { frontmatter: {
82 | layout: layout, # e.g. 'book'
83 | title: opts[:title], # e.g. 'The Free Beer Book'
84 | permalink: "/#{opts[:id]}.html" # e.g. '/index.html'
85 | }}
86 | page_opts = page_opts.merge( opts ) ## pass along all opts
87 |
88 | TextUtils::Page.create( path, page_opts ) do |page|
89 | yield( page )
90 | end
91 | end
92 | end
93 |
94 | end # class BookBuilder
95 |
96 |
--------------------------------------------------------------------------------
/almost-sinatra/up/almost_sinatra.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | #####
4 | # orginal source in six lines;
5 | #
6 | # 1: %w.rack tilt backports date INT TERM..map{|l|trap(l){$r.stop}rescue require l};$u=Date;$z=($u.new.year + 145).abs;puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick"
7 | # 2: $n=Sinatra=Module.new{a,D,S,q=Rack::Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m
8 | # 3: %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}}}}
9 | # 4: Tilt.default_mapping.lazy_map.map{|k,v|D.(k){|n,*o|$t||=(h=$u._jisx0301("hash, please");File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);Kernel.const_get(v[0][0]).new(*o){n=="#{n}"?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
10 | # 5: %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Rack::Handler.get("webrick").run(a,Port:$z){|s|$r=s}}
11 | # 6: %w[params session].map{|m|D.(m){q.send m}};a.use Rack::Session::Cookie;a.use Rack::Lock;D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Rack::Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}}
12 | #
13 | # see: https://github.com/rkh/almost-sinatra/blob/master/almost_sinatra.rb
14 |
15 |
16 |
17 | #############
18 | # unbundled ("obfuscated") version
19 | #
20 | # replaced
21 | # 1) D = Object.method(:define_method) with
22 | # define_method
23 |
24 |
25 | # line 1
26 | %w[rack tilt backports date INT TERM].map do |l|
27 | trap(l) { $r.stop }
28 | rescue
29 | require l
30 | end
31 |
32 | $u = Date
33 | $z = ($u.new.year + 145).abs
34 | puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick"
35 |
36 | # line 2
37 | $n = Sinatra = Module.new do
38 | a = Rack::Builder.new
39 | S = /@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m
40 | q = nil
41 |
42 | # line 3
43 | %w[get post put delete].map do |m|
44 | define_method( m ) do |u, &b|
45 | a.map(u) do
46 | run ->(e) { [200, {"Content-Type"=>"text/html"}, [a.instance_eval(&b)]] }
47 | end
48 | end
49 | end
50 |
51 | # line 4
52 | Tilt.default_mapping.lazy_map.map do |k,v|
53 | define_method( k ) do |n, *o|
54 | $t ||= do
55 | h = $u._jisx0301("hash, please")
56 | File.read( caller[0][/^[^:]+/] ).scan(S) { |a,b| h[a]=b }
57 | h
58 | end
59 | Kernel.const_get( v[0][0] ).new( *o ) do
60 | n == "#{n}" ? n : $t[n.to_s]
61 | end.render( a, o[0].try( :[], :locals) || {} )
62 | end
63 | end
64 |
65 | # line 5
66 | %w[set enable disable configure helpers use register].map do |m|
67 | define_method( m ) do |*_, &b|
68 | b.try :[]
69 | end
70 | end
71 |
72 | END do
73 | Rack::Handler.get( "webrick" ).run( a, Port:$z ) { |s| $r=s }
74 | end
75 |
76 |
77 | # line 6
78 | %w[params session].map do |m|
79 | define_method( m ) do
80 | q.send m
81 | end
82 | end
83 | a.use Rack::Session::Cookie
84 | a.use Rack::Lock
85 | define_method( :before ) do |&b|
86 | a.use Rack::Config, &b
87 | end
88 | before do |e|
89 | q = Rack::Request.new e
90 | q.params.dup.map { |k,v| params[k.to_sym] = v}
91 | end
92 | end
93 |
--------------------------------------------------------------------------------
/preproc/lib/preproc.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | # 3rd party gems
5 |
6 | require 'fetcher'
7 |
8 | # our own code
9 |
10 | require 'preproc/version' # let version always go first
11 |
12 |
13 |
14 | module Preproc
15 |
16 | #############
17 | ### todo/fix: use/find better name? - e.g. Fetcher.read_utf8!() move out of global ns etc.
18 | ## move to Fetcher gem; (re)use!!! remove here
19 | ### e.g. use Fetch.read_utf8!() e.g. throws exception on error
20 | ## read_blob!()
21 | def self.fetcher_read_utf8!( src )
22 | worker = Fetcher::Worker.new
23 | res = worker.get_response( src )
24 | if res.code != '200'
25 | puts "sorry; failed to fetch >#{src} - HTTP #{res.code} - #{res.message}"
26 | exit 1
27 | end
28 |
29 | ###
30 | # Note: Net::HTTP will NOT set encoding UTF-8 etc.
31 | # will be set to ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
32 | # thus, set/force encoding to utf-8
33 | txt = res.body.to_s
34 | txt = txt.force_encoding( Encoding::UTF_8 )
35 | txt
36 | end
37 |
38 |
39 | class IncludeReader
40 |
41 | ###
42 | ## concat files w/ @include directive
43 | include LogUtils::Logging
44 |
45 | def self.from_url( src )
46 | uri = URI.parse( src )
47 | text = Preproc.fetcher_read_utf8!( src )
48 |
49 | base_path = uri.path[0..uri.path.rindex('/')] # get everything upto incl. last slash (/)
50 | self.new( text, base: "#{uri.scheme}://#{uri.host}:#{uri.port}#{base_path}" )
51 | end
52 |
53 |
54 | def initialize( text, opts={} )
55 | @text = text
56 | @base = opts[:base]
57 |
58 | logger.debug(" base: #{@base}")
59 | end
60 |
61 | def read
62 | preproc( @text )
63 | end
64 |
65 |
66 | private
67 | def preproc( text )
68 | buf = ''
69 | text.each_line do |line|
70 | ### e.g. allows
71 | ## @include 'test' or
72 | ## @INCLUDE "test"
73 | ## note: for now we strip (allow) leading and trailing spaces (e.g. [ ]*)
74 | ##
75 | ## todo/allow
76 | ## @include( test ) - alternative syntax - why? why not?
77 | if line =~ /^[ ]*@include[ ]+("|')(.+?)\1[ ]*$/i
78 | logger.info( " try to include '#{$2}'")
79 | ## buf << preproc( 'include here' )
80 | buf << preproc( read_include( $2 ) )
81 | buf << "\n"
82 | else
83 | buf << line
84 | buf << "\n"
85 | end
86 | end
87 | buf
88 | end
89 |
90 | def read_include( name )
91 | ## for now assume fetch via url
92 | ## note: assume partial e.g. add leading underscore (_)
93 | ## e.g. test => _test.ini
94 |
95 | src = "#{@base}_#{name}.ini"
96 | logger.info( " try to fetch include #{src}")
97 |
98 | Preproc.fetcher_read_utf8!( src )
99 | end
100 |
101 | end # class IncludeReader
102 |
103 |
104 | end # module Preproc
105 |
106 |
107 | ## add top level (convenience) alias
108 | InclPreproc = Preproc::IncludeReader
109 | IncludePreproc = Preproc::IncludeReader
110 |
111 |
112 |
113 | ## say hello
114 | puts Preproc.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
115 |
116 |
--------------------------------------------------------------------------------
/rubycat/lib/rubycat/card.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module RubyCat
4 |
5 |
6 | class Card
7 |
8 | ## read only
9 | attr_reader :name # e.g. sinatra
10 | attr_reader :gem_url # e.g. https://rubygems.org/gems/sinatra
11 | attr_reader :github_url # e.g. https://github.com/sinatra/sinatra
12 | attr_reader :categories # e.g.
13 |
14 | attr_reader :desc # info/blurb/description/summary (use summary ??)
15 | attr_reader :latest_version ## as string
16 | attr_reader :latest_version_downloads
17 | attr_reader :downloads ## total downloads
18 | attr_reader :deps # runtime dependencies as a string for now (activerecord, activesupport etc.)
19 |
20 |
21 | def to_hash
22 | { name: @name,
23 | gem_url: @gem_url,
24 | github_url: @github_url,
25 | categories: @categories,
26 | desc: @desc,
27 | latest_version: @latest_version,
28 | latest_version_downloads: @latest_version_downloads,
29 | downloads: @downloads,
30 | deps: @deps }
31 | end
32 |
33 |
34 |
35 | def initialize( card )
36 | @categories = card.categories
37 | @name = nil
38 |
39 |
40 | github_link = card.links.find {|it| it[0].include?( ':octocat:') }
41 |
42 | if github_link
43 | @github_url = github_link[1]
44 |
45 | ## check if org (shortcut)
46 | uri = URI.parse( @github_url )
47 | puts " uri.path: #{uri.path}"
48 | ##
49 | names = uri.path[1..-1].split('/') ## cut off leading / and split
50 | pp names
51 |
52 | ## if single name (duplicate - downcased! e.g. Ramaze => Ramaze/ramaze)
53 | if names.size == 1
54 | @github_url += "/#{names[0].downcase}"
55 | @name = names[0].downcase
56 | else
57 | @name = names[1]
58 | end
59 | puts "github_url: #{@github_url}"
60 | else
61 | puts "*** no github_url found"
62 | pp card
63 | end
64 |
65 | gem_link = card.links.find {|it| it[0] == ':gem:' }
66 | if gem_link
67 | @gem_url = gem_link[1]
68 | puts "gem_url: #{@gem_url}"
69 |
70 | uri = URI.parse( @gem_url )
71 | names = uri.path[1..-1].split('/') ## cut off leading / and split
72 | pp names
73 | ## assume last name entry is name of gem
74 | @name = names[-1]
75 | else
76 | puts "*** no gem_url found"
77 | pp card
78 | end
79 | end
80 |
81 |
82 | def sync_gems_info( json )
83 | @desc = json['info']
84 | @latest_version = json['version']
85 | @latest_version_downloads = json['version_downloads']
86 | @downloads = json['downloads']
87 |
88 | deps_runtime = json['dependencies']['runtime']
89 | if deps_runtime && deps_runtime.size > 0
90 | deps = []
91 | deps_runtime.each do |dep|
92 | deps << dep['name']
93 | end
94 | @deps = deps.join(', ')
95 | else
96 | @deps = nil
97 | end
98 | end # method sync_gems_info
99 |
100 | end ## class Card
101 |
102 |
103 |
104 | end # module RubyCat
105 |
--------------------------------------------------------------------------------
/record/lib/record/field.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Record
5 |
6 | ## note on naming:
7 | ## use naming convention from awk and tabular data package/json schema for now
8 | ## use - records (use rows for "raw" untyped (string) data rows )
9 | ## - fields (NOT columns or attributes) -- might add an alias later - why? why not?
10 |
11 | class Field ## ruby record class field
12 |
13 |
14 | ###################################
15 | ## add simple logger with debug flag/switch
16 | #
17 | # use Parser.debug = true # to turn on
18 | #
19 | # todo/fix: use logutils instead of std logger - why? why not?
20 |
21 | def self.build_logger()
22 | l = Logger.new( STDOUT )
23 | l.level = :info ## set to :info on start; note: is 0 (debug) by default
24 | l
25 | end
26 | def self.logger() @@logger ||= build_logger; end
27 | def logger() self.class.logger; end
28 |
29 |
30 | attr_reader :name, :type
31 |
32 | ## zero-based position index (0,1,2,3,...)
33 | ## todo: use/rename to index/idx/pos - add an alias name - why?
34 | attr_reader :num
35 |
36 | def initialize( name, num, type )
37 | ## note: always symbol-ify (to_sym) name and type
38 |
39 | ## todo: add title or titles for header field/column title as is e.g. 'Team 1' etc.
40 | ## incl. numbers only or even an empty header title
41 | @name = name.to_sym
42 | @num = num
43 |
44 | if type.is_a?( Class )
45 | @type = type ## assign class to its own property - why? why not?
46 | else
47 | @type = Type.registry[type.to_sym]
48 | if @type.nil?
49 | logger.warn "!!!! warn unknown type >#{type}< - no class mapping found; add missing type to Record::Type.registry[]"
50 | ## todo/fix: raise exception!!!!
51 | end
52 | end
53 | end
54 |
55 |
56 | def typecast( value ) ## cast (convert) from string value to type (e.g. float, integer, etc.)
57 | ## todo: add typecast to class itself (monkey patch String/Float etc. - why? why not)
58 | ## use __typecast or something?
59 | ## or use a new "wrapper" class Type::String or StringType - why? why not?
60 |
61 | ## convert string value to (field) type
62 | if @type == String
63 | value ## pass through as is
64 | elsif @type == Float
65 | ## note: allow/check for nil values - why? why not?
66 | float = (value.nil? || value.empty?) ? nil : value.to_f
67 | logger.debug "typecast >#{value}< to float number >#{float}<"
68 | float
69 | elsif @type == Integer
70 | number = (value.nil? || value.empty?) ? nil : value.to_i(10) ## always use base10 for now (e.g. 010 => 10 etc.)
71 | logger.debug "typecast >#{value}< to integer number >#{number}<"
72 | number
73 | else
74 | ## todo/fix: raise exception about unknow type
75 | logger.warn "!!!! unknown type >#{@type}< - don't know how to convert/typecast string value >#{value}<"
76 | logger.warn @type.inspect
77 | value
78 | end
79 | end
80 | end # class Field
81 |
82 |
83 |
84 | class Type ## todo: use a module - it's just a namespace/module now - why? why not?
85 |
86 | ## e.g. use Type.registry[:string] = String etc.
87 | ## note use @@ - there is only one registry
88 | def self.registry() @@registry ||={} end
89 |
90 | ## add built-in types:
91 | registry[:string] = String
92 | registry[:integer] = Integer ## todo/check: add :number alias for integer? why? why not?
93 | registry[:float] = Float
94 | ## todo: add some more
95 | end # class Type
96 |
97 |
98 | end # module Record
99 |
--------------------------------------------------------------------------------
/bookfile/test/bookfile/beer.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | package 'book-templates/beer'
5 |
6 |
7 | beer adapter: 'sqlite3', database: './beer.db'
8 |
9 |
10 | book do |b|
11 |
12 | ## todo/fix:
13 | ## find a way to pass along opts - why, why not??
14 | opts = {}
15 |
16 | ### generate what's news in 2015
17 | years = [2015,2014,2013,2012,2011,2010]
18 | years.each do |year|
19 | b.page( "#{year}", title: "What's News in #{year}?",
20 | id: "#{year}" ) do |page|
21 | page.render_whats_news_in_year( year, opts )
22 | end
23 | end
24 |
25 |
26 | ### generate breweries index
27 |
28 | b.page( 'breweries', title: 'Breweries Index',
29 | id: 'breweries' ) do |page|
30 | page.render_breweries_idx( opts )
31 | end
32 |
33 | ### generate beers index
34 |
35 | b.page( 'beers', title: 'Beers Index',
36 | id: 'beers' ) do |page|
37 | page.render_beers_idx( opts )
38 | end
39 |
40 | ### generate brands index
41 |
42 | b.page( 'brands', title: 'Brands Index',
43 | id: 'brands' ) do |page|
44 | page.render_brands_idx( opts )
45 | end
46 |
47 |
48 | ### generate table of contents (toc)
49 |
50 | b.page( 'index', title: 'Contents',
51 | id: 'index' ) do |page|
52 | page.render_toc( opts )
53 | end
54 |
55 |
56 | ### generate pages for countries
57 |
58 | country_count=0
59 | # Country.where( "key in ('at','mx','hr', 'de', 'be', 'nl', 'cz')" ).each do |country|
60 | Country.order(:id).each do |country|
61 | beers_count = country.beers.count
62 | breweries_count = country.breweries.count
63 | next if beers_count == 0 && breweries_count == 0
64 |
65 | country_count += 1
66 | puts "build country page #{country.key}..."
67 |
68 | path = country.to_path
69 | puts "path=#{path}"
70 | b.page( path, title: "#{country.title} (#{country.code})",
71 | id: "#{country.key}" ) do |page|
72 | page.render_country( country, opts )
73 | end
74 |
75 | ## todo - add b.divider() - for inline version - why, why not ????
76 |
77 | ## break if country_count == 3 # note: for testing only build three country pages
78 | end
79 | end
80 |
81 |
82 | =begin
83 | ###
84 | ## todo: move to its own bookfile
85 | ## - how to pass in country parameter ???
86 |
87 | def build_book_for_country( country_code, opts={} )
88 |
89 | country = Country.find_by_key!( country_code )
90 |
91 | b = BookBuilder.new( PAGES_DIR, opts )
92 |
93 | ### generate breweries index
94 |
95 | b.page( "#{country.key}-breweries", title: 'Breweries Index',
96 | id: "/#{country.key}-breweries" ) do |page|
97 | page.write render_breweries_idx( opts )
98 | end
99 |
100 | ### generate pages for countries
101 |
102 | puts "build country page #{country.key}..."
103 |
104 | path = country.to_path
105 | puts "path=#{path}"
106 | b.page( path, title: "#{country.title} (#{country.code})",
107 | id: "#{country.key}" ) do |page|
108 | page.write render_country( country, opts )
109 | end
110 |
111 | b.page( "#{country.key}-mini", title: "#{country.title} (#{country.code}) - Mini",
112 | id: "#{country.key}-mini" ) do |page|
113 | page.write render_country_mini( country, opts )
114 | end
115 |
116 | b.page( "#{country.key}-stats", title: "#{country.title} (#{country.code}) - Stats",
117 | id: "#{country.key}-stats.html" ) do |page|
118 | page.write render_country_stats( country, opts )
119 | end
120 |
121 | end
122 | =end
123 |
124 |
--------------------------------------------------------------------------------
/fizzbuzzer/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 |
4 | ## FizzBuzz Articles and Samples
5 |
6 | ### Ruby
7 |
8 | FizzBuzz in Too Much Detail by Tom Dalling
9 | @ https://www.tomdalling.com/blog/software-design/fizzbuzz-in-too-much-detail/ and
10 | @ https://www.rubypigeon.com/posts/fizzbuzz-in-too-much-detail/
11 |
12 | FizzBuzz with pattern matching (in Ruby) by Paweł Świątkowski
13 | @ http://katafrakt.me/2016/11/05/fizzbuzz-with-pattern-matching/
14 |
15 |
16 | FizzBuzz RubyQuiz #126
17 | @ http://rubyquiz.com/quiz126.html
18 |
19 |
20 | Search RubyGems.org
21 | @ https://rubygems.org/search?query=fizzbuzz
22 |
23 | Search BestGems.org
24 | @ http://bestgems.org/search?q=fizzbuzz
25 |
26 |
27 |
28 |
29 | ### Java
30 |
31 | FizzBuzz Enterprise Edition is a no-nonsense implementation of FizzBuzz made by serious businessmen for serious business purposes.
32 | @ https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
33 |
34 |
35 | ### Python
36 |
37 | Fizz buzz in tensorflow (machine learning)
38 | @ https://github.com/joelgrus/fizz-buzz-tensorflow and
39 | @ https://github.com/joelgrus/fizz-buzz-tensorflow/blob/master/Fizz%20Buzz%20in%20Tensorflow.ipynb
40 | @ http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/
41 |
42 | ### More
43 |
44 | FizzBuzz @ Rosseta Code
45 | @ http://rosettacode.org/wiki/FizzBuzz
46 |
47 | FizzBuzz Topic / Tag @ GitHub
48 | @ https://github.com/topics/fizzbuzz
49 |
50 | FizzBuzz Repo by Tobias Pfeiffer aka Prag Tob
51 | @ https://github.com/PragTob/fizzbuzz
52 |
53 |
54 |
55 | ## More FizzBuzz Algorithms
56 |
57 | Rotate / No Conditionals
58 |
59 | ``` ruby
60 | def fizzbuzz
61 | fizzy = [1,0,0]
62 | buzzy = [1,0,0,0,0]
63 |
64 | (1..100).map do |n|
65 | fizzy.rotate!
66 | buzzy.rotate!
67 | result = n.to_s * (1 - (fizzy[0] | buzzy[0]))
68 | result << "Fizz" * fizzy[0]
69 | result << "Buzz" * buzzy[0]
70 | result
71 | end
72 | end
73 | ```
74 |
75 | Contributed by [John Schank](https://github.com/jschank).
76 |
77 |
78 |
79 |
80 | ## Monkey Patch Version with Refinements
81 |
82 |
83 | ``` ruby
84 | module V3
85 | ## monkey patch for Fixnum - note: use refinements fo now - why? why not?
86 | module FizzBuzz
87 | refine Fixnum do
88 | def to_fizzbuzz
89 | if self % 3 == 0 && self % 5 == 0
90 | "FizzBuzz"
91 | elsif self % 3 == 0
92 | "Fizz"
93 | elsif self % 5 == 0
94 | "Buzz"
95 | else
96 | self
97 | end
98 | end # method to_fizzbuzz
99 | end
100 | end
101 |
102 | using FizzBuzz
103 |
104 | def fizzbuzz
105 | (1..100).map { |n| n.to_fizzbuzz }
106 | end
107 | end
108 | ```
109 |
110 |
111 |
112 | ## Old Test Builder with eval
113 |
114 | ``` ruby
115 | %w[V2a V2b V2c V2d V3 V4 V5 V6a V6b V7 V8 V9 V10 V11 V12a V12b].each do |name|
116 | eval %Q(
117 | class Test#{name} < MiniTest::Test
118 | include FizzBuzzer::#{name}
119 |
120 | def test_fizzbuzz
121 | puts "running fizzbuzz #{name}..."
122 | assert_equal FIZZBUZZES_1_TO_100, fizzbuzz
123 | end
124 | end)
125 | end
126 | ```
127 |
128 | Add name to anonymous test class - why? why not?
129 |
130 | ``` ruby
131 | module FizzBuzz
132 |
133 | ## auto-generate test classes (see model/sample above)
134 | def self.test_class_for( m )
135 | test_class = Class.new( MiniTest::Test ) do
136 | include m
137 | define_method :test_fizzbuzz do
138 | puts "testing #{m.name}..."
139 | assert_equal FIZZBUZZES_1_TO_100, fizzbuzz
140 | end
141 | end
142 | ## change name from FizzBuzzer::V1 to FizzBuzzer_V1 etc.
143 | ## Object.const_set( "Test_" + m.name.gsub(/:+/, '_'), test_class )
144 | end
145 |
146 | end
147 | ```
148 |
149 |
--------------------------------------------------------------------------------
/officetxt/lib/officetxt.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | require 'pp'
5 |
6 |
7 | ## add tools
8 | require 'jekyll'
9 | require 'quik'
10 | require 'mrhyde/tools'
11 | require 'drjekyll'
12 | require 'slideshow'
13 | require 'journaltxt'
14 | require 'pluto'
15 |
16 | require 'kramdown'
17 | require 'word-to-markdown'
18 | require 'rouge'
19 |
20 |
21 | require 'jekyll-import'
22 | require 'jekyll-import/version' ## note: not auto-loaded with gem
23 |
24 | ## require 'jekyll-octopod'
25 |
26 | ### add more jekyll plugins plus jekyll-admin
27 | ### plus add some themes!!!
28 |
29 | require 'jekyll-avatar'
30 | require 'jekyll-avatar/version' ## note: not auto-loaded with plugin
31 | require 'jekyll-feed'
32 |
33 |
34 | require 'jekyll/planet'
35 |
36 |
37 | require 'octopod/version' ## note: just auto-load version script
38 |
39 |
40 | # our own code
41 | require 'officetxt/version' # note: let version always go first
42 |
43 |
44 |
45 | module Officetxt
46 |
47 | def self.about
48 |
49 | puts
50 | puts
51 | puts "Welcome to officetxt/#{Officetxt::VERSION}:"
52 | puts
53 | puts "Tool versions installed:"
54 |
55 | puts " journaltxt/#{Journaltxt::VERSION}"
56 | puts " jekyll/#{Jekyll::VERSION}"
57 | puts " jekyll-import/#{JekyllImport::VERSION}"
58 | puts " jekyll-avatar/#{Jekyll::Avatar::VERSION}"
59 | puts " jekyll-planet/#{JekyllPlanet::VERSION}"
60 |
61 | =begin
62 | puts " jekyll-feed/#{Jekyll::Feed::VERSION}"
63 | no: version in ruby just in gemspec e.g.
64 | Gem::Specification.new do |spec|
65 | spec.name = "jekyll-feed"
66 | spec.version = "0.9.2"
67 |
68 | todo: try to get info from gemspec??
69 | =end
70 |
71 |
72 | =begin
73 | ## fix Octopod
74 |
75 | puts " jekyll-octopod/#{Jekyll::Octopod::VERSION}"
76 |
77 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:68:in `require': C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:32: void value expression (SyntaxError)
78 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:33: syntax error, unexpected '<', expecting keyword_end
79 |
83 | ^
84 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:37: syntax error, unexpected tSTRING_BEG, expecting keyword_end
85 | ...ipts/podigee-podcast-player.js">
86 | ... ^
87 | C:/prg/ri/v310/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/jekyll-octopod-0.9.0/lib/jekyll/podigee_player_tag.rb:37: unterminated string meets end of file
88 | =end
89 |
90 | puts " mrhyde/#{MrHyde::VERSION}"
91 | puts " drjekyll/#{DrJekyll::VERSION}"
92 |
93 | puts " octopod/#{Jekyll::Octopod::VERSION::STRING}"
94 |
95 |
96 | puts " slideshow/#{SlideshowCli::VERSION}" ## note: Slideshow::VERSION is for models
97 |
98 | puts " pluto/#{PlutoCli::VERSION}" ## note: Pluto::VERSION is for models
99 |
100 |
101 | puts " rouge/#{Rouge.version}" ## incl. rougify
102 | puts " kramdown/#{Kramdown::VERSION}"
103 | puts " word-to-markdown/#{WordToMarkdown::VERSION}" # incl. w2m
104 |
105 | puts " quik/#{Quik::VERSION}"
106 |
107 |
108 | ### todo:
109 | ## (auto-)issue list commands for: !!!!!!!!!!
110 | ## drjekyll
111 | ## mrhyde
112 | ## slideshow
113 | ## pluto
114 | ## quik
115 |
116 | ###
117 | ## ## fix: hexapdf requires Ruby version >= 2.3.
118 | ## puts " hexapdf/#{HexaPDF::VERSION}"
119 |
120 |
121 | end # method about
122 |
123 | end # class Officetxt
124 |
125 |
126 |
127 | # say hello
128 | puts Officetxt.banner if defined?( $RUBYLIBS_DEBUG )
129 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/book/book.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | ## todo/fix:
5 | ## render - auto-include/merge (global) book opts ???
6 | ## build book twice (std, and inline:true)
7 | ##
8 | ## use global inline? helper instead of passing along
9 | ## opts[:inline] == true ???? - why, why not???
10 |
11 |
12 | module Bookfile
13 |
14 |
15 | class PageCtx ## page context for evaluate
16 |
17 | include HybookHelper
18 |
19 | attr_reader :content
20 |
21 | def initialize( config ) ## BookConfig
22 | @config = config
23 | @content = '' ## rename to body,text,buf,out - why, why not???
24 |
25 | ## track rendering (stack) level - only output if in top-level (1)
26 | ## -- check/todo - is there a better way???
27 | ## use a (separate) partial method or keep using on render method etc. ???
28 | ## any other ways??
29 | @level = 0
30 | end
31 |
32 |
33 | def write( text )
34 | puts "*** write:"
35 | ## puts " #{text}"
36 |
37 | @content << text
38 | end
39 |
40 | def render( name, opts={}, locals={} ) ## possible? - make opts required ??
41 | @level +=1
42 | puts "*** render(#{@level}) #{name}:"
43 |
44 | tmpl = File.read_utf8( "#{@config.templates_dir}/#{name}.md" ) ## name e.g. includes/_city
45 |
46 | ### if any locals defined; add "header/preamble w/ shortcuts" to template
47 | # e.g. country = locals[:country] etc.
48 | unless locals.empty?
49 | tmpl = _locals_code( locals ) + tmpl
50 | end
51 |
52 | text = TextUtils::PageTemplate.new( tmpl ).render( binding )
53 |
54 | ## note: only add text to content if top-level render call
55 | ## (do NOT add for partials/includes/etc.)
56 | if @level == 1
57 | @content << text
58 | end
59 |
60 | @level -=1
61 |
62 | ## puts " #{text}"
63 | text
64 | end
65 |
66 |
67 | def _locals_code( locals )
68 | ## convert locals hash to erb snippet with shortcuts
69 | ## e.g. country = locals[:country]
70 | ## and so on
71 |
72 | buf = "<%\n"
73 | locals.each do |k,v|
74 | puts " add local '#{k}' #{k.class.name} - #{v.class.name}"
75 |
76 | buf << "#{k} = locals[:#{k}];\n"
77 | end
78 | buf << "%>\n"
79 | buf
80 | end
81 |
82 | end # class PageCtx
83 |
84 |
85 |
86 | class BookCtx
87 |
88 | def initialize( config, book_opts={} )
89 | @config = config
90 | ## todo: add opts to config ???
91 | ## e.g. title, layout, inline ??? - why? why not??
92 | @builder = BookBuilder.new( config.pages_dir, book_opts )
93 | end
94 |
95 | ## change name to path - why, why not??
96 | def page( name, page_opts={} ) ## &block
97 | puts "[BookCtx#page] #{name} opts:#{page_opts.inspect}"
98 |
99 | puts "[BookCtx#page] before yield"
100 | ctx = PageCtx.new( @config ) ## pass along self (bookctx) as parent
101 | yield( ctx ) ## same as - ctx.instance_eval( &block )
102 | puts "[BookCtx#page] after yield"
103 |
104 | @builder.page( name, page_opts ) do |page|
105 | page.write ctx.content
106 | end
107 | end
108 |
109 | end # class BootCtx
110 |
111 |
112 | class BookDef
113 | def initialize( opts={}, proc )
114 | @opts = opts
115 | @proc = proc ## use name block (why,why not??)
116 | ## @block = block ## save block as proc ?? ??
117 | end
118 |
119 | def build( unzip_dir )
120 | defaults = { templates_dir: "#{unzip_dir}/_templates",
121 | pages_dir: "#{unzip_dir}/_pages" }
122 |
123 | ## note:
124 | ## (auto)build two versions:
125 | ## 1) multi-page version - for (easy) browsing
126 | ## 2) all-in-one-page version - for (easy)pdf conversion
127 |
128 | multi_page_ctx = BookCtx.new( BookConfig.new( defaults ))
129 | @proc.call( multi_page_ctx ) ## same as - ctx.instance_eval( &@codeblock ) -- use instance_eval - why, why not??
130 |
131 | one_page_ctx = BookCtx.new( BookConfig.new( defaults ), inline: true )
132 | @proc.call( one_page_ctx ) ## same as - ctx.instance_eval( &@codeblock ) -- use instance_eval - why, why not??
133 | end
134 | end # class BookDef
135 |
136 |
137 | end # module Bookfile
138 |
139 |
--------------------------------------------------------------------------------
/bookfile/attic/football.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | #####
5 | # todo/fix: use constant to set ./_pages - output (root) folder for generated pages
6 | # todo/fix: use constant to set layout e.g. book
7 |
8 |
9 | ## quick fix/hack for settings globals; fix: use config hash etc.
10 | PAGES_DIR = $pages_dir if defined?( $pages_dir )
11 | TEMPLATES_DIR = $templates_dir if defined?( $templates_dir )
12 |
13 | puts '[book] Welcome'
14 | puts "[book] Dir.pwd: #{Dir.pwd}"
15 | puts "[book] PAGES_DIR: #{PAGES_DIR}"
16 | puts "[book] TEMPLATES_DIR: #{TEMPLATES_DIR}"
17 |
18 |
19 | # -- model shortcuts
20 |
21 | Continent = WorldDb::Model::Continent
22 | Country = WorldDb::Model::Country
23 | Region = WorldDb::Model::Region
24 | City = WorldDb::Model::City
25 |
26 | Team = SportDb::Model::Team
27 | League = SportDb::Model::League
28 | Event = SportDb::Model::Event
29 | Game = SportDb::Model::Game
30 | Ground = SportDb::Model::Ground
31 |
32 | # -- custom code
33 |
34 | require_relative 'helpers/link'
35 | require_relative 'helpers/markdown'
36 | require_relative 'helpers/navbar'
37 | require_relative 'helpers/part'
38 | require_relative 'helpers/misc'
39 | require_relative 'helpers/city'
40 | require_relative 'helpers/ground'
41 | require_relative 'helpers/team'
42 | require_relative 'helpers/page'
43 |
44 |
45 | require_relative 'utils'
46 |
47 |
48 |
49 |
50 | def build_book( opts={} )
51 |
52 | ### title: '{{ site.title }}',
53 |
54 | b = BookBuilder.new( PAGES_DIR, opts )
55 |
56 |
57 | ### generate table of contents (toc)
58 |
59 | b.page( 'index', title: 'Contents',
60 | id: 'index' ) do |page|
61 | page.write render_cover( opts )
62 | page.write render_about( opts )
63 | page.write render_toc( opts )
64 | end
65 |
66 |
67 | # note: use same order as table of contents
68 | event_count = 0
69 | League.order(:id).each do |league|
70 | next if league.events.count == 0
71 |
72 | league.events.each do |event|
73 | puts " build event page [#{event_count+1}] #{event.key} #{event.title}..."
74 |
75 | key = event.key.gsub( '/', '_' )
76 | b.page( "events/#{key}", title: "#{event.title}",
77 | id: "#{key}" ) do |page|
78 | page.write render_event( event, opts )
79 | end
80 | ## b.divider() ## -- todo: add for inline version
81 | event_count += 1
82 | end
83 | end
84 |
85 | ## ### generate events index
86 | ## b.page( 'events', title: 'Events',
87 | ## id: 'events' ) do |page|
88 | ## page.write render_events( opts )
89 | ## end
90 |
91 |
92 | # note: use same order as table of contents
93 | country_count = 0
94 | Continent.order(:id).each do |continent|
95 | continent.countries.order(:name).each do |country|
96 | next if country.teams.count == 0 # skip country w/o teams
97 |
98 | puts " build country page [#{country_count+1}] #{country.key} #{country.title}..."
99 |
100 | path = country.to_path
101 | puts " path=#{path}"
102 | b.page( "teams/#{path}", title: "#{country.title} (#{country.code})",
103 | id: "#{country.key}" ) do |page|
104 | page.write render_country( country, opts )
105 | end
106 |
107 | country_count += 1
108 | end
109 | end
110 |
111 |
112 | b.page( 'stadiums', title: 'Stadiums',
113 | id: 'stadiums' ) do |page|
114 | page.write render_grounds( opts )
115 | end
116 |
117 |
118 | ### generate national teams a-z index
119 | b.page( 'national-teams', title: 'National Teams A-Z Index',
120 | id: 'national-teams' ) do |page|
121 | page.write render_national_teams_idx( opts )
122 | end
123 |
124 | ### generate teams a-z index
125 | b.page( 'clubs', title: 'Clubs A-Z Index',
126 | id: 'clubs' ) do |page|
127 | page.write render_clubs_idx( opts )
128 | end
129 |
130 | b.page( 'back', title: 'Back',
131 | id: 'back' ) do |page|
132 | page.write render_back( opts )
133 | end
134 |
135 | end # method build_book
136 |
137 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/database/database.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Bookfile
5 |
6 | class Database
7 | def initialize( db_config )
8 | @db_config = db_config
9 | end
10 |
11 | def connect
12 | print " connecting..."
13 | ActiveRecord::Base.establish_connection( @db_config )
14 | puts "OK"
15 | end
16 |
17 | def setup ## use connect/prepare - why, why not??
18 | prepare # step 1: prepare - require and include models
19 | connect # step 2: connect
20 | end
21 | end
22 |
23 |
24 |
25 | class WorldDef < Database ## change to WorldDatabase or DatabaseWorld - why, why not???
26 | def initialize( db_config ) ## check - if it works by default (no initialze specfied)
27 | super
28 | end
29 |
30 | def prepare ## change to require - why, why not??
31 | puts "setup world: #{@db_config.inspect}"
32 |
33 | res = require 'worlddb/models'
34 |
35 | ## also add to xxxx ???
36 | ## (possible to include as globals ???? how - Object.send :include ???) or
37 | ## Module.send :include ??
38 | ## find a better check - check for constants defined??? if not define???
39 | ## or use constant_missing handler???
40 |
41 | if res == false
42 | puts " todo/fix: WorldDb::Models already included ??"
43 | end
44 |
45 | puts "include WorldDb::Models"
46 |
47 | ### check/fix: include as globals/top-level!!! how? possible???
48 | Builder.send :include, WorldDb::Models
49 | PageCtx.send :include, WorldDb::Models
50 | HybookHelper.send :include, WorldDb::Models ## constants not accesible (include in module too)
51 | ## BookCtx.send :include, WorldDb::Models -- needed for Book context too?? why, why not??
52 | end # method prepare
53 | end # class WorldDef
54 |
55 |
56 | class BeerDef < Database ## change to BeerDatabase or DatabaseBeer - why, why not???
57 | def initialize( db_config ) ## check - if it works by default (no initialze specfied)
58 | super
59 | end
60 |
61 | def prepare ## change to require - why, why not??
62 | puts "setup beer: #{@db_config.inspect}"
63 |
64 | res = require 'beerdb/models'
65 |
66 | ## also add to xxxx ???
67 | ## (possible to include as globals ???? how - Object.send :include ???) or
68 | ## Module.send :include ??
69 |
70 | if res == false
71 | ## find a better check - check for constants defined??? if not define???
72 | ## or use constant_missing handler???
73 | puts " todo/fix: BeerDb::Models already included ??"
74 | end
75 |
76 | ## for now always include
77 | puts " include BeerDb::Models"
78 |
79 | ### check/fix: include as globals/top-level!!! how? possible???
80 | Builder.send :include, BeerDb::Models
81 | PageCtx.send :include, BeerDb::Models
82 | HybookHelper.send :include, BeerDb::Models ## constants not accesible (include in module too)
83 |
84 |
85 | end # method prepare
86 | end # class BeerDef
87 |
88 |
89 | class FootballDef < Database ## change to FootballDatabase or DatabaseFootball - why, why not???
90 | def initialize( db_config ) ## check - if it works by default (no initialze specfied)
91 | super
92 | end
93 |
94 | def prepare ## change to require - why, why not??
95 | puts "setup football: #{@db_config.inspect}"
96 |
97 | res = require 'sportdb/models'
98 |
99 | ## also add to xxxx ???
100 | ## (possible to include as globals ???? how - Object.send :include ???) or
101 | ## Module.send :include ??
102 |
103 | if res == false
104 | ## find a better check - check for constants defined??? if not define???
105 | ## or use constant_missing handler???
106 | puts " todo/fix: SportDb::Models already included ??"
107 | end
108 |
109 | ## for now always include
110 | puts " include SportDb::Models"
111 |
112 | ### check/fix: include as globals/top-level!!! how? possible???
113 | Builder.send :include, SportDb::Models
114 | PageCtx.send :include, SportDb::Models
115 | HybookHelper.send :include, SportDb::Models ## constants not accesible (include in module too)
116 |
117 |
118 | end # method prepare
119 | end # class FootballDef
120 |
121 |
122 | end # module Bookfile
123 |
--------------------------------------------------------------------------------
/catalogdb/lib/catalogdb/reader.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module CatalogDb
5 |
6 |
7 | class CardReader
8 |
9 | include LogUtils::Logging
10 |
11 |
12 | Card = Struct.new( :links, :categories ) ## use cats for categories - why? why not?
13 |
14 |
15 | def self.from_url( src ) # note: src assumed a string
16 | worker = Fetcher::Worker.new
17 | self.from_string( worker.read_utf8!( src ) )
18 | end
19 |
20 | def self.from_file( path )
21 | self.from_string( File.read_utf8( path ) )
22 | end
23 |
24 | def self.from_string( text )
25 | self.new( text )
26 | end
27 |
28 |
29 | def initialize( text )
30 | @text = text
31 | end
32 |
33 |
34 |
35 | ## example:
36 | ## - [Sinatra HQ](http://sinatrarb.com)
37 |
38 | LINK_ENTRY_REGEX = /\[
39 | (?[^\]]+) # 1st capture group (title)
40 | \]
41 | \(
42 | (?[^\)]+) # 2nd capture group (url)
43 | \)
44 | /x
45 |
46 |
47 | def read
48 |
49 | cards = []
50 | stack = [] ## header/heading stack; note: last_stack is stack.size; starts w/ 0
51 |
52 |
53 | # note: cut out; remove all html comments e.g.
54 | # supports multi-line comments too (e.g. uses /m - make dot match newlines)
55 | text = @text.gsub( //m, '' ) ## todo/fix: track/log cut out comments!!!
56 |
57 | text.each_line do |line|
58 |
59 | logger.debug "line: >#{line}<"
60 | line = line.rstrip ## remove (possible) trailing newline
61 |
62 | ## todo/fix: add to event reader too!!! - Thanks/Meta
63 | break if line =~ /^## (More|Thanks|Meta)/ # stop when hitting >## More< or Thanks or Meta section
64 | next if line =~ /^\s*$/ # skip blank lines
65 |
66 | m = nil
67 | if line =~ /^[ ]*(#+)[ ]+/ ## heading/headers - note: must escpape #
68 | s = StringScanner.new( line )
69 | s.skip( /[ ]*/ ) ## skip whitespaces
70 | markers = s.scan( /#+/)
71 | level = markers.size
72 | s.skip( /[ ]*/ ) ## skip whitespaces
73 | title = s.rest.rstrip
74 |
75 | logger.debug " heading level: #{level}, title: >#{title}<"
76 |
77 | level_diff = level - stack.size
78 |
79 | if level_diff > 0
80 | logger.debug "[CardReader] up +#{level_diff}"
81 | if level_diff > 1
82 | logger.error "fatal: level step must be one (+1) is +#{level_diff}"
83 | fail "[CardReader] level step must be one (+1) is +#{level_diff}"
84 | end
85 | elsif level_diff < 0
86 | logger.debug "[CardReader] down #{level_diff}"
87 | level_diff.abs.times { stack.pop }
88 | stack.pop
89 | else
90 | ## same level
91 | stack.pop
92 | end
93 | stack.push( [level,title] )
94 | logger.debug " stack: #{stack.inspect}"
95 |
96 | elsif line =~ /^([ ]*)-[ ]+/ ## list item
97 |
98 | ## check indent level
99 | ## note: skip sub list items for now (assume 2 or more spaces)
100 | indent = $1.to_s
101 | if indent.length >= 2
102 | logger.debug " *** skip link entry w/ indent #{indent.length}: >#{line}<"
103 | elsif( m=LINK_ENTRY_REGEX.match( line ) )
104 | logger.debug " link entry: #{line}"
105 |
106 | s = StringScanner.new( line )
107 | s.skip( /[ ]*-[ ]*/ ) ## skip leading list
108 |
109 |
110 | ## collect links e.g.
111 | ## [["Lotus HQ", "http://lotusrb.org"],
112 | ## [":octocat:", "https://github.com/lotus"],
113 | ## [":gem:", "https://rubygems.org/gems/lotusrb"],
114 | ## [":book:", "http://rubydoc.info/gems/lotusrb"]]
115 |
116 | links = s.rest.scan( LINK_ENTRY_REGEX )
117 | pp links
118 |
119 | categories = stack.map {|it| it[1] }.join(' › ')
120 | logger.debug " categories: #{categories}"
121 |
122 | card = Card.new( links, categories )
123 | ## pp card
124 | cards << card
125 | else
126 | logger.debug " *** skip list item line: #{line}"
127 | end
128 | else
129 | logger.debug " *** skip line: #{line}"
130 | end
131 | end
132 |
133 | cards
134 | end
135 |
136 | end # class CardReader
137 |
138 | end # module CatalogDb
139 |
--------------------------------------------------------------------------------
/bookfile/attic/beer.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | # -- custom code
5 |
6 | require_relative 'helpers/link'
7 | require_relative 'helpers/markdown'
8 | require_relative 'helpers/navbar'
9 | require_relative 'helpers/part'
10 | require_relative 'helpers/misc'
11 | require_relative 'helpers/beer'
12 | require_relative 'helpers/brewery'
13 | require_relative 'helpers/city'
14 | require_relative 'helpers/page'
15 |
16 |
17 | require_relative 'utils'
18 |
19 | ## quick fix/hack for settings globals; fix: use config hash etc.
20 | PAGES_DIR = $pages_dir if defined?( $pages_dir )
21 | TEMPLATES_DIR = $templates_dir if defined?( $templates_dir )
22 |
23 |
24 | puts '[book] Welcome'
25 | puts "[book] Dir.pwd: #{Dir.pwd}"
26 | puts "[book] PAGES_DIR: #{PAGES_DIR}"
27 | puts "[book] TEMPLATES_DIR: #{TEMPLATES_DIR}"
28 |
29 |
30 | ### model shortcuts
31 |
32 | require_relative 'models'
33 |
34 |
35 | #####
36 | # todo/fix: use constant to set ./_pages - output (root) folder for generated pages
37 | # todo/fix: use constant to set layout e.g. book
38 |
39 |
40 |
41 | def build_book_for_country( country_code, opts={} )
42 |
43 | country = Country.find_by_key!( country_code )
44 |
45 | b = BookBuilder.new( PAGES_DIR, opts )
46 |
47 | ### generate breweries index
48 |
49 | b.page( "#{country.key}-breweries", title: 'Breweries Index',
50 | id: "/#{country.key}-breweries" ) do |page|
51 | page.write render_breweries_idx( opts )
52 | end
53 |
54 | ### generate pages for countries
55 |
56 | puts "build country page #{country.key}..."
57 |
58 | path = country.to_path
59 | puts "path=#{path}"
60 | b.page( path, title: "#{country.title} (#{country.code})",
61 | id: "#{country.key}" ) do |page|
62 | page.write render_country( country, opts )
63 | end
64 |
65 | b.page( "#{country.key}-mini", title: "#{country.title} (#{country.code}) - Mini",
66 | id: "#{country.key}-mini" ) do |page|
67 | page.write render_country_mini( country, opts )
68 | end
69 |
70 | b.page( "#{country.key}-stats", title: "#{country.title} (#{country.code}) - Stats",
71 | id: "#{country.key}-stats.html" ) do |page|
72 | page.write render_country_stats( country, opts )
73 | end
74 |
75 | end
76 |
77 |
78 |
79 | def build_book( opts={} )
80 |
81 | b = BookBuilder.new( PAGES_DIR, opts )
82 |
83 | ### generate what's news in 2014
84 |
85 | years = [2014,2013,2012,2011,2010]
86 | years.each do |year|
87 | b.page( "#{year}", title: "What's News in #{year}?",
88 | id: "#{year}" ) do |page|
89 | page.write render_whats_news_in_year( year, opts )
90 | end
91 | end
92 |
93 |
94 | ### generate breweries index
95 |
96 | b.page( 'breweries', title: 'Breweries Index',
97 | id: 'breweries' ) do |page|
98 | page.write render_breweries_idx( opts )
99 | end
100 |
101 |
102 | ### generate beers index
103 |
104 | b.page( 'beers', title: 'Beers Index',
105 | id: 'beers' ) do |page|
106 | page.write render_beers_idx( opts )
107 | end
108 |
109 |
110 | ### generate brands index
111 |
112 | b.page( 'brands', title: 'Brands Index',
113 | id: 'brands' ) do |page|
114 | page.write render_brands_idx( opts )
115 | end
116 |
117 |
118 | ### generate table of contents (toc)
119 |
120 | b.page( 'index', title: 'Contents',
121 | id: 'index' ) do |page|
122 | page.write render_toc( opts )
123 | end
124 |
125 |
126 |
127 | ### generate pages for countries
128 |
129 | country_count=0
130 | # Country.where( "key in ('at','mx','hr', 'de', 'be', 'nl', 'cz')" ).each do |country|
131 | Country.order(:id).each do |country|
132 | beers_count = country.beers.count
133 | breweries_count = country.breweries.count
134 | next if beers_count == 0 && breweries_count == 0
135 |
136 | country_count += 1
137 | puts "build country page #{country.key}..."
138 |
139 | path = country.to_path
140 | puts "path=#{path}"
141 | b.page( path, title: "#{country.title} (#{country.code})",
142 | id: "#{country.key}" ) do |page|
143 | page.write render_country( country, opts )
144 | end
145 |
146 | ## todo - add b.divider() - for inline version - why, why not ????
147 |
148 | ## break if country_count == 3 # note: for testing only build three country pages
149 | end
150 |
151 | end # method build_book
152 |
153 |
--------------------------------------------------------------------------------
/almost-sinatra/lib/almost-sinatra.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | ###
5 | # almost_sinatra.rb
6 | # -- Sinatra refactored, only six lines now. A hack by Konstantin Haase.
7 | # see https://github.com/rkh/almost-sinatra/blob/master/almost_sinatra.rb
8 | #
9 | # e.g.
10 | #
11 | # %w.rack tilt date INT TERM..map{|l|trap(l){$r.stop}rescue require l};$u=Date;$z=($u.new.year + 145).abs;puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick"
12 | # $n=Module.new{extend Rack;a,D,S,q=Rack::Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m
13 | # %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}}}}
14 | # Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h=$u._jisx0301("hash, please");File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n=="#{n}"?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
15 | # %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Rack::Handler.get("webrick").run(a,Port:$z){|s|$r=s}}
16 | # %w[params session].map{|m|D.(m){q.send m}};a.use Rack::Session::Cookie;a.use Rack::Lock;D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Rack::Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}}
17 | #
18 | #
19 | # Why? Why? Why?
20 | #
21 | # > Until programmers stop acting like obfuscation is morally hazardous,
22 | # > they're not artists, just kids who don’t want their food to touch.
23 | # > -- \_why
24 |
25 |
26 |
27 |
28 | # Almost Sinatra - A Breakdown - Line 1/6
29 | #
30 | # Line 1:
31 | # %w.rack tilt date INT TERM..map{|l|trap(l){$r.stop}rescue require l};$u=Date;$z=($u.new.year + 145).abs;puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick"
32 |
33 | require 'rack'
34 | require 'tilt'
35 |
36 | trap( 'INT' ) { $server.stop } # rename $r to $server
37 | trap( 'TERM' ) { $server.stop }
38 |
39 | $port = 4567 # rename $z to $port
40 |
41 | puts "== Almost Sinatra has taken the stage on #{$port} for development with backup from Webrick"
42 |
43 |
44 | # Almost Sinatra - A Breakdown - Line 2/6
45 | #
46 | # Line 2:
47 | # $n=Module.new{extend Rack;a,D,S,q=Rack::Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m
48 |
49 | $n = Module.new do
50 | app = Rack::Builder.new # rename a to app
51 | req = nil # rename q to req
52 |
53 |
54 | # Almost Sinatra - A Breakdown - Line 3/6
55 | #
56 | # Line 3:
57 | # %w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}}}}
58 |
59 | ['get','post','put','delete'].each do |method|
60 | define_method method do |path, &block|
61 | app.map( path ) do
62 | run ->(env){ [200, {'Content-Type'=>'text/html'}, [app.instance_eval( &block )]]}
63 | end
64 | end
65 | end
66 |
67 |
68 | # Almost Sinatra - A Breakdown - Line 4/6
69 | #
70 | # Line 4:
71 | # Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h=$u._jisx0301("hash, please");File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n=="#{n}"?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
72 |
73 | Tilt.default_mapping.lazy_map.each do |ext, engines| # rename k to ext and v to engines
74 | define_method ext do |text, *args|
75 | # rename n to text and o to args
76 | template = Kernel.const_get(engines[0][0]).new(*args) do
77 | text
78 | end
79 | locals = (args[0].respond_to?(:[]) ? args[0][:locals] : nil) || {} # was o[0].try(:[],:locals)||{}
80 | template.render( app, locals )
81 | end
82 | end
83 |
84 |
85 |
86 |
87 | # Almost Sinatra - A Breakdown - Line 5/6
88 | #
89 | # Line 5:
90 | # %w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Rack::Handler.get("webrick").run(a,Port:$z){|s|$r=s}}
91 |
92 | # was END { ... }; change to run! method
93 | define_method 'run!' do
94 | Rack::Handler.get('webrick').run( app, Port:$port ) {|server| $server=server }
95 | end
96 |
97 |
98 | # Almost Sinatra - A Breakdown - Line 6/6
99 | #
100 | # Line 6:
101 | # %w[params session].map{|m|D.(m){q.send m}};a.use Rack::Session::Cookie;a.use Rack::Lock;D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Rack::Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}}
102 |
103 | ['params','session'].each do |method|
104 | define_method method do
105 | req.send method
106 | end
107 | end
108 |
109 | app.use Rack::Session::Cookie
110 | app.use Rack::Lock
111 | app.use Rack::Config do |env|
112 | req = Rack::Request.new( env )
113 | end
114 | end # Module.new
115 |
--------------------------------------------------------------------------------
/bookfile/lib/bookfile/package/package.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module Bookfile
5 |
6 | class BookPackage ## change to BookTemplates/BookTheme/BookPack/BookClass/BookStyle ???
7 | def initialize( name, opts={} )
8 | @name = name
9 | @opts = opts
10 | end
11 |
12 |
13 | def remote_zip_url # remote zip url
14 | ### note: use http:// for now - lets us use (personal proxy NOT working w/ https) for now
15 | ## "https://github.com/#{@name}/archive/gh-pages.zip"
16 | "http://github.com/#{@name}/archive/gh-pages.zip"
17 | end
18 |
19 | def local_zip_name
20 | ### note: replace / in name w/ --I--
21 | ## e.g. flatten the filename, that is, do NOT include any folders
22 | @name.gsub('/', '--I--') # note: will NOT include/return .zip extension
23 | end
24 |
25 | def local_zip_dir
26 | "./tmp"
27 | end
28 |
29 | def local_zip_path # local zip path
30 | "#{local_zip_dir}/#{local_zip_name}.zip"
31 | end
32 |
33 |
34 | =begin
35 | def local_unzip_dir() "./book"; end
36 |
37 | def local_scripts_dir
38 | ## fix: just use _scripts -- remove helpers in repo!!!
39 | "#{local_unzip_dir}/_scripts"
40 | end
41 | =end
42 |
43 |
44 | def download
45 | ## logger.info( "download book package '#{@name}'" )
46 | ## logger.info( " from '#{remote_zip_url}'" )
47 | ## logger.info( " to '#{local_zip_path}'..." )
48 |
49 | ## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
50 | src = remote_zip_url
51 | dest_zip = local_zip_path
52 |
53 | ## make sure dest folder exists
54 | FileUtils.mkdir_p( local_zip_dir ) unless Dir.exists?( local_zip_dir )
55 |
56 | fetch_book_templates( src, dest_zip )
57 | end
58 |
59 |
60 | def unzip( unzip_dir )
61 | src = local_zip_path
62 | dest_unzip = unzip_dir ## local_unzip_dir
63 |
64 | ## check if folders exists? if not create folder in path
65 | FileUtils.mkdir_p( dest_unzip ) unless Dir.exists?( dest_unzip )
66 |
67 | unzip_book_templates( src, dest_unzip )
68 | end
69 |
70 |
71 | def prepare( unzip_dir ) ## change to require - why, why not??
72 | puts "auto-require/include book scripts in '#{unzip_dir}/_scripts'"
73 |
74 | files = Dir["#{unzip_dir}/_scripts/**/*.rb"]
75 | pp files
76 |
77 | files.each_with_index do |file,idx|
78 | ## todo/check: check for exceptions???
79 | puts " [#{idx+1}/#{files.count}] try auto-require '#{file}'..."
80 | require file
81 | end
82 |
83 | ## include Hytext::Helper or use HytextHelper ??
84 | ## include Bookfile::Helper or use BookfileHelper ??
85 | ## check Rails example names for helper modules
86 | ## get Helper module name from book template name ???
87 |
88 | =begin
89 | res = require 'worlddb/models'
90 | if res
91 | puts " include WorldDb::Models"
92 |
93 | Builder.send :include, WorldDb::Models
94 | ## PageCtx.send :include, WorldDb::Models
95 | ## BookCtx.send :include, WorldDb::Models
96 |
97 | ## also add to xxxx ???
98 | ## (possible to include as globals ???? how - Object.send :include ???) or
99 | ## Module.send :include ??
100 | else
101 | ## find a better check - check for constants defined??? if not define???
102 | ## or use constant_missing handler???
103 | puts " assume WorldDb::Models already included ??"
104 | end
105 | =end
106 | end
107 |
108 |
109 | private
110 |
111 | def fetch_book_templates( src, dest )
112 | ## step 1 - fetch archive
113 | worker = Fetcher::Worker.new
114 | worker.copy( src, dest )
115 | ### fix: add src.sha5
116 | ### inside folder
117 | ### lets us check if current HEAD version is in place across datafiles etc.
118 | ## - try HTTP HEAD ?? to check?
119 | end
120 |
121 |
122 | ######
123 | # fix/todo:
124 | # exclude _pages folder for now
125 | # lets us include working live sample pages in template pack
126 |
127 | def unzip_book_templates( src, dest, opts={} )
128 | ### todo/fix: rename or remove root folder -- use opts { root: false or something??}
129 | # e.g
130 | # !/beer-gh-pages/_templates/ becomes
131 | # !/_templates/ etc.
132 |
133 | Zip::File.open( src ) do |zipfile|
134 | zipfile.each do |file|
135 | if file.directory?
136 | puts " skip directory zip entry - #{file.name}"
137 | else
138 | name = file.name[ file.name.index('/')+1..-1] ## cut-off root/first path entry
139 | path = File.join( dest, name)
140 | puts " unzip file zip entry - #{file.name} to #{path}"
141 | FileUtils.mkdir_p( File.dirname( path) )
142 | zipfile.extract(file, path) unless File.exist?(path)
143 | end
144 | end
145 | end
146 | end
147 |
148 | end # class BookPackage
149 |
150 | end # module Bookfile
151 |
152 |
--------------------------------------------------------------------------------
/record/test/test_record.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_record.rb
6 |
7 |
8 | require 'helper'
9 |
10 | class TestRecord < MiniTest::Test
11 |
12 | def test_class_style1
13 | clazz1 = Record.define do
14 | field :brewery, :string # fix: do NOT use 'Brewery' - name SHOULD be a valid variable name
15 | field :city, :string
16 | field :name ## default type is :string
17 | field :abv, Float ## allow type specified as class
18 | end
19 | pp clazz1
20 | pp clazz1.fields
21 |
22 | assert true ## assume ok if we get here
23 | end
24 |
25 | Beer = Record.define do
26 | string :brewery # fix: do NOT use 'Brewery' - name SHOULD be a valid variable name
27 | string :city
28 | string :name
29 | float :abv
30 | end
31 |
32 | class BeerClassic < Record::Base
33 | field :brewery
34 | field :city
35 | field :name
36 | field :abv, Float
37 | end
38 |
39 |
40 | def test_class_style2
41 | clazz2 = Record.define do
42 | string :brewery # fix: do NOT use 'Brewery' - name SHOULD be a valid variable name
43 | string :city
44 | string :name
45 | float :abv
46 | end
47 | pp clazz2
48 | pp clazz2.class.name
49 | pp clazz2.fields
50 |
51 | clazz2b = Record.define do |rec| ## try "yield"-style dsl with block.arity == 1
52 | rec.string :brewery
53 | rec.string :city
54 | rec.string :name
55 | rec.float :abv
56 | end
57 | pp clazz2b
58 | pp clazz2b.class.name
59 | pp clazz2b.fields
60 |
61 | assert true ## assume ok if we get here
62 | end
63 |
64 |
65 |
66 | def test_classic
67 | pp BeerClassic.fields
68 | pp BeerClassic.field_names
69 | pp BeerClassic.columns ## try fields alias
70 | pp BeerClassic.column_names ## try field_names alias
71 |
72 | assert_equal [:brewery, :city, :name, :abv], BeerClassic.field_names
73 | assert_equal [String, String, String, Float], BeerClassic.field_types
74 |
75 | beer = BeerClassic.new
76 | pp beer
77 | beer.update( abv: 7.0 )
78 | beer.update( brewery: 'Andechser Klosterbrauerei',
79 | city: 'Andechs',
80 | name: 'Doppelbock Dunkel' )
81 | pp beer
82 |
83 | assert_equal 7.0, beer.abv
84 | assert_equal 'Andechser Klosterbrauerei', beer.brewery
85 | assert_equal 'Andechs', beer.city
86 | assert_equal 'Doppelbock Dunkel', beer.name
87 | end
88 |
89 |
90 | def test_new
91 | beer = Beer.new
92 | pp beer
93 | beer.update( abv: 7.0 )
94 | beer.update( brewery: 'Andechser Klosterbrauerei',
95 | city: 'Andechs',
96 | name: 'Doppelbock Dunkel' )
97 | pp beer
98 |
99 | assert_equal 7.0, beer.abv
100 | assert_equal 'Andechser Klosterbrauerei', beer.brewery
101 | assert_equal 'Andechs', beer.city
102 | assert_equal 'Doppelbock Dunkel', beer.name
103 |
104 |
105 | pp beer.abv
106 | pp beer.abv = 7.0
107 | pp beer.abv
108 | assert_equal 7.0, beer.abv
109 |
110 | pp beer.parse_abv( '7%' ) ## (auto-)converts/typecasts string to specified type (e.g. float)
111 | assert_equal 7.0, beer.abv
112 |
113 | pp beer.name
114 | pp beer.name = 'Doppelbock Dunkel'
115 | pp beer.name
116 | assert_equal 'Doppelbock Dunkel', beer.name
117 |
118 |
119 | beer2 = Beer.new( brewery: 'Andechser Klosterbrauerei',
120 | city: 'Andechs',
121 | name: 'Doppelbock Dunkel' )
122 | pp beer2
123 |
124 | assert_nil beer2.abv
125 | assert_equal 'Andechser Klosterbrauerei', beer2.brewery
126 | assert_equal 'Andechs', beer2.city
127 | assert_equal 'Doppelbock Dunkel', beer2.name
128 | end
129 |
130 | def test_parse
131 | values = ['Andechser Klosterbrauerei',
132 | 'Andechs',
133 | 'Doppelbock Dunkel',
134 | '7%']
135 |
136 | beer = Beer.new
137 | beer.parse( values )
138 |
139 | assert_equal values[0], beer.brewery
140 | assert_equal values[1], beer.city
141 | assert_equal values[2], beer.name
142 | assert_equal values[3].to_f, beer.abv
143 |
144 | assert_equal values[0], beer[0]
145 | assert_equal values[1], beer[1]
146 | assert_equal values[2], beer[2]
147 | assert_equal values[3].to_f, beer[3]
148 |
149 | assert_equal values[0], beer.values[0]
150 | assert_equal values[1], beer.values[1]
151 | assert_equal values[2], beer.values[2]
152 | assert_equal values[3].to_f, beer.values[3]
153 |
154 | assert_equal values[0], beer[:brewery]
155 | assert_equal values[1], beer[:city]
156 | assert_equal values[2], beer[:name]
157 | assert_equal values[3].to_f, beer[:abv]
158 |
159 | assert_equal values[0], beer['Brewery']
160 | assert_equal values[1], beer['City']
161 | assert_equal values[2], beer['Name']
162 | assert_equal values[3].to_f, beer['Abv']
163 | end
164 |
165 | end # class TestRecord
166 |
--------------------------------------------------------------------------------
/record/lib/record/base.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Record
4 |
5 | class Base
6 |
7 | def self.fields ## note: use class instance variable (@fields and NOT @@fields)!!!! (derived classes get its own copy!!!)
8 | @fields ||= []
9 | end
10 |
11 | def self.field_names ## rename to header - why? why not?
12 | ## return header row, that is, all field names in an array
13 | ## todo: rename to field_names or just names - why? why not?
14 | ## note: names are (always) symbols!!!
15 | fields.map {|field| field.name }
16 | end
17 |
18 | def self.field_types
19 | ## note: types are (always) classes!!!
20 | fields.map {|field| field.type }
21 | end
22 |
23 |
24 |
25 | def self.field( name, type=:string )
26 | num = fields.size ## auto-calc num(ber) / position index - always gets added at the end
27 | field = Field.new( name, num, type )
28 | fields << field
29 |
30 | define_field( field ) ## auto-add getter,setter,parse/typecast
31 | end
32 |
33 | def self.define_field( field )
34 | name = field.name ## note: always assumes a "cleaned-up" (symbol) name
35 | num = field.num
36 |
37 | define_method( name ) do
38 | instance_variable_get( "@values" )[num]
39 | end
40 |
41 | define_method( "#{name}=" ) do |value|
42 | instance_variable_get( "@values" )[num] = value
43 | end
44 |
45 | define_method( "parse_#{name}") do |value|
46 | instance_variable_get( "@values" )[num] = field.typecast( value )
47 | end
48 | end
49 |
50 | ## column/columns aliases for field/fields
51 | ## use self << with alias_method - possible? works? why? why not?
52 | def self.column( name, type=:string ) field( name, type ); end
53 | def self.columns() fields; end
54 | def self.column_names() field_names; end
55 | def self.column_types() field_types; end
56 |
57 |
58 |
59 |
60 | def self.build_hash( values ) ## find a better name - build_attrib? or something?
61 | ## convert to key-value (attribute) pairs
62 | ## puts "== build_hash:"
63 | ## pp values
64 |
65 | ## e.g. [[],[]] return zipped pairs in array as (attribute - name/value pair) hash
66 | Hash[ field_names.zip(values) ]
67 | end
68 |
69 |
70 |
71 | def self.typecast( new_values )
72 | values = []
73 |
74 | ##
75 | ## todo: check that new_values.size <= fields.size
76 | ##
77 | ## fields without values will get auto-filled with nils (or default field values?)
78 |
79 | ##
80 | ## use fields.zip( new_values ).map |field,value| ... instead - why? why not?
81 | fields.each_with_index do |field,i|
82 | value = new_values[i] ## note: returns nil if new_values.size < fields.size
83 | values << field.typecast( value )
84 | end
85 | values
86 | end
87 |
88 |
89 | def parse( new_values ) ## use read (from array) or read_values or read_row - why? why not?
90 |
91 | ## todo: check if values overshadowing values attrib is ok (without warning?) - use just new_values (not values)
92 | @values = self.class.typecast( new_values )
93 | self ## return self for chaining
94 | end
95 |
96 |
97 | def values
98 | ## return array of all record values (typed e.g. float, integer, date, ..., that is,
99 | ## as-is and NOT auto-converted to string
100 | @values
101 | end
102 |
103 |
104 |
105 | def [](key)
106 | if key.is_a? Integer
107 | @values[ key ]
108 | elsif key.is_a? Symbol
109 | ## try attribute access
110 | send( key )
111 | else ## assume string
112 | ## downcase and symbol-ize
113 | ## remove spaces too -why? why not?
114 | ## todo/fix: add a lookup mapping for (string) titles (Team 1, etc.)
115 | send( key.downcase.to_sym )
116 | end
117 | end
118 |
119 |
120 |
121 | def to_h ## use to_hash - why? why not? - add attributes alias - why? why not?
122 | self.class.build_hash( @values )
123 | end
124 |
125 | def initialize( **kwargs )
126 | @values = []
127 | update( kwargs )
128 | end
129 |
130 | def update( **kwargs )
131 | pp kwargs
132 | kwargs.each do |name,value|
133 | ## note: only convert/typecast string values
134 | if value.is_a?( String )
135 | send( "parse_#{name}", value ) ## note: use parse_ setter (for typecasting)
136 | else ## use "regular" plain/classic attribute setter
137 | send( "#{name}=", value )
138 | end
139 | end
140 |
141 | ## todo: check if args.first is an array (init/update from array)
142 | self ## return self for chaining
143 | end
144 | end ## class Base
145 |
146 |
147 |
148 | #########
149 | # alternative class (record) builder
150 |
151 | def self.define( super_class=Base, &block ) ## check: rename super_class to base - why? why not?
152 | builder = Builder.new( super_class )
153 | if block.arity == 1
154 | block.call( builder )
155 | ## e.g. allows "yield" dsl style e.g.
156 | ## Record.define do |rec|
157 | ## rec.string :team1
158 | ## rec.string :team2
159 | ## end
160 | ##
161 | else
162 | builder.instance_eval( &block )
163 | ## e.g. shorter "instance eval" dsl style e.g.
164 | ## Record.define do
165 | ## string :team1
166 | ## string :team2
167 | ## end
168 | end
169 | builder.to_record
170 | end
171 |
172 | end # module Record
173 |
--------------------------------------------------------------------------------
/bookman/lib/bookman/bookman.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Bookman
4 |
5 | class Bookman
6 |
7 | ## todo: add logutils/logger here
8 |
9 | def initialize( config )
10 | @config = config
11 |
12 | ## for debugging dump main config settings
13 | puts "dataset:"
14 | puts " - collection: #{@config.collection}"
15 | puts " - setup: #{@config.setup}"
16 | ## todo: add db_path - why, why not???
17 |
18 | puts "datafile:"
19 | puts " - datafile_url (remote): #{@config.datafile_url}"
20 | puts " - datafile_dir (local): #{@config.datafile_dir}"
21 | puts " - datafile_path (local): #{@config.datafile_path}"
22 |
23 | puts "bookfile:"
24 | puts " - bookfile_url (remote): #{@config.bookfile_url}"
25 | puts " - bookfile_dir (local): #{@config.bookfile_dir}"
26 | puts " - bookfile_path (local): #{@config.bookfile_path}"
27 | ## todo: add bookfile_unzip_path - why, why not???
28 | end
29 |
30 |
31 | def dl_datasets
32 | ## fetch Datafile
33 | datafile_dir = @config.datafile_dir
34 | datafile_path = @config.datafile_path
35 |
36 | ## check if folders exists? if not create folder in path
37 | FileUtils.mkdir_p( datafile_dir ) unless Dir.exists?( datafile_dir )
38 |
39 | ## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
40 | src = @config.datafile_url
41 | ## dest will be something like './Datafile'
42 |
43 | fetch_datafile( src, datafile_path )
44 |
45 | datafile = Datafile::Datafile.load_file( datafile_path )
46 | datafile.dump ## for debugging
47 | datafile.download ## datafile step 1 - download all datasets/zips
48 | end
49 |
50 |
51 | def dl_book_templates
52 | ## fetch Bookfile
53 | bookfile_dir = @config.bookfile_dir
54 | bookfile_path = @config.bookfile_path
55 |
56 | ## check if folders exists? if not create folder in path
57 | FileUtils.mkdir_p( bookfile_dir ) unless Dir.exists?( bookfile_dir )
58 |
59 | ## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
60 | src = @config.bookfile_url
61 | ## dest will be something like './Bookfile'
62 |
63 | fetch_bookfile( src, bookfile_path )
64 |
65 |
66 | bookfile = Bookfile::Bookfile.load_file( bookfile_path )
67 |
68 | bookfile.dump ## for debugging
69 | bookfile.download ## bookfile step 1 - download all packages/zips (defaults to ./tmp)
70 |
71 | ## todo/check: already checked in unzip if folder exists???
72 | dest_unzip = @config.book_templates_unzip_dir
73 | FileUtils.mkdir_p( dest_unzip ) unless Dir.exists?( dest_unzip )
74 |
75 | bookfile.unzip( dest_unzip ) ## bookfile step 2 - unzip book templates
76 | end
77 |
78 |
79 | def connect
80 | db_path = @config.db_path
81 |
82 | db_config = {
83 | adapter: 'sqlite3',
84 | database: db_path
85 | }
86 |
87 | pp db_config
88 | ActiveRecord::Base.establish_connection( db_config )
89 |
90 | c = ActiveRecord::Base.connection
91 |
92 | ## try to speed up sqlite
93 | ## see http://www.sqlite.org/pragma.html
94 | c.execute( 'PRAGMA synchronous=OFF;' )
95 | c.execute( 'PRAGMA journal_mode=OFF;' )
96 | ## c.execute( 'PRAGMA journal_mode=MEMORY;' )
97 | c.execute( 'PRAGMA temp_store=MEMORY;' )
98 | end
99 |
100 |
101 | def build_db
102 | ## clean; remove db if exits
103 |
104 | db_path = @config.db_path
105 | FileUtils.rm( db_path ) if File.exists?( db_path )
106 |
107 | connect()
108 | @config.create_db!
109 |
110 | datafile_path = @config.datafile_path
111 | pp datafile_path
112 |
113 |
114 | ### hack/quick fix for at,de - "standalone quick test": todo
115 | ## - find something better
116 | if datafile_path.end_with?( 'at.rb' ) ||
117 | datafile_path.end_with?( '/at/Datafile' )
118 | ## standalone austria for debugging add country
119 | WorldDb::Model::Country.create!( key: 'at',
120 | name: 'Austria',
121 | code: 'AUT',
122 | pop: 0,
123 | area: 0 )
124 | elsif datafile_path.end_with?( 'de.rb' ) ||
125 | datafile_path.end_with?( '/de/Datafile' )
126 | WorldDb::Model::Country.create!( key: 'de',
127 | name: 'Germany',
128 | code: 'GER',
129 | pop: 0,
130 | area: 0 )
131 | else
132 | # no special case; continue
133 | puts "[debug] - no special world archive case w/ start script; continue"
134 | end
135 |
136 |
137 | datafile = Datafile::Datafile.load_file( datafile_path )
138 | datafile.dump ## for debugging
139 |
140 | ## set "global" logger to debug
141 | LogUtils::Logger.root.level = :debug
142 |
143 | datafile.read ## datafile step 2 - read all datasets
144 | end
145 |
146 |
147 | def build_book
148 | connect()
149 |
150 | bookfile_path = @config.bookfile_path
151 |
152 | bookfile = Bookfile::Bookfile.load_file( bookfile_path )
153 | bookfile.dump ## for debugging
154 |
155 | ### fix:
156 | ### assume WorldDb::Models already included ??
157 | ## - for now always include on prepare
158 | bookfile.prepare( @config.book_templates_unzip_dir )
159 |
160 | puts " contintents: #{WorldDb::Model::Continent.count}" ## for debugging
161 |
162 | bookfile.build( @config.book_templates_unzip_dir )
163 |
164 | puts 'Done.'
165 | end
166 |
167 |
168 | def run_jekyll
169 | # change cwd folder
170 | cwd = FileUtils.pwd
171 | puts "cwd (before): #{FileUtils.pwd}"
172 | FileUtils.cd( @config.book_templates_unzip_dir )
173 | puts "cwd (after): #{FileUtils.pwd}"
174 |
175 | ## use `cd #{book_dir}; jekyll build` -- why, why not???
176 | puts `jekyll build`
177 |
178 | # restore cwd folder
179 | FileUtils.cd( cwd )
180 | end
181 |
182 |
183 | def build
184 | ## all-in-one; do everything; complete all steps
185 | dl_datasets
186 | dl_book_templates
187 |
188 | build_db
189 | build_book
190 | run_jekyll
191 | end
192 |
193 |
194 | private
195 |
196 | def fetch_datafile( src, dest )
197 | worker = Fetcher::Worker.new
198 | worker.copy( src, dest )
199 | end
200 |
201 | def fetch_bookfile( src, dest )
202 | worker = Fetcher::Worker.new
203 | worker.copy( src, dest )
204 | end
205 |
206 | end # class Bookman
207 |
208 | end # module Bookman
209 |
--------------------------------------------------------------------------------