carb 0.0.4 → 0.0.5
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.
- data/.rspec +2 -0
- data/CHANGELOG.md +1 -1
- data/README.md +28 -18
- data/bin/carb +1 -4
- data/carb.gemspec +6 -1
- data/lib/carb/cli.rb +29 -11
- data/lib/carb/controller.rb +50 -17
- data/lib/carb/version.rb +1 -1
- data/lib/carb.rb +2 -0
- data/spec/carb/cli_spec.rb +62 -0
- data/spec/spec_helper.rb +40 -0
- metadata +43 -10
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,34 +3,44 @@
|
|
3
3
|
Tool to help us set up our web apps faster. It can merge different subprojects
|
4
4
|
and deliver a folder ready to start developing.
|
5
5
|
|
6
|
-
|
6
|
+
# Install #
|
7
7
|
|
8
|
-
|
9
|
-
- octaplus: octaplus installation
|
10
|
-
- bearded-octo: frontend framework topped with moreorless
|
8
|
+
gem install carb
|
11
9
|
|
12
|
-
|
10
|
+
### RMagick and OSX ###
|
11
|
+
For all file/dir related tasks, the gem relies on FileUtils, which itself relies on the RMagick gem. If you are on OSX, and having trouble, please try to install RMagic:
|
13
12
|
|
14
|
-
|
13
|
+
- through (homebrew)[http://mxcl.github.com/homebrew/], just run
|
14
|
+
`$ brew update | brew install imagemagick`
|
15
|
+
- by using [this great script](https://github.com/maddox/magick-installer)
|
15
16
|
|
16
|
-
|
17
|
+
# Usage #
|
17
18
|
|
18
|
-
|
19
|
+
$ carb create TYPE TARGET_FOLDER
|
20
|
+
=> Installs a specific type, just run the command
|
19
21
|
|
20
|
-
$
|
22
|
+
$ carb [-h|--help]
|
23
|
+
=> Display usage information
|
21
24
|
|
22
|
-
|
25
|
+
# The possible types are
|
23
26
|
|
24
|
-
|
27
|
+
# - on-fire: octaplus topped with bearded-octo and moreorless (default)
|
28
|
+
# - octaplus: a fuelphp installation
|
29
|
+
# - bearded-octo: frontend framework topped with moreorless
|
25
30
|
|
26
|
-
|
31
|
+
# Installation types #
|
27
32
|
|
28
|
-
|
33
|
+
Available setups are:
|
29
34
|
|
30
|
-
|
35
|
+
- on-fire: [octaplus](https://github.com/proximitybbdo/octaplus) topped with [bearded-octo](https://github.com/proximitybbdo/bearded-octo) and [moreorless](https://github.com/rob-bar/moreorless) (default)
|
36
|
+
- octaplus: octaplus installation, which is a basic FuelPHP installation
|
37
|
+
- bearded-octo: frontend framework topped with moreorless
|
31
38
|
|
32
|
-
|
39
|
+
# Contributing #
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
Fork, alter, pull request!
|
42
|
+
|
43
|
+
## Copyright ##
|
44
|
+
|
45
|
+
Copyright (c) 2012 Proximity BBDO
|
46
|
+
See LICENSE for details.
|
data/bin/carb
CHANGED
data/carb.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["jeroenbourgois@gmail.com"]
|
7
7
|
gem.description = %q{Boost the start of a Proximity BBDO Octaplus framework}
|
8
8
|
gem.summary = %q{Boost the start of a Proximity BBDO Octaplus framework}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/proximitybbdo/carb"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -15,6 +15,11 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Carb::VERSION
|
17
17
|
|
18
|
+
gem.required_ruby_version = '>= 1.9'
|
19
|
+
|
18
20
|
gem.add_dependency "clamp"
|
19
21
|
gem.add_dependency "fileutils"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "stringio"
|
20
25
|
end
|
data/lib/carb/cli.rb
CHANGED
@@ -1,35 +1,53 @@
|
|
1
|
-
require
|
1
|
+
require "clamp/command"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "carb/config"
|
4
|
+
require "carb/controller"
|
5
|
+
require "carb/logger"
|
6
|
+
require "carb/version"
|
6
7
|
|
7
8
|
module Carb
|
8
9
|
module CLI
|
9
10
|
|
10
11
|
class InstallCommand < Clamp::Command
|
11
|
-
parameter "TYPE", "
|
12
|
+
parameter "TYPE", "Type of project, one of:
|
13
|
+
------------------------
|
14
|
+
|
15
|
+
octaplus a clean fuelphp installation,
|
16
|
+
with no frontend classes merged
|
17
|
+
|
18
|
+
bearded-octo frontend only, merges our frontend framework
|
19
|
+
with the moreorless less package
|
20
|
+
|
21
|
+
on-fire [recommended] combo of octaplus and bearded-octo
|
22
|
+
|
23
|
+
" do |s|
|
12
24
|
raise ArgumentError.new('Not a correct project type.') unless Carb::Config::PROJECT_TYPES.include?(s)
|
13
25
|
s # return the actual value
|
14
26
|
end
|
15
27
|
|
16
|
-
parameter "[TARGET]", "
|
28
|
+
parameter "[TARGET]", "target folder", :default => "."
|
29
|
+
|
30
|
+
option ["--force", "-f"], :flag, "force overwrite of the target folder if it exists"
|
17
31
|
|
18
32
|
def execute
|
19
|
-
Carb::Controller.assemble(type, target)
|
33
|
+
Carb::Controller.assemble(type, target, force?)
|
20
34
|
end
|
21
35
|
end
|
22
36
|
|
23
37
|
class MainCommand < Clamp::Command
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
38
|
+
option ["--version", "-v"], :flag, "show version" do
|
39
|
+
puts "Carb #{Carb::VERSION}"
|
40
|
+
exit(0)
|
41
|
+
end
|
28
42
|
|
29
43
|
subcommand "install", "Install a new project", InstallCommand
|
30
44
|
end
|
31
45
|
|
32
46
|
def self.run(*a)
|
47
|
+
Logger::log('TODO: alter the default view, merge with index.html', Logger::WARNING)
|
48
|
+
Logger::log('TODO: check if repos are there', Logger::WARNING)
|
49
|
+
puts ''
|
50
|
+
|
33
51
|
MainCommand.run(*a)
|
34
52
|
end
|
35
53
|
end
|
data/lib/carb/controller.rb
CHANGED
@@ -1,38 +1,63 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
|
2
|
+
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module Carb
|
5
6
|
class Controller
|
6
7
|
class << self
|
7
8
|
|
8
|
-
type, pwd, target = '', '', ''
|
9
|
+
type, pwd, target, force = '', '', '', false
|
9
10
|
|
10
11
|
##################################
|
11
12
|
# the chef
|
12
13
|
##################################
|
13
14
|
|
14
|
-
def assemble(type, target)
|
15
|
+
def assemble(type, target, force)
|
15
16
|
|
16
17
|
@type = type
|
17
18
|
@target = target || "."
|
19
|
+
@force = force || false
|
20
|
+
|
21
|
+
if check_target() == true
|
22
|
+
set_up()
|
23
|
+
|
24
|
+
case @type
|
25
|
+
when Config::TYPE_OCTAPLUS
|
26
|
+
cook_octaplus()
|
27
|
+
when Config::TYPE_BEARDED_OCTO
|
28
|
+
cook_bearded_octo()
|
29
|
+
when Config::TYPE_ON_FIRE
|
30
|
+
cook_on_fire()
|
31
|
+
end
|
32
|
+
|
33
|
+
tear_down()
|
34
|
+
else
|
35
|
+
exit(1)
|
36
|
+
end
|
37
|
+
end
|
18
38
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
39
|
+
def check_target()
|
40
|
+
# check if target exists, if it does and
|
41
|
+
# force is false, stop right here
|
42
|
+
if File.directory?(@target)
|
43
|
+
if @force
|
44
|
+
FileUtils.rm_rf(Dir.glob("#{@target}/*"))
|
45
|
+
return true
|
46
|
+
else
|
47
|
+
Logger::log("⚡ Target folder exists, use --force | -f to overwrite ⚡", Logger::ERROR)
|
48
|
+
return false
|
49
|
+
end
|
28
50
|
end
|
29
51
|
|
30
|
-
|
52
|
+
return true
|
31
53
|
end
|
32
54
|
|
33
55
|
def set_up
|
34
56
|
Logger::log("⚡ Preparing your package, hold on ⚡", Logger::INFO)
|
35
57
|
|
58
|
+
# clean up if the tear down left some crappers
|
59
|
+
FileUtils.remove_dir "#{Config::TMP_FOLDER}", :force => true
|
60
|
+
|
36
61
|
# save pwd
|
37
62
|
@pwd = Dir.pwd
|
38
63
|
|
@@ -52,7 +77,7 @@ module Carb
|
|
52
77
|
Logger::log("⚡⚡⚡ Et voila! All set in the ./#{@target} folder ⚡⚡⚡ ", Logger::SUCCESS)
|
53
78
|
|
54
79
|
# clean up
|
55
|
-
|
80
|
+
FileUtils.remove_dir "#{Config::TMP_FOLDER}", :force => true
|
56
81
|
end
|
57
82
|
|
58
83
|
##################################
|
@@ -94,17 +119,25 @@ module Carb
|
|
94
119
|
get_bearded_octo()
|
95
120
|
get_moreorless()
|
96
121
|
|
97
|
-
FileUtils.remove_dir "#{Config::DIR_OCTAPLUS}/assets"
|
98
122
|
FileUtils.mkdir_p "#{Config::DIR_COOKPOT}/assets"
|
99
123
|
|
100
|
-
FileUtils.cp_r "#{Config::DIR_BEARDED}
|
124
|
+
FileUtils.cp_r "#{Config::DIR_BEARDED}/.", "#{Config::DIR_COOKPOT}/"
|
101
125
|
FileUtils.remove_dir "#{Config::DIR_MOREORLESS}/tests"
|
102
126
|
FileUtils.cp_r "#{Config::DIR_MOREORLESS}/.", "#{Config::DIR_COOKPOT}/assets/css"
|
103
127
|
end
|
104
128
|
|
105
129
|
def cook_on_fire
|
106
130
|
get_octaplus()
|
107
|
-
|
131
|
+
get_bearded_octo()
|
132
|
+
get_moreorless()
|
133
|
+
|
134
|
+
FileUtils.mkdir_p "#{Config::DIR_COOKPOT}/assets"
|
135
|
+
|
136
|
+
FileUtils.cp_r "#{Config::DIR_BEARDED}/assets", "#{Config::DIR_COOKPOT}/"
|
137
|
+
FileUtils.remove_dir "#{Config::DIR_MOREORLESS}/tests"
|
138
|
+
FileUtils.cp_r "#{Config::DIR_MOREORLESS}/.", "#{Config::DIR_COOKPOT}/assets/css"
|
139
|
+
|
140
|
+
FileUtils.remove_dir "#{Config::DIR_OCTAPLUS}/assets"
|
108
141
|
|
109
142
|
FileUtils.cp_r "#{Config::DIR_OCTAPLUS}/.", "#{Config::DIR_COOKPOT}"
|
110
143
|
FileUtils.cp_r "#{Config::DIR_BEARDED}/index.html", "#{Config::DIR_COOKPOT}/fuel/app/views/welcome"
|
data/lib/carb/version.rb
CHANGED
data/lib/carb.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Carb::CLI do
|
4
|
+
|
5
|
+
include OutputCapture
|
6
|
+
|
7
|
+
describe "MainCommand" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@command = Carb::CLI::MainCommand.new("")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "without parameters" do
|
14
|
+
|
15
|
+
it "shows the help" do
|
16
|
+
|
17
|
+
lambda do
|
18
|
+
@command.parse(%w(--help))
|
19
|
+
end.should raise_error(Clamp::HelpWanted)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "InstallCommand" do
|
27
|
+
|
28
|
+
before do
|
29
|
+
@command = Carb::CLI::InstallCommand.new("")
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "with an invalid type" do
|
33
|
+
|
34
|
+
it "fails and leaves you burning in hell" do
|
35
|
+
lambda do
|
36
|
+
@command.parse(['bogus'])
|
37
|
+
end.should raise_error(Clamp::UsageError, /TYPE/)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "with a valid type and target" do
|
43
|
+
|
44
|
+
it "will give you what you want, a package" do
|
45
|
+
@command.parse(['octaplus', '/tmp/carb-rspec'])
|
46
|
+
@command.execute()
|
47
|
+
stdout.should include("voila")
|
48
|
+
|
49
|
+
@command.parse(['bearded-octo', '/tmp/carb-rspec'])
|
50
|
+
@command.execute()
|
51
|
+
stdout.should include("voila")
|
52
|
+
|
53
|
+
@command.parse(['on-fire', '/tmp/carb-rspec'])
|
54
|
+
@command.execute()
|
55
|
+
stdout.should include("voila")
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'carb'
|
2
|
+
require 'stringio' # capture streams
|
3
|
+
|
4
|
+
module OutputCapture
|
5
|
+
|
6
|
+
def self.included(target)
|
7
|
+
|
8
|
+
target.before do
|
9
|
+
$stdout = @out = StringIO.new
|
10
|
+
$stderr = @err = StringIO.new
|
11
|
+
end
|
12
|
+
|
13
|
+
target.after do
|
14
|
+
$stdout = STDOUT
|
15
|
+
$stderr = STDERR
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def stdout
|
21
|
+
@out.string
|
22
|
+
end
|
23
|
+
|
24
|
+
def stderr
|
25
|
+
@err.string
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# RSpec.configure do |config|
|
31
|
+
# config.treat_symbols_as_metadata_keys_with_true_values = true
|
32
|
+
# config.run_all_when_everything_filtered = true
|
33
|
+
# config.filter_run :focus
|
34
|
+
#
|
35
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
36
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
37
|
+
# # the seed, which is printed after each run.
|
38
|
+
# # --seed 1234
|
39
|
+
# config.order = 'random'
|
40
|
+
# end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeroen Bourgois
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-10-
|
18
|
+
date: 2012-10-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: clamp
|
@@ -45,6 +45,34 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: stringio
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
48
76
|
description: Boost the start of a Proximity BBDO Octaplus framework
|
49
77
|
email:
|
50
78
|
- jeroenbourgois@gmail.com
|
@@ -56,6 +84,7 @@ extra_rdoc_files: []
|
|
56
84
|
|
57
85
|
files:
|
58
86
|
- .gitignore
|
87
|
+
- .rspec
|
59
88
|
- CHANGELOG.md
|
60
89
|
- Gemfile
|
61
90
|
- Gemfile.lock
|
@@ -70,7 +99,9 @@ files:
|
|
70
99
|
- lib/carb/controller.rb
|
71
100
|
- lib/carb/logger.rb
|
72
101
|
- lib/carb/version.rb
|
73
|
-
|
102
|
+
- spec/carb/cli_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/proximitybbdo/carb
|
74
105
|
licenses: []
|
75
106
|
|
76
107
|
post_install_message:
|
@@ -83,10 +114,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
114
|
requirements:
|
84
115
|
- - ">="
|
85
116
|
- !ruby/object:Gem::Version
|
86
|
-
hash:
|
117
|
+
hash: 29
|
87
118
|
segments:
|
88
|
-
-
|
89
|
-
|
119
|
+
- 1
|
120
|
+
- 9
|
121
|
+
version: "1.9"
|
90
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
123
|
none: false
|
92
124
|
requirements:
|
@@ -103,5 +135,6 @@ rubygems_version: 1.8.24
|
|
103
135
|
signing_key:
|
104
136
|
specification_version: 3
|
105
137
|
summary: Boost the start of a Proximity BBDO Octaplus framework
|
106
|
-
test_files:
|
107
|
-
|
138
|
+
test_files:
|
139
|
+
- spec/carb/cli_spec.rb
|
140
|
+
- spec/spec_helper.rb
|