Basic project layout.

This commit is contained in:
Yorick Peterse 2014-02-26 19:50:16 +01:00
parent 626bb9e0b6
commit 702477ca28
25 changed files with 308 additions and 0 deletions

13
.yardopts Normal file
View File

@ -0,0 +1,13 @@
./lib/oga/**/*.rb ./lib/oga.rb
-m markdown
-M kramdown
-o yardoc
-r ./README.md
--private
--protected
--asset ./doc/css/common.css:css/common.css
--verbose
-
./doc/*.md
LICENSE
CONTRIBUTING.md

3
Gemfile Normal file
View File

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gemspec

44
Gemfile.lock Normal file
View File

@ -0,0 +1,44 @@
PATH
remote: .
specs:
oga (0.0.1)
ast
racc
GEM
remote: https://rubygems.org/
specs:
ast (1.1.0)
cliver (0.3.2)
diff-lcs (1.2.5)
docile (1.1.3)
kramdown (1.3.2)
multi_json (1.8.4)
racc (1.4.11)
rake (10.1.1)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
yard (0.8.7.3)
PLATFORMS
ruby
DEPENDENCIES
cliver
kramdown
oga!
rake
rspec
simplecov
yard

0
MANIFEST Normal file
View File

24
Rakefile Normal file
View File

@ -0,0 +1,24 @@
require 'bundler/gem_tasks'
require 'digest/sha2'
require 'rake/clean'
require 'cliver'
GEMSPEC = Gem::Specification.load('oga.gemspec')
LEXER_INPUT = 'lib/oga/lexer.rl'
LEXER_OUTPUT = 'lib/oga/lexer.rb'
#PARSER_INPUT = 'lib/oga/parser.y'
#PARSER_OUTPUT = 'lib/oga/parser.rb'
GENERATED_FILES = ['coverage', 'yardoc', LEXER_OUTPUT]
GENERATED_FILES.each do |file|
CLEAN << file if File.exist?(file)
end
Dir['./task/*.rake'].each do |task|
import(task)
end
task :default => :test

0
checksum/.gitkeep Normal file
View File

0
doc/.gitkeep Normal file
View File

26
doc/DCO.md Normal file
View File

@ -0,0 +1,26 @@
# @title DCO
# Developer's Certificate of Origin 1.0
By making a contribution to this project, I certify that:
1. The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file LICENSE; or
2. The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file LICENSE; or
3. The contribution was provided directly to me by some other
person who certified (1), (2) or (3) and I have not modified
it.
4. I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

2
doc/changelog.md Normal file
View File

@ -0,0 +1,2 @@
# @title Changelog
# Changelog

0
doc/css/.gitkeep Normal file
View File

69
doc/css/common.css Normal file
View File

@ -0,0 +1,69 @@
body
{
font-size: 14px;
line-height: 1.6;
margin: 0 auto;
max-width: 960px;
}
p code
{
background: #f2f2f2;
padding-left: 3px;
padding-right: 3px;
}
pre.code
{
font-size: 13px;
line-height: 1.4;
overflow: auto;
}
/**
* YARD uses generic table styles, using a special class means those tables
* don't get messed up.
*/
.table
{
border: 1px solid #ccc;
border-right: none;
border-collapse: separate;
border-spacing: 0;
text-align: left;
}
.table.full
{
width: 100%;
}
.table .field_name
{
min-width: 160px;
}
.table thead tr th.no_sort:first-child
{
width: 25px;
}
.table thead tr th, .table tbody tr td
{
border-bottom: 1px solid #ccc;
border-right: 1px solid #ccc;
min-width: 20px;
padding: 8px 5px;
text-align: left;
vertical-align: top;
}
.table tbody tr:last-child td
{
border-bottom: none;
}
.table tr:nth-child(odd) td
{
background: #f9f9f9;
}

1
lib/oga.rb Normal file
View File

@ -0,0 +1 @@
require 'ast'

3
lib/oga/version.rb Normal file
View File

@ -0,0 +1,3 @@
module Oga
VERSION = '0.0.1'
end # Oga

27
oga.gemspec Normal file
View File

@ -0,0 +1,27 @@
require File.expand_path('../lib/oga/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'oga'
s.version = Oga::VERSION
s.authors = ['Yorick Peterse']
s.email = 'yorickpeterse@gmail.com'
s.summary = 'A pure Ruby HTML/XML parser.'
s.homepage = 'https://github.com/yorickpeterse/oga/'
s.description = s.summary
s.license = 'MIT'
s.files = File.read(File.expand_path('../MANIFEST', __FILE__)).split("\n")
s.has_rdoc = 'yard'
s.required_ruby_version = '>= 1.9.3'
s.add_dependency 'racc'
s.add_dependency 'ast'
s.add_development_dependency 'cliver'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'yard'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'kramdown'
end

13
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,13 @@
require 'rspec'
if ENV['COVERAGE']
require_relative 'support/simplecov'
end
require_relative '../lib/oga'
require_relative 'support/parsing'
RSpec.configure do |config|
config.color = true
config.include Oga::ParsingHelpers
end

14
spec/support/parsing.rb Normal file
View File

@ -0,0 +1,14 @@
module Oga
module ParsingHelpers
##
# Builds an AST node.
#
# @param [Symbol] type
# @param [Array] cihldren
# @return [Oga::AST::Node]
#
def s(type, *children)
return Oga::AST::Node.new(type, children)
end
end # ParsingHelpers
end # Oga

12
spec/support/simplecov.rb Normal file
View File

@ -0,0 +1,12 @@
require 'simplecov'
SimpleCov.configure do
root File.expand_path('../../../', __FILE__)
command_name 'rspec'
project_name 'oga'
add_filter 'spec'
add_filter 'lib/oga/version'
end
SimpleCov.start

4
task/build.rake Normal file
View File

@ -0,0 +1,4 @@
desc 'Builds a new Gem and its checksum'
task :signed_build => [:build] do
Rake::Task['checksum'].invoke
end

13
task/checksum.rake Normal file
View File

@ -0,0 +1,13 @@
desc 'Creates a SHA512 checksum of the current version'
task :checksum do
checksums = File.expand_path('../../checksum', __FILE__)
name = "#{GEMSPEC.name}-#{GEMSPEC.version}.gem"
path = File.join(File.expand_path('../../pkg', __FILE__), name)
checksum_name = File.basename(path) + '.sha512'
checksum = Digest::SHA512.new.hexdigest(File.read(path))
File.open(File.join(checksums, checksum_name), 'w') do |handle|
handle.write(checksum)
end
end

5
task/generate.rake Normal file
View File

@ -0,0 +1,5 @@
desc 'Generates auto-generated files'
task :generate => [:lexer, :parser]
desc 'Regenerates auto-generated files'
task :regenerate => [:clean, :generate]

8
task/lexer.rake Normal file
View File

@ -0,0 +1,8 @@
rule '.rb' => '.rl' do |task|
Cliver.assert('ragel', '~> 6.8')
sh "ragel -F1 -R #{task.source} -o #{task.name}"
end
desc 'Generates the lexer'
task :lexer => [LEXER_OUTPUT]

9
task/manifest.rake Normal file
View File

@ -0,0 +1,9 @@
desc 'Generates the MANIFEST file'
task :manifest do
generated = GENERATED_FILES.map { |path| File.expand_path(path) }
files = (`git ls-files`.split("\n") | generated).sort
handle = File.open(File.expand_path('../../MANIFEST', __FILE__), 'w')
handle.write(files.join("\n"))
handle.close
end

8
task/parser.rake Normal file
View File

@ -0,0 +1,8 @@
rule '.rb' => '.y' do |task|
Cliver.assert('racc', '~> 1.4')
sh "racc -l -o #{task.name} #{task.source}"
end
desc 'Generates the parser'
task :parser => [PARSER_OUTPUT]

6
task/tag.rake Normal file
View File

@ -0,0 +1,6 @@
desc 'Creates a Git tag for the current version'
task :tag do
version = Oga::VERSION
sh %Q{git tag -a -m "Version #{version}" #{version}}
end

4
task/test.rake Normal file
View File

@ -0,0 +1,4 @@
desc 'Runs the tests'
task :test => [:regenerate] do
sh 'rspec spec'
end