petrify 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4196552f668eeff27be617562e588c9d56ad1939
4
+ data.tar.gz: cf67c0b5d6e3d78c101b4f9be65121d74da51393
5
+ SHA512:
6
+ metadata.gz: a7aebd7d716a7824d0e698271a647ccadda03889bb84707277a277a1f23c05659f8ff1cb9c225781342d2f6c1f38591baaa0006c51b88647c0102a3b3470abf0
7
+ data.tar.gz: 282def2a456fbbcc08bcdfd82cef1b9ca2f2bfdca94e5ac8c597082d107b44405dd422d7fc41b39f03b2f1e5c4e2e7a0d5a254df5f1f2e20377d53d0493b37d3
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in petrify.gemspec
4
+ gemspec
@@ -0,0 +1,35 @@
1
+ # Petrify
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/petrify`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'petrify'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install petrify
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/petrify.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "petrify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,60 @@
1
+ require 'haml'
2
+ require 'csv'
3
+ require 'logger'
4
+ require "petrify/version"
5
+
6
+ module Petrify
7
+ @@output_dir = '_site'
8
+ @@working_dir = File.join(Dir.pwd, @@output_dir)
9
+ @@views_dir = 'views'
10
+ @@layout_fn = File.join(@@views_dir, 'layout.haml')
11
+
12
+ # https://stackoverflow.com/questions/917566/ruby-share-logger-instance-among-module-classes#6768164
13
+ @@log = Logger.new($stdout)
14
+ @@log.level = Logger::INFO
15
+
16
+ def self.page(path_items, template, locals = {})
17
+ dir = create_path(path_items)
18
+ fn = File.join(dir, 'index.html')
19
+
20
+ # https://stackoverflow.com/questions/6125265/using-layouts-in-haml-files-independently-of-rails
21
+ html = Haml::Engine.new(File.read(@@layout_fn)).render(Object.new, locals) do
22
+ Haml::Engine.new(File.read(File.join(@@views_dir, "#{template}.haml"))).render(Object.new, locals)
23
+ end
24
+
25
+ File.write(fn, html)
26
+ @@log.info fn
27
+ # TODO - add page to sitemap.xml or sitemap.txt
28
+ # https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190
29
+ end
30
+
31
+ def self.csv(path_items, filename, data)
32
+ dir = create_path(path_items)
33
+ fn = File.join(dir, filename + '.csv')
34
+
35
+ csv_string = CSV.generate do |csv|
36
+ csv << data.first.keys # header row
37
+ data.each { |row| csv << row.values }
38
+ end
39
+
40
+ File.write(fn, csv_string)
41
+ @@log.info fn
42
+ end
43
+
44
+ def self.setup
45
+ # Recursively delete working directory to ensure no redundant files are left behind from previous builds.
46
+ # But preserve dot-files (especially .git directory)
47
+ FileUtils.rm_r(Dir.glob(File.join(@@working_dir, '*')))
48
+ Dir.mkdir(@@working_dir) unless File.directory?(@@working_dir)
49
+
50
+ # Copy `public` dir to output dir
51
+ FileUtils.copy_entry('public', @@working_dir)
52
+ end
53
+
54
+ def self.create_path(path_items)
55
+ dir = File.join(@@output_dir, path_items)
56
+ FileUtils.mkdir_p(dir)
57
+ @@log.debug dir
58
+ dir
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Petrify
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "petrify/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "petrify"
8
+ spec.version = Petrify::VERSION
9
+ spec.authors = ["Adrian Short"]
10
+ spec.email = ['rubygems@adrianshort.org']
11
+ spec.licenses = ['MIT']
12
+ spec.summary = %q{A data(base)-driven static site generator with Haml templates.}
13
+ #spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/adrianshort/petrify/"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_runtime_dependency "haml", "~> 5.0"
26
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: petrify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Short
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: haml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description:
56
+ email:
57
+ - rubygems@adrianshort.org
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - bin/console
67
+ - bin/setup
68
+ - lib/petrify.rb
69
+ - lib/petrify/version.rb
70
+ - petrify.gemspec
71
+ homepage: https://github.com/adrianshort/petrify/
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.12
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: A data(base)-driven static site generator with Haml templates.
95
+ test_files: []