polygon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ template-info:
2
+ name: "rubygem.noe"
3
+ version: 1.7.0
4
+ variables:
5
+ lower:
6
+ polygon
7
+ upper:
8
+ Polygon
9
+ version:
10
+ 0.0.1
11
+ summary: |-
12
+ A web framework powered by sinatra for mostly static websites
13
+ description: |-
14
+ Polygon provides a framework with strong separation of concerns between
15
+ clients, developers and web designers
16
+ authors:
17
+ - {name: Bernard Lambeau, email: blambeau@gmail.com}
18
+ links:
19
+ - http://github.com/blambeau/polygon
20
+ dependencies:
21
+ - {name: sinatra, version: "~> 1.3", groups: [runtime]}
22
+ - {name: epath, version: "~> 0.2.0", groups: [runtime]}
23
+ - {name: json, version: ">= 0", groups: [runtime]}
24
+ - {name: wlang, version: "~> 0.10.2", groups: [runtime]}
25
+ - {name: rake, version: "~> 0.9.2", groups: [development]}
26
+ - {name: bundler, version: "~> 1.0", groups: [development]}
27
+ - {name: rspec, version: "~> 2.10", groups: [development]}
28
+ - {name: yard, version: "~> 0.7.2", groups: [development]}
29
+ - {name: bluecloth, version: "~> 2.2", groups: [development]}
30
+ rake_tasks:
31
+ unit_test:
32
+ libs: [lib, test]
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'polygon'
@@ -0,0 +1,8 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+ describe Polygon do
3
+
4
+ it "should have a version number" do
5
+ Polygon.const_defined?(:VERSION).should be_true
6
+ end
7
+
8
+ end
@@ -0,0 +1,75 @@
1
+ # Installs a rake task for debuging the announcement mail.
2
+ #
3
+ # This file installs the 'rake debug_mail' that flushes an announcement mail
4
+ # for your library on the standard output. It is automatically generated
5
+ # by Noe from your .noespec file, and should therefore be configured there,
6
+ # under the variables/rake_tasks/debug_mail entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # debug_mail:
11
+ # rx_changelog_sections: /^#/
12
+ # nb_changelog_sections: 1
13
+ # ...
14
+ #
15
+ # If you have specific needs requiring manual intervention on this file,
16
+ # don't forget to set safe-override to false in your noe specification:
17
+ #
18
+ # template-info:
19
+ # manifest:
20
+ # tasks/debug_mail.rake:
21
+ # safe-override: false
22
+ #
23
+ # The mail template used can be found in debug_mail.txt. That file may be
24
+ # changed to tune the mail you want to send. If you do so, don't forget to
25
+ # add a manifest entry in your .noespec file to avoid overriding you
26
+ # changes. The mail template uses wlang, with parentheses for block
27
+ # delimiters.
28
+ #
29
+ # template-info:
30
+ # manifest:
31
+ # tasks/debug_mail.txt:
32
+ # safe-override: false
33
+ #
34
+ desc "Debug the release announcement mail"
35
+ task :debug_mail do
36
+ begin
37
+ require 'wlang'
38
+ rescue LoadError
39
+ abort "wlang is not available. Try 'gem install wlang'"
40
+ end
41
+ require 'yaml'
42
+
43
+ # Check that a .noespec file exists
44
+ noespec_file = File.expand_path('../../polygon.noespec', __FILE__)
45
+ unless File.exists?(noespec_file)
46
+ raise "Unable to find .noespec project file, sorry."
47
+ end
48
+
49
+ # Load it as well as variables and options
50
+ noespec = YAML::load(File.read(noespec_file))
51
+ vars = noespec['variables'] || {}
52
+
53
+ # Changes are taken from CHANGELOG
54
+ logs = Dir[File.expand_path("../../CHANGELOG.*", __FILE__)]
55
+ unless logs.size == 1
56
+ abort "Unable to find a changelog file"
57
+ end
58
+
59
+ # Load interesting changesets
60
+ changes, end_found = [], 0
61
+ File.readlines(logs.first).select{|line|
62
+ if line =~ /^# /
63
+ break if end_found >= 1
64
+ end_found += 1
65
+ end
66
+ changes << line
67
+ }
68
+ vars['changes'] = changes.join
69
+
70
+ # WLang template
71
+ template = File.expand_path('../debug_mail.txt', __FILE__)
72
+
73
+ # Let's go!
74
+ $stdout << WLang::file_instantiate(template, vars, "wlang/active-text")
75
+ end
@@ -0,0 +1,13 @@
1
+ Subject: [ANN] !{lower} !{version} Released
2
+
3
+ !{lower} version !{version} has been released!
4
+
5
+ !{summary}
6
+
7
+ *{links as l}{* <!{l}>}{!{"\n"}}
8
+
9
+ !{description}
10
+
11
+ Changes:
12
+
13
+ !{changes}
@@ -0,0 +1,73 @@
1
+ # Installs rake tasks for gemming and packaging
2
+ #
3
+ # This file installs the 'rake package', 'rake gem' tasks and associates
4
+ # (clobber_package, repackage, ...). It is automatically generated by Noe
5
+ # from your .noespec file, and should therefore be configured there, under
6
+ # the variables/rake_tasks/gem entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # gem:
11
+ # package_dir: pkg
12
+ # need_tar: false
13
+ # need_tar_gz: false
14
+ # need_tar_bz2: false
15
+ # need_zip: false
16
+ # ...
17
+ #
18
+ # If you have specific needs requiring manual intervention on this file,
19
+ # don't forget to set safe-override to false in your noe specification:
20
+ #
21
+ # template-info:
22
+ # manifest:
23
+ # tasks/gem.rake:
24
+ # safe-override: false
25
+ #
26
+ begin
27
+ require 'rubygems/package_task'
28
+
29
+ # Dynamically load the gem spec
30
+ gemspec_file = File.expand_path('../../polygon.gemspec', __FILE__)
31
+ gemspec = Kernel.eval(File.read(gemspec_file))
32
+
33
+ Gem::PackageTask.new(gemspec) do |t|
34
+
35
+ # Name of the package
36
+ t.name = gemspec.name
37
+
38
+ # Version of the package
39
+ t.version = gemspec.version
40
+
41
+ # Directory used to store the package files
42
+ t.package_dir = "pkg"
43
+
44
+ # True if a gzipped tar file (tgz) should be produced
45
+ t.need_tar = false
46
+
47
+ # True if a gzipped tar file (tar.gz) should be produced
48
+ t.need_tar_gz = false
49
+
50
+ # True if a bzip2'd tar file (tar.bz2) should be produced
51
+ t.need_tar_bz2 = false
52
+
53
+ # True if a zip file should be produced (default is false)
54
+ t.need_zip = false
55
+
56
+ # List of files to be included in the package.
57
+ t.package_files = gemspec.files
58
+
59
+ # Tar command for gzipped or bzip2ed archives.
60
+ t.tar_command = "tar"
61
+
62
+ # Zip command for zipped archives.
63
+ t.zip_command = "zip"
64
+
65
+ end
66
+ rescue LoadError
67
+ task :gem do
68
+ abort 'rubygems/package_task is not available. You should verify your rubygems installation'
69
+ end
70
+ task :package do
71
+ abort 'rubygems/package_task is not available. You should verify your rubygems installation'
72
+ end
73
+ end
@@ -0,0 +1,71 @@
1
+ # Installs a rake task for for running examples written using rspec.
2
+ #
3
+ # This file installs the 'rake spec_test' (aliased as 'rake spec') as well as
4
+ # extends 'rake test' to run spec tests, if any. It is automatically generated
5
+ # by Noe from your .noespec file, and should therefore be configured there,
6
+ # under the variables/rake_tasks/spec_test entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # spec_test:
11
+ # pattern: spec/**/*_spec.rb
12
+ # verbose: true
13
+ # rspec_opts: [--color, --backtrace]
14
+ # ...
15
+ #
16
+ # If you have specific needs requiring manual intervention on this file,
17
+ # don't forget to set safe-override to false in your noe specification:
18
+ #
19
+ # template-info:
20
+ # manifest:
21
+ # tasks/spec_test.rake:
22
+ # safe-override: false
23
+ #
24
+ # This file has been written to conform to RSpec v2.4.0. More information about
25
+ # rspec and options of the rake task defined below can be found on
26
+ # http://relishapp.com/rspec
27
+ #
28
+ begin
29
+ require "rspec/core/rake_task"
30
+ desc "Run RSpec code examples"
31
+ RSpec::Core::RakeTask.new(:spec_test) do |t|
32
+ # Glob pattern to match files.
33
+ t.pattern = "spec/**/test_*.rb"
34
+
35
+ # Whether or not to fail Rake when an error occurs (typically when
36
+ # examples fail).
37
+ t.fail_on_error = true
38
+
39
+ # A message to print to stderr when there are failures.
40
+ t.failure_message = nil
41
+
42
+ # Use verbose output. If this is set to true, the task will print the
43
+ # executed spec command to stdout.
44
+ t.verbose = true
45
+
46
+ # Use rcov for code coverage?
47
+ t.rcov = false
48
+
49
+ # Path to rcov.
50
+ t.rcov_path = "rcov"
51
+
52
+ # Command line options to pass to rcov. See 'rcov --help' about this
53
+ t.rcov_opts = []
54
+
55
+ # Command line options to pass to ruby. See 'ruby --help' about this
56
+ t.ruby_opts = []
57
+
58
+ # Path to rspec
59
+ t.rspec_path = "rspec"
60
+
61
+ # Command line options to pass to rspec. See 'rspec --help' about this
62
+ t.rspec_opts = ["--color", "--backtrace"]
63
+ end
64
+ rescue LoadError => ex
65
+ task :spec_test do
66
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
67
+ end
68
+ ensure
69
+ task :spec => [:spec_test]
70
+ task :test => [:spec_test]
71
+ end
@@ -0,0 +1,76 @@
1
+ # Installs a rake task for for running unit tests.
2
+ #
3
+ # This file installs the 'rake unit_test' and extends 'rake test' to run unit
4
+ # tests, if any. It is automatically generated by Noe from your .noespec file,
5
+ # and should therefore be configured there, under the variables/rake_tasks/unit_test
6
+ # entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # unit_test:
11
+ # pattern: test/test*.rb
12
+ # verbose: false
13
+ # warning: false
14
+ # ...
15
+ #
16
+ # If you have specific needs requiring manual intervention on this file,
17
+ # don't forget to set safe-override to false in your noe specification:
18
+ #
19
+ # template-info:
20
+ # manifest:
21
+ # tasks/unit_test.rake:
22
+ # safe-override: false
23
+ #
24
+ # More info about the TestTask and its options can be found on
25
+ # http://rake.rubyforge.org/classes/Rake/TestTask.html
26
+ #
27
+ begin
28
+ require 'rake/testtask'
29
+ desc "Run unit tests"
30
+ Rake::TestTask.new(:unit_test) do |t|
31
+
32
+ # List of directories to added to $LOAD_PATH before running the
33
+ # tests. (default is 'lib')
34
+ t.libs = ["lib", "test"]
35
+
36
+ # True if verbose test output desired. (default is false)
37
+ t.verbose = false
38
+
39
+ # Test options passed to the test suite. An explicit TESTOPTS=opts
40
+ # on the command line will override this. (default is NONE)
41
+ t.options = nil
42
+
43
+ # Request that the tests be run with the warning flag set.
44
+ # E.g. warning=true implies "ruby -w" used to run the tests.
45
+ t.warning = false
46
+
47
+ # Glob pattern to match test files. (default is 'test/test*.rb')
48
+ t.pattern = "test/test_*.rb"
49
+
50
+ # Style of test loader to use. Options are:
51
+ #
52
+ # * :rake -- Rake provided test loading script (default).
53
+ # * :testrb -- Ruby provided test loading script.
54
+ # * :direct -- Load tests using command line loader.
55
+ #
56
+ t.loader = :rake
57
+
58
+ # Array of commandline options to pass to ruby when running test
59
+ # loader.
60
+ t.ruby_opts = []
61
+
62
+ # Explicitly define the list of test files to be included in a
63
+ # test. +list+ is expected to be an array of file names (a
64
+ # FileList is acceptable). If both +pattern+ and +test_files+ are
65
+ # used, then the list of test files is the union of the two.
66
+ t.test_files = nil
67
+
68
+ end
69
+ rescue LoadError => ex
70
+ task :unit_test do
71
+ abort "rake/testtask does not seem available...\n #{ex.message}"
72
+ end
73
+ ensure
74
+ desc "Run all tests"
75
+ task :test => [:unit_test]
76
+ end
@@ -0,0 +1,51 @@
1
+ # Installs a rake task to generate API documentation using yard.
2
+ #
3
+ # This file installs the 'rake yard' task. It is automatically generated by Noe from
4
+ # your .noespec file, and should therefore be configured there, under the
5
+ # variables/rake_tasks/yard entry, as illustrated below:
6
+ #
7
+ # variables:
8
+ # rake_tasks:
9
+ # yard:
10
+ # files: lib/**/*.rb
11
+ # options: []
12
+ # ...
13
+ #
14
+ # If you have specific needs requiring manual intervention on this file,
15
+ # don't forget to set safe-override to false in your noe specification:
16
+ #
17
+ # template-info:
18
+ # manifest:
19
+ # tasks/yard.rake:
20
+ # safe-override: false
21
+ #
22
+ # This file has been written to conform to yard v0.6.4. More information about
23
+ # yard and the rake task installed below can be found on http://yardoc.org/
24
+ #
25
+ begin
26
+ require "yard"
27
+ desc "Generate yard documentation"
28
+ YARD::Rake::YardocTask.new(:yard) do |t|
29
+ # Array of options passed to yardoc commandline. See 'yardoc --help' about this
30
+ t.options = ["--output-dir", "doc/api", "-", "README.md", "CHANGELOG.md", "LICENCE.md"]
31
+
32
+ # Array of ruby source files (and any extra documentation files
33
+ # separated by '-')
34
+ t.files = ["lib/**/*.rb"]
35
+
36
+ # A proc to call before running the task
37
+ # t.before = proc{ }
38
+
39
+ # A proc to call after running the task
40
+ # r.after = proc{ }
41
+
42
+ # An optional lambda to run against all objects being generated.
43
+ # Any object that the lambda returns false for will be excluded
44
+ # from documentation.
45
+ # t.verifier = lambda{|obj| true}
46
+ end
47
+ rescue LoadError
48
+ task :yard do
49
+ abort 'yard is not available. In order to run yard, you must: gem install yard'
50
+ end
51
+ end
@@ -0,0 +1,99 @@
1
+ require 'helper'
2
+ module Polygon
3
+
4
+ class Content::Entry
5
+ public :extensions, :index_files, :parent, :ancestors_or_self, :loader
6
+ end
7
+
8
+ class ContentEntryTest < Test::Unit::TestCase
9
+ include Helper
10
+
11
+ def setup
12
+ @root = Path.dir/"../fixtures"
13
+ @loader = ContentLoader.new
14
+ @loader.enable_yaml!(".yml")
15
+ @loader.enable_yaml_front_matter!(".md")
16
+ @content = Content.new(@root, @loader)
17
+ @fixtures = Content::Entry.new(@content, @root)
18
+ end
19
+
20
+ def test_loader
21
+ assert_equal @loader, @fixtures.loader
22
+ end
23
+
24
+ def test_extensions
25
+ assert_equal [".yml", ".md"], @fixtures.extensions
26
+ end
27
+
28
+ def test_index_files
29
+ assert_equal @loader.extensions.map{|e| "index#{e}"},
30
+ @fixtures.index_files
31
+ end
32
+
33
+ def test_divide
34
+ assert_equal @root/"index.yml", (@fixtures/"index.yml").path
35
+ assert_equal @loader, (@fixtures/"index.yml").loader
36
+ end
37
+
38
+ def test_exist?
39
+ assert @fixtures.exist?
40
+ assert (@fixtures/"index.yml").exist?
41
+ assert !(@fixtures/"index.md").exist?
42
+ end
43
+
44
+ def test_parent
45
+ assert_nil @fixtures.parent
46
+ assert_nil (@fixtures/"index.yml").parent
47
+ assert_equal @fixtures/"index.yml", (@fixtures/"index.md").parent
48
+ assert_equal @fixtures/"index.md", (@fixtures/"say-hello.md").parent
49
+ assert_equal @fixtures/"index.md", (@fixtures/"with_index_yml").parent
50
+ assert_equal @fixtures/"with_index_yml/index.md", (@fixtures/"with_index_yml/say-hello.md").parent
51
+ assert_equal @fixtures/"index.md", (@fixtures/"with_index_md").parent
52
+ assert_equal @fixtures/"with_index_md/index.yml", (@fixtures/"with_index_md/index.md").parent
53
+ end
54
+
55
+ def test_ancestors_or_self
56
+ assert_equal [ @fixtures ], @fixtures.ancestors_or_self
57
+ assert_equal [
58
+ @fixtures/"index.yml",
59
+ @fixtures/"index.md",
60
+ @fixtures/"with_index_yml/index.yml",
61
+ @fixtures/"with_index_yml/index.md",
62
+ @fixtures/"with_index_yml/say-hello.md",
63
+ ], (@fixtures/"with_index_yml/say-hello.md").ancestors_or_self
64
+ assert_equal [
65
+ @fixtures/"index.yml",
66
+ @fixtures/"with_index_yml/index.yml",
67
+ @fixtures/"with_index_yml/say-hello.md",
68
+ ], (@fixtures/"with_index_yml/say-hello.md").ancestors_or_self(true)
69
+ end
70
+
71
+ def test_to_hash
72
+ content = @fixtures/"with_index_yml/say-hello.md"
73
+
74
+ expected = {
75
+ "title" => "Say Hello",
76
+ "content" => "# How to Say Hello to World?\n\nThis way!\n",
77
+ "keywords" => ["say-hello", "with_index_yml/index.yml", "root"],
78
+ "__path__" => content.path,
79
+ "__url__" => "with_index_yml/say-hello" }
80
+ assert_equal expected, content.to_hash
81
+ assert_equal expected, content.to_hash(true)
82
+
83
+ expected = {
84
+ "title" => "Say Hello",
85
+ "content" => "# How to Say Hello to World?\n\nThis way!\n",
86
+ "keywords" => ["say-hello"],
87
+ "__path__" => content.path,
88
+ "__url__" => "with_index_yml/say-hello" }
89
+ assert_equal expected, content.to_hash(false)
90
+ end
91
+
92
+ def test_it_splits_md_files_correctly
93
+ content = (@fixtures/"without_index"/"hello.md").to_hash
94
+ assert_equal "Welcome!", content["title"]
95
+ assert_match /^Welcome to/, content["content"]
96
+ end
97
+
98
+ end
99
+ end