Browse files

restructuring so it is more like a good gem project as defined by jew…

…eler
  • Loading branch information...
1 parent 621b831 commit fe3722d820b79e61c5128b97622bed6ae33792cd starapor committed Feb 25, 2009
Showing with 137 additions and 78 deletions.
  1. BIN .DS_Store
  2. +20 −0 LICENSE
  3. +46 −1 Rakefile
  4. +0 −13 engine/directory_not_found_error.rb
  5. +0 −14 engine/spec/helper.rb
  6. +0 −1 engine/spec/views/person/name.st
  7. 0 { → examples}/main_controller.rb
  8. 0 { → examples}/start.rb
  9. 0 { → examples}/todolist.db
  10. 0 { → examples}/view/index.st
  11. 0 { → examples}/view/person/age.st
  12. 0 { → examples}/view/person/index.st
  13. 0 { → examples}/view/person/name.st
  14. +9 −0 features/slippers.feature
  15. 0 features/steps/slippers_steps.rb
  16. +11 −0 features/support/env.rb
  17. BIN lib/.DS_Store
  18. BIN lib/engine/.DS_Store
  19. 0 { → lib}/engine/binding_wrapper.rb
  20. +1 −4 { → lib}/engine/engine.rb
  21. +0 −2 { → lib}/engine/file_template.rb
  22. 0 { → lib}/engine/slippers.treetop
  23. 0 { → lib}/engine/slippers_nodes.rb
  24. 0 { → lib}/engine/template.rb
  25. 0 { → lib}/engine/template_group.rb
  26. +0 −2 { → lib}/engine/template_group_directory.rb
  27. 0 { → lib}/ramazeTemplates/0001-SarahTaraporewalla-adding-new-template-file-for-sli.patch
  28. 0 { → lib}/ramazeTemplates/slippers.rb
  29. +14 −0 lib/slippers.rb
  30. +0 −13 slippers.iml
  31. +0 −13 slippers.rb
  32. +1 −1 {engine → }/spec/binding_wrapper.rb
  33. +2 −1 {engine → }/spec/engine.rb
  34. +2 −2 {engine → }/spec/file_template.rb
  35. +3 −2 {engine → }/spec/parser.rb
  36. 0 {engine → }/spec/person_template.st
  37. +5 −0 spec/slippers_spec.rb
  38. +14 −0 spec/spec_helper.rb
  39. +2 −1 {engine → }/spec/template_group.rb
  40. +6 −8 {engine → }/spec/template_group_directory.rb
  41. 0 {engine → }/spec/views/index.st
  42. 0 {engine → }/spec/views/money.rb
  43. 0 {engine → }/spec/views/person/age.st
  44. 0 {engine → }/spec/views/person/date_renderer.rb
  45. +1 −0 spec/views/person/name.st
View
BIN .DS_Store
Binary file not shown.
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 starapor
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
47 Rakefile
@@ -13,4 +13,49 @@ Spec::Rake::SpecTask.new('failing_examples_with_html') do |t|
t.fail_on_error = false
end
-task :default => ['examples']
+desc "Generate the gem using technicalpickles jeweler"
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "slippers"
+ gem.summary = "A strict templating library for Ruby"
+ gem.email = "me@sarahtaraporewalla.com"
+ gem.homepage = "http://github.com/starapor/slippers"
+ gem.description = "A strict templating library for ruby"
+ gem.authors = ["Sarah Taraporewalla"]
+ gem.files = FileList["[A-Z]*", "{engine,examples,ramazeTemplates,view}/**/*"]
+ gem.add_dependency 'schacon-git'
+ end
+rescue LoadError
+ puts "Slippers, or one of its dependencies, is not available. Install it with: sudo gem install starapor-slippers -s http://gems.github.com"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'slippers'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new(:spec) do |t|
+ t.libs << 'lib' << 'spec'
+ t.spec_files = FileList['spec/**/*.rb']
+end
+
+Spec::Rake::SpecTask.new(:rcov) do |t|
+ t.libs << 'lib' << 'spec'
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.rcov = true
+end
+
+begin
+ require 'cucumber/rake/task'
+ Cucumber::Rake::Task.new(:features)
+rescue LoadError
+ puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
+end
+
+task :default => :spec
View
13 engine/directory_not_found_error.rb
@@ -1,13 +0,0 @@
-module Slippers
- class DirectoryNotFoundError < IOError
-
- def initialize(directory_name)
- @directory_name = directory_name
- end
-
- def to_s
- "Could not find the directory : " + @directory_name
- end
-
- end
-end
View
14 engine/spec/helper.rb
@@ -1,14 +0,0 @@
-require 'engine/template'
-require 'engine/file_template'
-require 'engine/template_group'
-require 'engine/template_group_directory'
-require 'engine/engine'
-require 'engine/binding_wrapper'
-require 'engine/directory_not_found_error'
-require 'engine/slippers_nodes'
-
-require 'rubygems'
-require 'treetop'
-require 'ostruct'
-require 'date'
-require 'mocha'
View
1 engine/spec/views/person/name.st
@@ -1 +0,0 @@
-Hello $name$.
View
0 main_controller.rb → examples/main_controller.rb
File renamed without changes.
View
0 start.rb → examples/start.rb
File renamed without changes.
View
0 todolist.db → examples/todolist.db
File renamed without changes.
View
0 view/index.st → examples/view/index.st
File renamed without changes.
View
0 view/person/age.st → examples/view/person/age.st
File renamed without changes.
View
0 view/person/index.st → examples/view/person/index.st
File renamed without changes.
View
0 view/person/name.st → examples/view/person/name.st
File renamed without changes.
View
9 features/slippers.feature
@@ -0,0 +1,9 @@
+Feature: something something
+ In order to something something
+ A user something something
+ something something something
+
+ Scenario: something something
+ Given inspiration
+ When I create a sweet new gem
+ Then everyone should see how awesome I am
View
0 features/steps/slippers_steps.rb
No changes.
View
11 features/support/env.rb
@@ -0,0 +1,11 @@
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
+require 'slippers'
+
+require 'spec/expectations'
+
+require 'test/unit/assertions'
+
+World do |world|
+
+ world
+end
View
BIN lib/.DS_Store
Binary file not shown.
View
BIN lib/engine/.DS_Store
Binary file not shown.
View
0 engine/binding_wrapper.rb → lib/engine/binding_wrapper.rb
File renamed without changes.
View
5 engine/engine.rb → lib/engine/engine.rb
@@ -1,7 +1,4 @@
-require 'rubygems'
-require 'treetop'
-require 'engine/slippers'
-require 'engine/template'
+Treetop.load File.dirname(__FILE__) + '/slippers'
module Slippers
class Engine
View
2 engine/file_template.rb → lib/engine/file_template.rb
@@ -1,5 +1,3 @@
-require 'engine/template'
-
module Slippers
class FileTemplate < Template
def initialize(filename)
View
0 engine/slippers.treetop → lib/engine/slippers.treetop
File renamed without changes.
View
0 engine/slippers_nodes.rb → lib/engine/slippers_nodes.rb
File renamed without changes.
View
0 engine/template.rb → lib/engine/template.rb
File renamed without changes.
View
0 engine/template_group.rb → lib/engine/template_group.rb
File renamed without changes.
View
2 engine/template_group_directory.rb → lib/engine/template_group_directory.rb
@@ -1,5 +1,3 @@
-require 'engine/engine'
-
module Slippers
class TemplateGroupDirectory < TemplateGroup
def initialize(directory_path, params={})
View
0 ...la-adding-new-template-file-for-sli.patch → ...la-adding-new-template-file-for-sli.patch
File renamed without changes.
View
0 ramazeTemplates/slippers.rb → lib/ramazeTemplates/slippers.rb
File renamed without changes.
View
14 lib/slippers.rb
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'treetop'
+require 'active_support'
+
+require File.dirname(__FILE__) + '/engine/template'
+require File.dirname(__FILE__) + '/engine/file_template'
+require File.dirname(__FILE__) + '/engine/template_group'
+require File.dirname(__FILE__) + '/engine/template_group_directory'
+require File.dirname(__FILE__) + '/engine/engine'
+require File.dirname(__FILE__) + '/engine/binding_wrapper'
+require File.dirname(__FILE__) + '/engine/slippers_nodes'
+
+
+
View
13 slippers.iml
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module relativePaths="true" type="RUBY_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$" />
- <orderEntry type="jdk" jdkName="Ruby SDK 1.8.6 (/usr/bin/ruby)" jdkType="RUBY_SDK" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
- <component name="RModuleSettingsStorage">
- <RMODULE_SETTINGS_STORAGE_ID NAME="NUMBER" VALUE="0" />
- </component>
-</module>
-
View
13 slippers.rb
@@ -1,13 +0,0 @@
-$LOAD_PATH.unshift(__DIR__)
-require 'engine/template'
-require 'engine/file_template'
-require 'engine/template_group'
-require 'engine/template_group_directory'
-require 'engine/engine'
-require 'engine/binding_wrapper'
-require 'engine/directory_not_found_error'
-require 'engine/slippers_nodes'
-
-require 'rubygems'
-require 'treetop'
-require 'active_support'
View
2 engine/spec/binding_wrapper.rb → spec/binding_wrapper.rb
@@ -1,4 +1,4 @@
-require 'engine/spec/helper'
+require File.dirname(__FILE__) + '/spec_helper'
describe Slippers::BindingWrapper do
def f
View
3 engine/spec/engine.rb → spec/engine.rb
@@ -1,4 +1,5 @@
-require 'engine/spec/helper'
+require File.dirname(__FILE__) + '/spec_helper'
+
describe Slippers::Engine do
before do
template = 'Hello $first$ $last$'
View
4 engine/spec/file_template.rb → spec/file_template.rb
@@ -1,8 +1,8 @@
-require 'engine/spec/helper'
+require File.dirname(__FILE__) + '/spec_helper'
describe Slippers::FileTemplate, " when rendering" do
it "should read the template from a file" do
- template_file = Slippers::FileTemplate.new('engine/spec/person_template.st')
+ template_file = Slippers::FileTemplate.new('spec/person_template.st')
template_file.template.should eql('This is a $template$')
end
end
View
5 engine/spec/parser.rb → spec/parser.rb
@@ -1,4 +1,5 @@
-require 'engine/spec/helper'
+require File.dirname(__FILE__) + '/spec_helper'
+
class Person
def initialize(first, last)
@first, @last = first, last
@@ -82,7 +83,7 @@ def to_s
end
it "should parse the file template from the template group" do
- template_group = Slippers::TemplateGroupDirectory.new('view')
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views')
name = OpenStruct.new({:first => 'fred', :last => 'flinestone'})
people = OpenStruct.new({:fred => name})
@parser.parse("should parse $person/name()$").eval(name, template_group).should eql("should parse fred flinestone")
View
0 engine/spec/person_template.st → spec/person_template.st
File renamed without changes.
View
5 spec/slippers_spec.rb
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "Slippers" do
+
+end
View
14 spec/spec_helper.rb
@@ -0,0 +1,14 @@
+require 'spec'
+
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+
+require 'slippers'
+require 'ostruct'
+require 'date'
+require 'mocha'
+require 'tempfile'
+
+Spec::Runner.configure do |config|
+
+end
+
View
3 engine/spec/template_group.rb → spec/template_group.rb
@@ -1,4 +1,5 @@
-require 'engine/spec/helper'
+require File.dirname(__FILE__) + '/spec_helper'
+
describe Slippers::TemplateGroup do
it 'should find the right template' do
subtemplate = Slippers::Engine.new('Hello $first$ $last$')
View
14 engine/spec/template_group_directory.rb → spec/template_group_directory.rb
@@ -1,36 +1,34 @@
-require 'engine/spec/helper'
-require 'tempfile'
-require 'active_support'
+require File.dirname(__FILE__) + '/spec_helper'
describe Slippers::TemplateGroupDirectory do
it 'should find the file in the directory folder' do
- template_group = Slippers::TemplateGroupDirectory.new('engine/spec/views')
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views')
template_group.find('index').should eql(Slippers::Engine.new('Hey foo', :template_group => template_group))
template_group.find('person/age').should eql(Slippers::Engine.new('The age for him is $age$', :template_group => template_group))
end
it 'should return nil if it cannot find the file in the directory folder' do
- template_group = Slippers::TemplateGroupDirectory.new('engine/spec/views')
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views')
template_group.find('person/not_found').should eql(nil)
end
it 'should read the st template file and return a new slipers engine for it' do
- template_group = Slippers::TemplateGroupDirectory.new('engine/spec/views')
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views')
template_group.find('index').should eql(Slippers::Engine.new('Hey foo', :template_group => template_group))
template_group.find('person/age').should eql(Slippers::Engine.new('The age for him is $age$', :template_group => template_group))
end
it 'should load the ruby file found in the directory folder' do
- template_group = Slippers::TemplateGroupDirectory.new('engine/spec/views')
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views')
template_group.find('person/date_renderer').class.should eql(DateRenderer)
template_group.find('money').class.should eql(Money)
end
it 'should look in the super template group if it cannot find the template' do
template = stub 'template'
super_template_group = Slippers::TemplateGroup.new(:templates => {:person => template})
- template_group = Slippers::TemplateGroupDirectory.new('engine/spec/views', :super_group => super_template_group)
+ template_group = Slippers::TemplateGroupDirectory.new('spec/views', :super_group => super_template_group)
template_group.find('person').should eql(template)
template_group.find('not_this').should eql(nil)
end
View
0 engine/spec/views/index.st → spec/views/index.st
File renamed without changes.
View
0 engine/spec/views/money.rb → spec/views/money.rb
File renamed without changes.
View
0 engine/spec/views/person/age.st → spec/views/person/age.st
File renamed without changes.
View
0 engine/spec/views/person/date_renderer.rb → spec/views/person/date_renderer.rb
File renamed without changes.
View
1 spec/views/person/name.st
@@ -0,0 +1 @@
+$first$ $last$

0 comments on commit fe3722d

Please sign in to comment.