redrum 0.3.4 → 0.4.0

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,20 @@
1
+ Feature: Templates
2
+ So that I can choose a template for my redrum project
3
+ As a web designer
4
+ I want to be able to select a specific template from all the available templates
5
+
6
+ Scenario: Creating a redrum project called MyBLog with --template bright or -t bright
7
+ Given there is no directory already existing at "MyBlog"
8
+ When I start redrum with "--template=bright" or "-t bright"
9
+ Then I want to get a Rakefile in MyBlog
10
+ And I want to get a haml/index.haml in MyBlog
11
+ And I want to get a public/css/bright.css in MyBlog
12
+ And I want to see "Copying default/Rakefile to MyBlog/Rakefile" from the command line
13
+ And I want to see "Copying default/haml to MyBlog/haml" from the command line
14
+ And I want to see "Copying default/public to MyBlog/public" from the command line
15
+ And I want to see "Overwriting MyBlog/public with bright/public" from the command line
16
+
17
+ Scenario: Checking out what templates are there to choose from
18
+ When I start redrum with "--list-templates" or "-l"
19
+ Then I want to see "default" from the command line
20
+ And I want to see "bright" from the command line
@@ -5,7 +5,8 @@ require File.expand_path("../redrum/skeleton", __FILE__)
5
5
  require File.expand_path("../redrum/redrum", __FILE__)
6
6
  require File.expand_path("../redrum/cli", __FILE__)
7
7
  require File.expand_path("../redrum/default_files", __FILE__)
8
+ require File.expand_path("../redrum/templates", __FILE__)
8
9
  require "fileutils"
9
10
 
10
- REDRUM_VERSION = "0.3.4"
11
+ REDRUM_VERSION = "0.4.0"
11
12
 
@@ -14,6 +14,14 @@ module Redrum
14
14
  out.puts "Redrum v" + REDRUM_VERSION
15
15
  return false
16
16
  end
17
+ opts.on("-t", "--template=TEMPLATE", "Select a template") do |template|
18
+ options[:template] = template
19
+ return options
20
+ end
21
+ opts.on("-l", "--list-templates", "List all available templates") do
22
+ Redrum::Templates.list(out)
23
+ return false
24
+ end
17
25
  opts.on_tail do
18
26
  out.puts opts
19
27
  end
@@ -21,7 +29,7 @@ module Redrum
21
29
 
22
30
  opt.parse!
23
31
  options
24
- rescue OptionParser::InvalidOption => e
32
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
25
33
  out.puts e.to_s
26
34
  out.puts opt.to_s
27
35
  false
@@ -4,6 +4,7 @@ module Redrum
4
4
  def self.make(project_dir, params={})
5
5
  Skeleton.new(project_dir, params)
6
6
  DefaultFiles.copy(project_dir, params)
7
+ Templates.copy(project_dir, params) if params[:template]
7
8
  rescue Errno::EEXIST => e
8
9
  params[:output_to].puts e.to_s if params[:output_to]
9
10
  end
@@ -0,0 +1,18 @@
1
+ module Redrum
2
+ class Templates
3
+ def self.copy(project_dir, params = {})
4
+ Dir[File.expand_path("../../../templates/#{params[:template]}/*", __FILE__)].each do |template|
5
+ source = template.scan(/templates\/(.+)$/).flatten.to_s
6
+ destination = project_dir + "/" + source.scan(/^.+?\/(.+)$/).to_s
7
+ params[:output_to].puts "Overwriting #{destination} with #{source}" if params[:output_to]
8
+ FileUtils.cp_r(template, project_dir)
9
+ end
10
+ end
11
+
12
+ def self.list(out=STDOUT)
13
+ Dir[File.expand_path("../../../templates/*", __FILE__)].each do |template|
14
+ out.puts template.scan(/.+\/([^\/]+)$/).to_s
15
+ end
16
+ end
17
+ end
18
+ end
@@ -63,5 +63,28 @@ describe Redrum::CLI do
63
63
  end
64
64
  end
65
65
 
66
+ context "with -t, --template=TEMPLATE" do
67
+ before { no_warnings { ARGV = ["temp", "--template=default"] } }
68
+
69
+ it "returns a hash" do
70
+ Redrum::CLI.parse(@messenger).should be_kind_of(Hash)
71
+ end
72
+ end
73
+
74
+ context "with -l, --list-templates" do
75
+ before { no_warnings { ARGV = ["-l"] } }
76
+
77
+ it "shows a list of available templates" do
78
+ Redrum::CLI.parse(@messenger)
79
+ @messenger.string.should include("default")
80
+ @messenger.string.should include("bright")
81
+ end
82
+
83
+ it "returns false" do
84
+ Redrum::CLI.parse(@messenger).should == false
85
+ end
86
+
87
+ end
88
+
66
89
  end
67
90
  end
@@ -0,0 +1,40 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ describe Redrum::Templates do
4
+ before do
5
+ @project = "temp"
6
+ @messenger = StringIO.new
7
+ @options = { :template => "bright", :output_to => @messenger }
8
+ FileUtils.rm_rf @project rescue nil
9
+ end
10
+
11
+ after(:all) do
12
+ FileUtils.rm_rf @project rescue nil
13
+ end
14
+
15
+ describe "self#copy" do
16
+ it "copies the public folder from the template to the project folder" do
17
+ FileUtils.as_null_object.should_receive(:cp_r).with(File.expand_path("../../../templates/bright/public", __FILE__), @project)
18
+ Redrum::Templates.copy(@project, @options)
19
+ end
20
+
21
+ it "copies the haml folder from the template to project folder" do
22
+ FileUtils.as_null_object.should_receive(:cp_r).with(File.expand_path("../../../templates/bright/haml", __FILE__), @project)
23
+ Redrum::Templates.copy(@project, @options)
24
+ end
25
+ it "prints what files it is copying/overwriting" do
26
+ @messenger.as_null_object.should_receive(:puts).with("Overwriting #{@project}/public with bright/public")
27
+ Redrum::Templates.copy(@project, @options)
28
+ end
29
+ end
30
+
31
+ describe "self#list" do
32
+ it "shows every available template" do
33
+ Redrum::Templates.list(@messenger)
34
+ Dir[File.expand_path("../../../templates/*", __FILE__)].each do |template|
35
+ @messenger.string.should include template.scan(/.+\/([^\/]+)$/).to_s
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,11 +1,4 @@
1
1
  require File.expand_path( "../../lib/redrum", __FILE__ )
2
+ require File.expand_path("../../helpers", __FILE__)
2
3
  require "fileutils"
3
4
  require "stringio"
4
-
5
- def no_warnings
6
- verbosity = $VERBOSE
7
- $VERBOSE = nil
8
- result = yield
9
- $VERBOSE = verbosity
10
- result
11
- end
@@ -0,0 +1,35 @@
1
+ !!!
2
+ %html(xmlns="http://www.w3.org/1999/xhtml")
3
+ %head
4
+ %meta(http-equiv="content-type" content="text/html; charset=utf-8")
5
+ %link(href="css/bright.css" rel="stylesheet" media="screen")
6
+ %title Redrum::Default
7
+ %body
8
+ #wrapper
9
+ #header
10
+ %h1 Welcome to Redrum!
11
+ %p
12
+ %em A way to quickly produce static websites for the ruby enthusiast!
13
+ #content
14
+ %h2 What's this redrum then?
15
+ %p
16
+ Say, you like to work with haml and use rake for lot's of stuff?
17
+ That's of course great when working with frameworks that use and
18
+ support these tools, like rails. But what about static websites for
19
+ example? Wouldn't it be nice to be able to utilitze haml and rake
20
+ effectively for those kinda projects?
21
+ %em That's where redrum comes in!
22
+ %p
23
+ The purpose of redrum is to make developing static websites easier,
24
+ faster and especially more organized by creating a skeleton project
25
+ for you. You just add your content, run rake and deploy.
26
+ %h2 Workflow
27
+ %h3 The general workflow is as follows:
28
+ %ul
29
+ %li Edit one or more haml files in [project folder]/haml
30
+ %li run rake to translate all haml-files into html-files in [project folder]/public
31
+ %li Deploy by uploading all content from the public folder to your webserver
32
+ #footer
33
+ %p
34
+ %a(href="http://github.com/oem/redrum")redrum on github
35
+
@@ -0,0 +1,69 @@
1
+ /* General Styles */
2
+
3
+ body {
4
+ font: 10px Arial, Helvetica;
5
+ color: #666666;
6
+ background-color: #F5F5F5;
7
+ padding: 0px;
8
+ margin: 0px;
9
+ }
10
+
11
+ h1, h2, h3, h4 {
12
+ font: italic 16px "Georgia", "Times", serif;
13
+ color: #222222;
14
+ }
15
+
16
+ p {
17
+ line-height: 1.5em;
18
+ }
19
+
20
+ em {
21
+ color: #3592a8;
22
+ padding: 4px 8px;
23
+ font-style: italic;
24
+ }
25
+
26
+ a {
27
+ color: #000;
28
+ text-decoration: none;
29
+ font-weight: bold;
30
+ border-bottom: dotted 1px #009983;
31
+ padding: 2px 5px;
32
+ border-bottom: dotted 1px #aaa;
33
+ }
34
+
35
+ a:hover {
36
+ border:none;
37
+ color: #aaa;
38
+ }
39
+
40
+ ul {
41
+ list-style-type: none;
42
+ padding: 0;
43
+ }
44
+
45
+ #wrapper {
46
+ width: 1000px;
47
+ font-size: 1.3em;
48
+ padding: 1em .5em;
49
+ }
50
+
51
+ /* Page Structure */
52
+
53
+ #header {
54
+ margin-top: 1.5em;
55
+ }
56
+
57
+ #header, #content, #footer{
58
+ padding-left: 200px;
59
+ padding-right: 30px;
60
+ }
61
+
62
+ #header h1 {
63
+ font-size: 3em;
64
+ }
65
+
66
+ #footer {
67
+ margin-top: 50px;
68
+ }
69
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redrum
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
8
  - 4
10
- version: 0.3.4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - !binary |
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-11-16 00:00:00 +01:00
20
+ date: 2010-12-07 00:00:00 +01:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -49,16 +49,21 @@ files:
49
49
  - lib/redrum/default_files.rb
50
50
  - lib/redrum/redrum.rb
51
51
  - lib/redrum/skeleton.rb
52
+ - lib/redrum/templates.rb
52
53
  - lib/redrum.rb
53
54
  - spec/redrum/cli_spec.rb
54
55
  - spec/redrum/default_files_spec.rb
55
56
  - spec/redrum/redrum_spec.rb
56
57
  - spec/redrum/skeleton_spec.rb
58
+ - spec/redrum/templates_spec.rb
57
59
  - spec/spec_helper.rb
58
60
  - bin/redrum
59
61
  - features/command_line_interface.feature
60
62
  - features/create_folder_skeleton.feature
61
63
  - features/default_files.feature
64
+ - features/templates.feature
65
+ - templates/bright/haml/index.haml
66
+ - templates/bright/public/css/bright.css
62
67
  - templates/default/haml/index.haml
63
68
  - templates/default/public/css/default.css
64
69
  - templates/default/Rakefile