redrum 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/features/default_files.feature +15 -0
- data/lib/redrum.rb +3 -1
- data/lib/redrum/cli.rb +0 -7
- data/lib/redrum/default_files.rb +12 -0
- data/lib/redrum/redrum.rb +7 -4
- data/spec/redrum/cli_spec.rb +0 -16
- data/spec/redrum/default_files_spec.rb +28 -0
- data/spec/redrum/redrum_spec.rb +28 -3
- data/spec/redrum/skeleton_spec.rb +3 -2
- metadata +12 -7
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: Default files
|
2
|
+
In order to easily and quickly create websites by only filling in the specific data
|
3
|
+
As a web designer
|
4
|
+
I want to already have some default files I can quickly modify to have a complete website
|
5
|
+
|
6
|
+
Scenario: Creating a redrum project without any special options
|
7
|
+
Given there is no directory already existing at "MyBlog"
|
8
|
+
When I start redrum with "MyBlog"
|
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/default.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
|
+
|
data/lib/redrum.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
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
|
+
require File.expand_path("../redrum/default_files", __FILE__)
|
8
|
+
require "fileutils"
|
7
9
|
|
8
|
-
REDRUM_VERSION = "0.
|
10
|
+
REDRUM_VERSION = "0.3.0"
|
9
11
|
|
data/lib/redrum/cli.rb
CHANGED
@@ -2,13 +2,6 @@ require "optparse"
|
|
2
2
|
|
3
3
|
module Redrum
|
4
4
|
class CLI
|
5
|
-
def initialize(project, params={})
|
6
|
-
params = {:output_to => STDOUT}.merge params
|
7
|
-
@skeleton = Skeleton.new(project, params)
|
8
|
-
rescue Errno::EEXIST => e
|
9
|
-
params[:output_to].puts e.to_s
|
10
|
-
end
|
11
|
-
|
12
5
|
def self.parse(out=STDOUT)
|
13
6
|
options = {}
|
14
7
|
opt = OptionParser.new do |opts|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Redrum
|
2
|
+
class DefaultFiles
|
3
|
+
def self.copy(project_dir, params={})
|
4
|
+
Dir[File.expand_path("../../../templates/default/*", __FILE__)].each do |default|
|
5
|
+
source = default.scan(/templates\/(.+)$/).flatten.to_s
|
6
|
+
destination = project_dir + "/" + source.scan(/^.+?\/(.+)$/).to_s
|
7
|
+
params[:output_to].puts "Copying #{source} to #{destination}" if params[:output_to]
|
8
|
+
FileUtils.cp_r(default, project_dir)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/redrum/redrum.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Redrum
|
2
2
|
FOLDER_STRUCTURE = %w[haml public public/css public/img public/js]
|
3
3
|
|
4
|
-
def self.make(project_dir)
|
5
|
-
Skeleton.new(project_dir)
|
4
|
+
def self.make(project_dir, params={})
|
5
|
+
Skeleton.new(project_dir, params)
|
6
|
+
DefaultFiles.copy(project_dir, params)
|
7
|
+
rescue Errno::EEXIST => e
|
8
|
+
params[:output_to].puts e.to_s if params[:output_to]
|
6
9
|
end
|
7
10
|
|
8
11
|
def self.folder_structure
|
@@ -12,10 +15,10 @@ module Redrum
|
|
12
15
|
def self.start(out=STDOUT)
|
13
16
|
project = ARGV[0]
|
14
17
|
if (ARGV.size == 1) and (ARGV[0] =~ /^[^-].+/)
|
15
|
-
Redrum
|
18
|
+
Redrum.make(project, :output_to => out) if project
|
16
19
|
elsif options = Redrum::CLI.parse(out)
|
17
20
|
options = { :output_to => out }.merge options
|
18
|
-
Redrum
|
21
|
+
Redrum.make(project, options) if project
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
data/spec/redrum/cli_spec.rb
CHANGED
@@ -1,20 +1,6 @@
|
|
1
1
|
require File.expand_path("../../spec_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Redrum::CLI do
|
4
|
-
describe "#new" do
|
5
|
-
it "creates a new Redrum::Skeleton instance" do
|
6
|
-
Redrum::Skeleton.should_receive(:new).with("temp", {:output_to => STDOUT})
|
7
|
-
Redrum::CLI.new("temp")
|
8
|
-
end
|
9
|
-
|
10
|
-
it "catches an error raised by Redrum::Skeleton.new if a directory already exists" do
|
11
|
-
messenger = StringIO.new
|
12
|
-
Redrum::CLI.new("temp", :output_to => messenger)
|
13
|
-
messenger.should_receive(:puts).with("File exists - temp")
|
14
|
-
Redrum::CLI.new("temp", :output_to => messenger)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
4
|
describe "#self.parse" do
|
19
5
|
before do
|
20
6
|
no_warnings { ARGV = [] }
|
@@ -75,8 +61,6 @@ describe Redrum::CLI do
|
|
75
61
|
Redrum::CLI.parse(@messenger)
|
76
62
|
@messenger.string.should include("Redrum v")
|
77
63
|
end
|
78
|
-
|
79
|
-
|
80
64
|
end
|
81
65
|
|
82
66
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Redrum::DefaultFiles do
|
4
|
+
before do
|
5
|
+
@project = "temp"
|
6
|
+
FileUtils.rm_rf @project rescue nil
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
FileUtils.rm_rf @project rescue nil
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#copy" do
|
14
|
+
it "calls FileUtils.cp_r to copy Rakefile" do
|
15
|
+
FileUtils.as_null_object.should_receive(:cp_r).with(File.expand_path("../../../templates/default/Rakefile", __FILE__), @project)
|
16
|
+
Redrum::DefaultFiles.copy(@project)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "prints what files and directories it is copying to :output_to" do
|
20
|
+
@messenger = StringIO.new
|
21
|
+
@messenger.as_null_object.should_receive(:puts).with("Copying default/Rakefile to temp/Rakefile")
|
22
|
+
@messenger.as_null_object.should_receive(:puts).with("Copying default/haml to temp/haml")
|
23
|
+
@messenger.as_null_object.should_receive(:puts).with("Copying default/public to temp/public")
|
24
|
+
FileUtils.stub(:cp_r)
|
25
|
+
Redrum::DefaultFiles.copy(@project, :output_to => @messenger)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/redrum/redrum_spec.rb
CHANGED
@@ -9,9 +9,21 @@ describe Redrum do
|
|
9
9
|
|
10
10
|
describe "#self.make" do
|
11
11
|
it "wraps the Redrum::Skeleton.new call" do
|
12
|
-
Redrum::Skeleton.should_receive(:new).with(@target)
|
12
|
+
Redrum::Skeleton.should_receive(:new).with(@target, {})
|
13
|
+
Redrum::DefaultFiles.stub(:copy)
|
13
14
|
Redrum.make(@target)
|
14
15
|
end
|
16
|
+
|
17
|
+
it "calls Redrum::DefaultFiles.copy" do
|
18
|
+
Redrum::DefaultFiles.should_receive(:copy).with(@target, :output_to => @messenger)
|
19
|
+
Redrum.make(@target, :output_to => @messenger)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "rescues the raised error from Skeleton.new and prints out a nice error message" do
|
23
|
+
@messenger.should_receive(:puts).with("File exists - temp")
|
24
|
+
Redrum.make(@target, :output_to => @messenger)
|
25
|
+
end
|
26
|
+
|
15
27
|
end
|
16
28
|
|
17
29
|
describe "#self.folder_structure" do
|
@@ -24,17 +36,30 @@ describe Redrum do
|
|
24
36
|
describe "#self.start" do
|
25
37
|
before { Dir.stub(:mkdir) }
|
26
38
|
|
27
|
-
it "wraps
|
28
|
-
Redrum::
|
39
|
+
it "wraps Skeleton.new" do
|
40
|
+
Redrum::Skeleton.should_receive(:new)
|
41
|
+
Redrum.start(@messenger)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "calls Redrum.make to do the backend work" do
|
45
|
+
Redrum.should_receive(:make)
|
29
46
|
Redrum.start(@messenger)
|
30
47
|
end
|
31
48
|
|
32
49
|
it "calls Redrum::CLI.parse when there seem to be parameters to parse" do
|
50
|
+
no_warnings { ARGV = [ @target, "--help" ] }
|
33
51
|
Redrum::CLI.should_receive(:parse)
|
34
52
|
Redrum::CLI.stub(:new)
|
35
53
|
Redrum.start(@messenger)
|
36
54
|
end
|
37
55
|
|
56
|
+
it "does not call Redrum::CLI.parse when there was only a project name given" do
|
57
|
+
no_warnings { ARGV = [ @target ] }
|
58
|
+
Redrum::CLI.should_not_receive(:parse)
|
59
|
+
Redrum::CLI.stub(:new)
|
60
|
+
Redrum.start(@messenger)
|
61
|
+
end
|
62
|
+
|
38
63
|
it "does not show the help page when a project name is defined without parameters" do
|
39
64
|
no_warnings { ARGV = [ @target ] }
|
40
65
|
Redrum.start(@messenger)
|
@@ -4,6 +4,7 @@ describe Redrum::Skeleton do
|
|
4
4
|
before do
|
5
5
|
@target = "temp"
|
6
6
|
FileUtils.rm_rf(@target) rescue nil
|
7
|
+
@messenger = StringIO.new
|
7
8
|
end
|
8
9
|
|
9
10
|
after(:all) { FileUtils.rm_rf("temp") rescue nil }
|
@@ -22,8 +23,8 @@ describe Redrum::Skeleton do
|
|
22
23
|
end
|
23
24
|
|
24
25
|
it "informs us what folders it creates, if params[:output_to] is defined" do
|
25
|
-
|
26
|
-
Redrum::Skeleton.new(@target, :output_to =>
|
26
|
+
@messenger.as_null_object.should_receive(:puts).with("Creating temp")
|
27
|
+
Redrum::Skeleton.new(@target, :output_to => @messenger)
|
27
28
|
end
|
28
29
|
|
29
30
|
it "does not print what it creates if params[:output_to] is not defined" do
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.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-
|
20
|
+
date: 2010-11-04 00:00:00 +01:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -28,10 +28,12 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
31
|
+
hash: 7
|
32
32
|
segments:
|
33
|
+
- 3
|
34
|
+
- 0
|
33
35
|
- 0
|
34
|
-
version:
|
36
|
+
version: 3.0.0
|
35
37
|
type: :runtime
|
36
38
|
version_requirements: *id001
|
37
39
|
description: Create static websites with a little help from redrum!
|
@@ -44,16 +46,19 @@ extra_rdoc_files: []
|
|
44
46
|
|
45
47
|
files:
|
46
48
|
- lib/redrum/cli.rb
|
49
|
+
- lib/redrum/default_files.rb
|
47
50
|
- lib/redrum/redrum.rb
|
48
51
|
- lib/redrum/skeleton.rb
|
49
52
|
- lib/redrum.rb
|
50
53
|
- spec/redrum/cli_spec.rb
|
54
|
+
- spec/redrum/default_files_spec.rb
|
51
55
|
- spec/redrum/redrum_spec.rb
|
52
56
|
- spec/redrum/skeleton_spec.rb
|
53
57
|
- spec/spec_helper.rb
|
54
58
|
- bin/redrum
|
55
59
|
- features/command_line_interface.feature
|
56
60
|
- features/create_folder_skeleton.feature
|
61
|
+
- features/default_files.feature
|
57
62
|
has_rdoc: true
|
58
63
|
homepage: http://darkno.de
|
59
64
|
licenses: []
|