tipsy 0.0.2 → 0.0.3

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.
Files changed (95) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +6 -11
  3. data/README.md +24 -1
  4. data/Rakefile +13 -9
  5. data/bin/tipsy +4 -2
  6. data/lib/templates/server/htaccess.erb +14 -0
  7. data/lib/templates/site/Gemfile +19 -0
  8. data/lib/templates/site/assets/stylesheets/_config.css.scss +1 -0
  9. data/lib/templates/site/assets/stylesheets/screen.css.scss +1 -0
  10. data/lib/templates/site/config.rb +52 -0
  11. data/lib/templates/site/deploy.yml +27 -0
  12. data/lib/templates/site/layouts/default.html.erb +41 -0
  13. data/lib/templates/site/views/index.html.erb +2 -0
  14. data/lib/tipsy/compressors/{css.rb → css_compressor.rb} +0 -0
  15. data/lib/tipsy/compressors/javascript_compressor.rb +44 -0
  16. data/lib/tipsy/configuration.rb +9 -0
  17. data/lib/tipsy/handler/all.rb +4 -0
  18. data/lib/tipsy/handler/asset.rb +93 -0
  19. data/lib/tipsy/handler/erb.rb +42 -0
  20. data/lib/tipsy/handler/php.rb +36 -0
  21. data/lib/tipsy/{sass/template.rb → handler/sass/importer.rb} +15 -53
  22. data/lib/tipsy/handler/sass/resolver.rb +30 -0
  23. data/lib/tipsy/handler/sass.rb +36 -0
  24. data/lib/tipsy/handler/static.rb +30 -0
  25. data/lib/tipsy/helpers/asset_paths.rb +29 -1
  26. data/lib/tipsy/helpers/asset_tags.rb +1 -1
  27. data/lib/tipsy/helpers/capture.rb +12 -41
  28. data/lib/tipsy/helpers/rendering.rb +46 -0
  29. data/lib/tipsy/helpers/sass.rb +17 -6
  30. data/lib/tipsy/helpers/tag.rb +6 -9
  31. data/lib/tipsy/helpers.rb +13 -16
  32. data/lib/tipsy/runner.rb +82 -0
  33. data/lib/tipsy/runners/compiler.rb +189 -0
  34. data/lib/tipsy/runners/deployer.rb +7 -0
  35. data/lib/tipsy/runners/generator.rb +24 -0
  36. data/lib/tipsy/server.rb +56 -114
  37. data/lib/tipsy/site.rb +88 -0
  38. data/lib/tipsy/utils/logger.rb +47 -0
  39. data/lib/tipsy/utils/system.rb +115 -0
  40. data/lib/tipsy/utils/system_test.rb +103 -0
  41. data/lib/tipsy/version.rb +1 -1
  42. data/lib/tipsy/view/base.rb +55 -0
  43. data/lib/tipsy/view/context.rb +28 -0
  44. data/lib/tipsy/view/path.rb +44 -0
  45. data/lib/tipsy/view.rb +14 -68
  46. data/lib/tipsy.rb +30 -67
  47. data/{lib/tipsy/project/assets/javascripts/site.js → test/fixtures/capture.html.erb} +0 -0
  48. data/test/helpers/tag_test.rb +22 -0
  49. data/{lib/tipsy/project/assets/stylesheets/screen.css.scss → test/root/compiled/fake.txt} +0 -0
  50. data/test/root/{test/assets/javascripts/test.js → compiled/sub-path/fake.txt} +0 -0
  51. data/test/root/{development/assets/javascripts/test.js → compiled/sub-path-with-skip/fake.txt} +0 -0
  52. data/test/root/layouts/default.html.erb +0 -0
  53. data/test/root/views/index.html.erb +0 -0
  54. data/test/root/views/page.html.erb +0 -0
  55. data/test/root/views/sub/page.html.erb +0 -0
  56. data/test/root/views/sub/tertiary/index.html.erb +0 -0
  57. data/test/runner/compiler_test.rb +49 -0
  58. data/test/test_helper.rb +160 -21
  59. data/test/unit/site_test.rb +23 -0
  60. data/test/unit/tipsy_test.rb +13 -0
  61. data/test/unit/utils/system_test.rb +26 -0
  62. data/test/view/base_test.rb +34 -0
  63. data/test/view/path_test.rb +34 -0
  64. data/tipsy.gemspec +10 -7
  65. metadata +113 -84
  66. data/lib/tipsy/application.rb +0 -86
  67. data/lib/tipsy/builder.rb +0 -26
  68. data/lib/tipsy/builders/base.rb +0 -64
  69. data/lib/tipsy/builders/export.rb +0 -16
  70. data/lib/tipsy/builders/project.rb +0 -40
  71. data/lib/tipsy/builders/remote.rb +0 -14
  72. data/lib/tipsy/compressors/javascript.rb +0 -25
  73. data/lib/tipsy/logger.rb +0 -62
  74. data/lib/tipsy/project/Gemfile +0 -8
  75. data/lib/tipsy/project/config.erb +0 -19
  76. data/lib/tipsy/project/helpers/site_helper.rb +0 -4
  77. data/lib/tipsy/project/views/_layout.html.erb +0 -16
  78. data/test/fixtures/about.html +0 -1
  79. data/test/fixtures/contact.html +0 -1
  80. data/test/fixtures/index.html +0 -1
  81. data/test/functional/page_test.rb +0 -33
  82. data/test/root/.gitignore +0 -7
  83. data/test/root/development/assets/stylesheets/screen.css.scss +0 -3
  84. data/test/root/development/config.rb +0 -6
  85. data/test/root/development/views/_layout.html.erb +0 -20
  86. data/test/root/development/views/index.html.erb +0 -3
  87. data/test/root/test/assets/stylesheets/screen.css.scss +0 -3
  88. data/test/root/test/config.rb +0 -6
  89. data/test/root/test/views/_layout.html.erb +0 -1
  90. data/test/root/test/views/about/index.html +0 -1
  91. data/test/root/test/views/contact.html +0 -1
  92. data/test/root/test/views/index.html.erb +0 -1
  93. data/test/unit/helpers/asset_paths_test.rb +0 -14
  94. data/test/unit/helpers_test.rb +0 -22
  95. data/test/unit/server_test.rb +0 -1
data/lib/tipsy/view.rb CHANGED
@@ -1,78 +1,24 @@
1
+ require 'tipsy/handler/all'
1
2
  require 'tilt'
2
- require 'tipsy/helpers'
3
3
  require 'hike'
4
4
 
5
5
  module Tipsy
6
- ##
7
- # Handles rendering of templates and layouts
8
- #
9
- class View
10
-
11
- attr_reader :content_type
12
- attr_reader :file
13
- attr_reader :request
14
- attr_reader :trail
15
- attr_reader :view_path
16
-
17
- def initialize(path, request)
18
- @request = request
19
- @content_type = 'text/html'
20
- @trail = Hike::Trail.new(File.join(Tipsy.root, 'views'))
21
- @view_path = path
22
- @template = nil
23
- trail.append_path('.')
24
- trail.append_extensions '.erb','.html', '.json', '.xml'
25
- end
26
-
27
- def render
28
- unless template.nil?
29
- handler = Tilt[template] || Tilt::ErubisTemplate
30
- tilt = handler.new(template, nil, :outvar => '@_output_buffer')
31
- context = Context.new(request, template, trail)
32
- contents = unless layout.nil?
33
- wrapped = Tilt.new(layout, nil, :outvar => '@_output_buffer')
34
- contents = wrapped.render(context) do |*args|
35
- tilt.render(context, *args)
36
- end
37
- else
38
- tilt.render(context)
39
- end
40
- return contents
41
- end
42
- nil
43
- end
44
-
45
- private
46
-
47
- def template
48
- @template ||= (trail.find(view_path) || trail.find(File.join(view_path, "index")))
49
- end
50
-
51
- def layout
52
- @layout ||= (trail.find(File.join(view_path, '_layout')) || trail.find('_layout'))
53
- end
54
-
55
- ##
56
- # A rendering context. This class is the context all views are stemmed from.
57
- #
58
- class Context
59
- include Tipsy::Helpers
60
- attr_reader :request, :root, :template_file_name, :view_trail
61
-
62
- def initialize(req, tpl, trail)
63
- @request = req
64
- @root = Tipsy.root
65
- @template_file_name = tpl
66
- @view_trail = trail
67
- __initialize_helpers
6
+ module View
7
+ class << self
8
+ def register_handler(klass, ext)
9
+ Tilt.register(klass, ext)
68
10
  end
69
11
  end
70
12
 
13
+ class TemplateMissing < ::StandardError; end
14
+ class LayoutMissing < ::StandardError; end
15
+
71
16
  end
72
17
  end
73
18
 
74
- begin
75
- require 'erubis'
76
- Tilt.prefer Tilt::ErubisTemplate, 'erb'
77
- rescue LoadError
78
- end
19
+ require 'tipsy/helpers'
20
+ require 'tipsy/view/base'
21
+ require 'tipsy/view/context'
22
+ require 'tipsy/view/path'
23
+
24
+ Tipsy::View.register_handler(Tipsy::Handler::ErbHandler, 'erb')
data/lib/tipsy.rb CHANGED
@@ -1,84 +1,47 @@
1
- require "tipsy/version"
2
1
  require "active_support/all"
3
- require 'optparse'
4
- require 'ostruct'
2
+ require "tipsy/version"
5
3
 
6
4
  module Tipsy
7
-
8
- autoload :Application, 'tipsy/application'
9
- autoload :Server, 'tipsy/server'
10
- autoload :Responder, 'tipsy/handler'
11
- autoload :Helpers, 'tipsy/helpers'
12
- autoload :Builder, 'tipsy/builder'
13
- autoload :Logger, 'tipsy/logger'
14
- autoload :View, 'tipsy/view'
15
5
 
16
- module Compressors
17
- autoload :CssCompressor, 'tipsy/compressors/css'
18
- autoload :JavascriptCompressor, 'tipsy/compressors/javascript'
6
+ module Handler
7
+ autoload :AssetHandler, 'tipsy/handler/asset'
8
+ autoload :StaticHandler, 'tipsy/handler/static'
9
+ autoload :SassHandler, 'tipsy/handler/sass'
10
+ autoload :PhpHandler, 'tipsy/handler/php'
11
+ autoload :ErbHandler, 'tipsy/handler/erb'
19
12
  end
20
13
 
21
- module Sass
22
- autoload :Template, 'tipsy/sass/template'
14
+ module Runners
15
+ autoload :Generator, 'tipsy/runners/generator'
16
+ autoload :Compiler, 'tipsy/runners/compiler'
17
+ autoload :Deployer, 'tipey/runners/deployer'
23
18
  end
24
19
 
25
- mattr_accessor :root
26
- mattr_accessor :logger
27
- mattr_accessor :env
28
- mattr_accessor :sprockets
29
- mattr_accessor :compass
30
-
31
- def self.logger
32
- @logger ||= Tipsy::Logger.new($stdout)
33
- end
34
-
35
- def self.run_command(args, stdin)
36
- args = [args].flatten
37
- to_run = args.first
38
- to_run = case to_run
39
- when nil then 'run'
40
- when 'new' then 'create'
41
- when 'serve' || 's' then 'run'
42
- else to_run
43
- end
44
-
45
- args.shift
46
- parse_options!
47
- Tipsy::Application.send(:"#{to_run}", *args)
48
-
20
+ module Utils
21
+ autoload :System, 'tipsy/utils/system'
22
+ autoload :SystemTest, 'tipsy/utils/system_test'
23
+ autoload :Logger, 'tipsy/utils/logger'
49
24
  end
50
25
 
51
- def self.options
52
- @@options ||= OpenStruct.new({
53
- :port => 4000,
54
- :host => '0.0.0.0',
55
- :assets => OpenStruct.new({ :paths => [], :precompile => [] }),
56
- :build_path => File.join(Tipsy.root, 'build'),
57
- :public_path => File.join(Tipsy.root, 'public'),
58
- :asset_path => File.join(Tipsy.root, 'public', 'assets')
59
- })
26
+ module Compressors
27
+ autoload :JavascriptCompressor, 'tipsy/compressors/javascript_compressor'
28
+ autoload :CssCompressor, 'tipsy/compressors/css_compressor'
60
29
  end
61
30
 
62
- private
63
-
64
- def self.parse_options!
31
+ class << self
32
+ def env
33
+ @env ||= ENV['TIPSY_ENV'] || 'development'
34
+ end
65
35
 
66
- op = OptionParser.new do |opts|
67
- opts.banner = "Usage: tipsy [cmd] [options]"
68
- opts.separator ""
69
- opts.separator "Options:"
70
- opts.on("-p", "--port", "Run the server on a specified port ( default: 4000 )") do |port|
71
- options.port = port
72
- end
73
- opts.on("-a", "--address", "Run the server on a specified address ( default: 0.0.0.0 )") do |host|
74
- options.host = host
75
- end
76
- opts.on_tail("--version", "Show version") do
77
- puts Tipsy::VERSION
78
- exit 0
79
- end
36
+ def root
37
+ @root ||= ENV['TIPSY_ROOT']
80
38
  end
81
39
 
40
+ def logger
41
+ @logger ||= Tipsy::Utils::Logger.new($stdout)
42
+ end
82
43
  end
83
-
44
+
84
45
  end
46
+
47
+ require 'tipsy/site'
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ require 'tipsy/helpers'
3
+
4
+ class TagTest < ActiveSupport::TestCase
5
+
6
+ include Tipsy::Helpers::Tag
7
+ include Tipsy::Helpers::AssetPaths
8
+ include Tipsy::Helpers::AssetTags
9
+
10
+ def setup
11
+ @output_buffer = ""
12
+ end
13
+
14
+ test "Single tags should be rendered with attributes" do
15
+ tag(:img, { src: "some/source.jpg" }).should == '<img src="some/source.jpg" />'
16
+ end
17
+
18
+ test "The image_tag renders an img tag" do
19
+ image_tag("something.jpg").should == '<img alt="something.jpg" src="/assets/something.jpg" />'
20
+ end
21
+
22
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class CompilerTest < ActiveSupport::TestCase
4
+ attr_reader :compiler
5
+
6
+ def setup
7
+ Tipsy::Runners::Compiler.send(:include, Tipsy::Utils::SystemTest)
8
+ @compiler = Tipsy::Runners::Compiler.new
9
+ Tipsy::Site.configure!
10
+ end
11
+
12
+ test "Ensure source path is set" do
13
+ compiler.source_path.should == Tipsy::Site.config.public_path
14
+ end
15
+
16
+ test "Ensure destination path is set" do
17
+ compiler.dest_path.should == Tipsy::Site.config.compile_to
18
+ end
19
+
20
+ test "An option exists to skip specific files and folders on compile" do
21
+ compiler.excludes.include?('.git').should == true
22
+ compiler.excludes.include?('.svn').should == true
23
+ end
24
+
25
+ test "Ensure skipped directory is not removed" do
26
+ compiler.was_deleted?(File.join(Tipsy::Site.compile_to, ".svn")).should == false
27
+ end
28
+
29
+ test "Ensure un-skipped files are removed" do
30
+ compiler.was_deleted?(File.join(Tipsy::Site.compile_to, "sub-path-with-skip", "fake.txt")).should == true
31
+ end
32
+
33
+ test "Ensure un-skipped files in folders are removed" do
34
+ compiler.was_deleted?(File.join(Tipsy::Site.compile_to, "sub-path", "fake.txt")).should == true
35
+ end
36
+
37
+ test "Ensure un-skipped directories are removed" do
38
+ compiler.was_deleted?(File.join(Tipsy::Site.compile_to, "sub-path")).should == true
39
+ end
40
+
41
+ test "Ensure templates are created" do
42
+ compiler.was_created?(File.join(Tipsy::Site.compile_to, "sub", "page.html")).should == true
43
+ end
44
+
45
+ test "Ensure index templates are created" do
46
+ compiler.was_created?(File.join(Tipsy::Site.compile_to, "sub", "tertiary", "index.html")).should == true
47
+ end
48
+
49
+ end
data/test/test_helper.rb CHANGED
@@ -1,33 +1,172 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require "rack/test"
3
- require "test/unit"
4
- require "minitest/unit"
5
- require "turn"
6
- require "tipsy"
7
- require 'matchy'
8
-
9
- module Tipsy
10
- module Test
11
-
12
- def self.app
13
- @app ||= Tipsy::Server.init!
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ ENV['TIPSY_ROOT'] ||= File.join(File.dirname(__FILE__), "root")
5
+ ENV['TIPSY_ENV'] = "test"
6
+
7
+ Bundler.require
8
+ require 'rubygems'
9
+ require 'colored'
10
+ require 'active_support/all'
11
+ require 'fileutils'
12
+ require 'ostruct'
13
+ require 'minitest/unit'
14
+ require 'minitest/autorun'
15
+ require 'test/unit'
16
+
17
+ require 'tipsy'
18
+
19
+ require 'rspec/core'
20
+ require 'rspec/expectations'
21
+
22
+ Tipsy::Site.configure!
23
+
24
+ module MiniTest
25
+ class SpecRunner < Unit
26
+
27
+ def before_suites
28
+ super if defined?(super)
29
+ end
30
+
31
+ def after_suites
32
+ super if defined?(super)
14
33
  end
15
34
 
16
- module Helpers
35
+ def status(io = nil)
36
+ io ||= @@out
37
+ return io.puts ("%d tests, %d failures" % [assertion_count, failures]).green unless (failures.to_i > 0 || errors.to_i > 0)
38
+ format = "%d tests, %d assertions, %d failures, %d skipped/pending"
39
+ io.puts (format % [test_count, assertion_count, (failures + errors), skips]).red
40
+ end
41
+
42
+ def pad(str, size = 2)
43
+ " " * size + ("%5s" % str)
44
+ end
45
+
46
+ def puke klass, meth, e
17
47
 
18
- def to_html(string)
19
- string.strip
48
+ meth_title = meth.to_s.gsub("_", " ").capitalize
49
+ make_fail = lambda{ |k, m, msg, loc|
50
+ ["#{k} #{m}", pad("Failure/Error: #{msg}", 5).red, pad("#{loc}", 5)].join("\n")
51
+ }
52
+ make_bt = lambda{ | bt |
53
+ bt.map{ |line| "\e[90m# #{line}\e[0m" }.join("\n")
54
+ }
55
+
56
+ msg = case e
57
+ when MiniTest::Skip
58
+ @skips += 1
59
+ result = :skip
60
+ message = pad("(skipped/pending)", 6).yellow
61
+ "Pending: #{klass} #{meth}\n #{pad(location e)}]"
62
+ when MiniTest::Assertion
63
+ @failures += 1
64
+ result = :fail
65
+ message = pad("#{e.message}", 6).red
66
+ when defined?(RSpec::Expectations) && RSpec::Expectations::ExpectationNotMetError
67
+ @failures += 1
68
+ result = :fail
69
+ message = pad("#{e.message}", 6).red
70
+ else
71
+ @errors += 1
72
+ result = :error
73
+ message = pad("#{e.class}: #{e.message}\n", 6)
20
74
  end
21
75
 
22
- def fixture(name)
23
- path = File.join(File.expand_path('../fixtures', __FILE__), name)
24
- File.read(path).to_s.strip
76
+ loc = (result == :fail) ? location(e).split("\n") : MiniTest::filter_backtrace(e.backtrace)
77
+ msg = make_fail.call(klass, meth_title, e.message, make_bt.call(loc)) if result === :fail || result === :error
78
+
79
+ @report << msg
80
+ result
81
+ end
82
+
83
+ def _run_anything type
84
+ suites = TestCase.send "#{type}_suites"
85
+ return if suites.empty?
86
+
87
+ start = Time.now
88
+ puts "---------------------------------------------------------"
89
+ puts "Running #{type} suite(s)"
90
+ puts "---------------------------------------------------------"
91
+ puts
92
+ puts
93
+
94
+ @test_count, @assertion_count = 0, 0
95
+ sync = output.respond_to? :"sync=" # stupid emacs
96
+ old_sync, output.sync = output.sync, true if sync
97
+
98
+ before_suites
99
+ results = _run_suites suites, type
100
+
101
+ @test_count = results.inject(0) { |sum, (tc, _)| sum + tc }
102
+ @assertion_count = results.inject(0) { |sum, (_, ac)| sum + ac }
103
+
104
+ output.sync = old_sync if sync
105
+ after_suites
106
+
107
+ t = Time.now - start
108
+
109
+ puts
110
+ puts "Finished in %.5fs" % t
111
+ puts status
112
+
113
+ report.each_with_index do |msg, i|
114
+ puts "\n%3d) %s" % [i + 1, msg]
25
115
  end
116
+ puts
117
+ puts
118
+
119
+ if defined?(MiniTest::Growl)
120
+ MiniTest::Growl.new(self)
121
+ end
122
+
123
+ end
124
+
125
+ def _run_suite suite, type
126
+ header = "#{type}_suite_header"
127
+ puts send(header, suite) if respond_to? header
128
+
129
+ filter = options[:filter] || '/./'
130
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
131
+
132
+ available_suites = suite.send("#{type}_methods").grep(filter)
133
+ suite_name = suite.to_s.gsub(/Test$/i, '')
134
+
135
+ print "#{suite_name}\n" unless available_suites.empty?
136
+
137
+ assertions = available_suites.map { |method|
138
+ inst = suite.new method
139
+ inst._assertions = 0
140
+
141
+ @start_time = Time.now
142
+ result = inst.run self
143
+ repl_hash = { "_" => " ", ":" => "" }
144
+ meth_title = method.to_s.gsub(/\A(#{type.to_s})/, "").strip.gsub(/\A(\W|_)/){ repl_hash[$1] }.strip
145
+ meth_title = meth_title.gsub(/\A(#{suite_name})/i, '').strip.gsub("_", " ")
146
+
147
+ # Account for any sort of non-puke callback
148
+ response = if result.is_a?(Symbol)
149
+ (result == :skip) ? "#{meth_title} (skipped/pending)".yellow : "[x] : #{meth_title}".red
150
+ else
151
+ "[\u221A] : #{meth_title}".green
152
+ end
153
+
154
+ time = Time.now - @start_time
155
+
156
+ print pad(response)
157
+ print (" (%.2fs) " % time).clear
158
+ puts
159
+
160
+ inst._assertions
161
+ }
162
+
163
+ puts unless available_suites.empty?
164
+ return assertions.size, assertions.inject(0) { |sum, n| sum + n }
26
165
 
27
166
  end
28
167
 
29
- end
30
168
 
169
+ end
31
170
  end
32
171
 
33
- Tipsy.root = File.join(File.dirname(__FILE__), '.', 'root', 'test')
172
+ MiniTest::Unit.runner = MiniTest::SpecRunner.new
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class SiteTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ Tipsy::Site.configure!
7
+ end
8
+
9
+ test "before_compile should be a callable class method" do
10
+ Tipsy::Site.respond_to?(:before_compile).should == true
11
+ end
12
+
13
+ test "Defined callbacks should be runnable blocks" do
14
+ check = false
15
+ Tipsy::Site.before_compile do
16
+ check = true
17
+ end
18
+ Tipsy::Site.before_compile
19
+ check.should == true
20
+ end
21
+
22
+
23
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class TipsyTest < ActiveSupport::TestCase
4
+
5
+ test "A root method is defined, defaulting to ENV['TIPSY_ROOT']" do
6
+ assert_equal Tipsy.root, File.expand_path("../../", __FILE__) << "/root"
7
+ end
8
+
9
+ test "An env method is defined, defaulting to ENV['TIPSY_ENV']" do
10
+ assert_equal Tipsy.env, "test"
11
+ end
12
+
13
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ class SystemTest < ActiveSupport::TestCase
4
+ attr_reader :runner
5
+
6
+ class Runner
7
+ include Tipsy::Utils::System
8
+ end
9
+
10
+ def setup
11
+ @runner = Runner.new
12
+ end
13
+
14
+ test "Files can be excluded by extension" do
15
+ runner.excluded?("/home/someuser/another/something.rb").should == true
16
+ end
17
+
18
+ test "Entire directories can be excluded" do
19
+ runner.excluded?("/home/someuser/another/.svn").should == true
20
+ end
21
+
22
+ test "Non-excluded directories should be found" do
23
+ runner.excluded?("/home/someuser/another/something/").should == false
24
+ end
25
+
26
+ end
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+ require 'tipsy/view'
3
+
4
+ class ViewBaseTest < ActiveSupport::TestCase
5
+ attr_reader :path
6
+
7
+ def setup
8
+ @path ||= Tipsy::View::Path.new
9
+ end
10
+
11
+ test "It should find a default index template" do
12
+ path.locate_template('').should_not == nil
13
+ end
14
+
15
+ test "It should locate templates based on the path" do
16
+ path.locate_template("page").should_not == nil
17
+ end
18
+
19
+ test "Locating the default layout" do
20
+ path.locate_layout('default').should == expand_path('layouts', 'default.html.erb')
21
+ end
22
+
23
+ test "Template is found from the URI" do
24
+ path.locate_template('page').should == expand_path('views', 'page.html.erb')
25
+ end
26
+
27
+ private
28
+
29
+ def expand_path(*names)
30
+ names.unshift(Tipsy.root)
31
+ File.join(*names)
32
+ end
33
+
34
+ end
@@ -0,0 +1,34 @@
1
+ require 'test_helper'
2
+ require 'tipsy/view'
3
+
4
+ class ViewPathTest < ActiveSupport::TestCase
5
+ attr_reader :path
6
+
7
+ def setup
8
+ @path ||= Tipsy::View::Path.new
9
+ end
10
+
11
+ test "The default template should be index" do
12
+ path.locate_template('').should_not == nil
13
+ end
14
+
15
+ test "Pages should be found by path" do
16
+ path.locate_template("page").should_not == nil
17
+ end
18
+
19
+ test "The default layout should be found" do
20
+ path.locate_layout('default').should == expand_path('layouts', 'default.html.erb')
21
+ end
22
+
23
+ test "Templates should be found by URI if existing" do
24
+ path.locate_template('page').should == expand_path('views', 'page.html.erb')
25
+ end
26
+
27
+ private
28
+
29
+ def expand_path(*names)
30
+ names.unshift(Tipsy.root)
31
+ File.join(*names)
32
+ end
33
+
34
+ end
data/tipsy.gemspec CHANGED
@@ -3,10 +3,10 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require "tipsy/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
-
7
6
  s.name = "tipsy"
8
7
  s.version = Tipsy::VERSION
9
8
  s.authors = ["Brent Kirby"]
9
+ s.authors = ["Brent Kirby"]
10
10
  s.email = ["info@kurbmedia.com"]
11
11
  s.homepage = "https://github.com/kurbmedia/tipsy"
12
12
  s.summary = %q{A mini Rack application server for developing static sites.}
@@ -19,13 +19,16 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency("rack", "~> 1.2")
23
- s.add_dependency("rack-test", "~> 0.5")
22
+ s.add_dependency("rack", "~> 1.3")
23
+ s.add_dependency("rack-test", "~> 0.6")
24
24
  s.add_dependency("tilt", "~> 1.3")
25
- s.add_dependency("i18n", "~> 0.5")
25
+ s.add_dependency("i18n", "~> 0.6")
26
26
  s.add_dependency("sass", "~> 3.1")
27
- s.add_dependency("compass", "~> 11.5")
28
- s.add_dependency("activesupport", ">= 3.0")
29
- s.add_dependency('sprockets', '~> 2.0.0.beta.12')
27
+ s.add_dependency("activesupport", ">= 3.1")
28
+ s.add_dependency('sprockets', '~> 2.0')
29
+ s.add_dependency("hike", "~> 1.2")
30
+ s.add_dependency("erubis", "~> 2.7")
31
+
32
+ s.add_development_dependency("minitest", "~> 2.5")
30
33
 
31
34
  end