carb 0.0.3 → 0.0.4
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/CHANGELOG.md +3 -0
- data/bin/carb +5 -3
- data/carb.gemspec +1 -2
- data/lib/carb.rb +0 -9
- data/lib/carb/cli.rb +28 -49
- data/lib/carb/config.rb +12 -5
- data/lib/carb/controller.rb +30 -37
- data/lib/carb/logger.rb +39 -0
- data/lib/carb/version.rb +1 -1
- metadata +9 -20
data/CHANGELOG.md
ADDED
data/bin/carb
CHANGED
data/carb.gemspec
CHANGED
data/lib/carb.rb
CHANGED
data/lib/carb/cli.rb
CHANGED
@@ -1,57 +1,36 @@
|
|
1
1
|
require 'carb'
|
2
2
|
|
3
|
+
require 'carb/config'
|
4
|
+
require 'carb/logger'
|
5
|
+
require 'carb/controller'
|
6
|
+
|
3
7
|
module Carb
|
4
|
-
|
5
|
-
class << self
|
6
|
-
SUB_COMMANDS = %w(create)
|
7
|
-
|
8
|
-
def start
|
9
|
-
puts 'TODO: implement the target param'.black.reversed
|
10
|
-
puts 'TODO: alter the default view, merge with index.html'.black.reversed
|
11
|
-
puts 'TODO: add check if target exists'.black.reversed
|
12
|
-
puts 'TODO: use FileUtils as much as possible'.black.reversed
|
13
|
-
puts 'TODO: check if repos are there'.black.reversed
|
14
|
-
global_opts = Trollop::options do
|
15
|
-
version = "Carb v#{Carb::VERSION}"
|
16
|
-
banner <<-EOS
|
17
|
-
#{version}
|
18
|
-
|
19
|
-
Carb gets your fuel flowing. Use it to setup your web dev env.
|
20
|
-
|
21
|
-
Usage:
|
22
|
-
carb create <type> <folder>
|
23
|
-
|
24
|
-
Where <type> is one of:
|
25
|
-
octaplus our fuelphp framework, this is as bare as it gets
|
26
|
-
bearded-octo our frontend framework together with moreoreless for less/css
|
27
|
-
on-fire octaplus + bearded-octo = dev on fire!
|
28
|
-
|
29
|
-
EOS
|
30
|
-
|
31
|
-
# raise Trollop::HelpNeeded if ARGV.empty? # show help screen
|
32
|
-
stop_on SUB_COMMANDS
|
33
|
-
end
|
34
|
-
|
35
|
-
cmd = ARGV.shift # get the subcommand
|
36
|
-
cmd_opts = case cmd
|
37
|
-
when "create" # parse create options
|
38
|
-
Trollop::options do
|
39
|
-
type = ARGV.shift
|
40
|
-
target = ARGV.shift || "."
|
41
|
-
|
42
|
-
if Carb::PROJECT_TYPES.include?(type)
|
43
|
-
Carb::Controller.assemble(type, target)
|
44
|
-
else
|
45
|
-
Trollop::die "wrong type passed. Use one these options: [#{Carb::PROJECT_TYPES.join(' | ')}]."
|
46
|
-
end
|
47
|
-
end
|
48
|
-
when nil
|
49
|
-
Trollop::die "No command specified! Please specify an applicable command"
|
50
|
-
else
|
51
|
-
Trollop::die "Unknown command #{cmd.inspect}"
|
52
|
-
end
|
8
|
+
module CLI
|
53
9
|
|
10
|
+
class InstallCommand < Clamp::Command
|
11
|
+
parameter "TYPE", "The type of project, being one of: octaplus, bearded-octo, on-fire" do |s|
|
12
|
+
raise ArgumentError.new('Not a correct project type.') unless Carb::Config::PROJECT_TYPES.include?(s)
|
13
|
+
s # return the actual value
|
54
14
|
end
|
15
|
+
|
16
|
+
parameter "[TARGET]", "The target folder", :default => "."
|
17
|
+
|
18
|
+
def execute
|
19
|
+
Carb::Controller.assemble(type, target)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class MainCommand < Clamp::Command
|
24
|
+
Logger::log('TODO: alter the default view, merge with index.html', Logger::WARNING)
|
25
|
+
Logger::log('TODO: add check if target exists', Logger::WARNING)
|
26
|
+
Logger::log('TODO: use FileUtils as much as possible', Logger::WARNING)
|
27
|
+
Logger::log('TODO: check if repos are there', Logger::WARNING)
|
28
|
+
|
29
|
+
subcommand "install", "Install a new project", InstallCommand
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.run(*a)
|
33
|
+
MainCommand.run(*a)
|
55
34
|
end
|
56
35
|
end
|
57
36
|
end
|
data/lib/carb/config.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
module Carb
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Config
|
3
|
+
TYPE_OCTAPLUS = 'octaplus'
|
4
|
+
TYPE_BEARDED_OCTO = 'bearded-octo'
|
5
|
+
TYPE_ON_FIRE = 'on-fire'
|
5
6
|
|
6
|
-
|
7
|
+
DIR_OCTAPLUS = 'octaplus'
|
8
|
+
DIR_BEARDED = 'bearded'
|
9
|
+
DIR_MOREORLESS = 'moreorless'
|
10
|
+
DIR_COOKPOT = 'cookpot'
|
7
11
|
|
8
|
-
|
12
|
+
PROJECT_TYPES = [TYPE_OCTAPLUS, TYPE_BEARDED_OCTO, TYPE_ON_FIRE]
|
13
|
+
|
14
|
+
TMP_FOLDER = "/tmp/proxdev"
|
15
|
+
end
|
9
16
|
end
|
data/lib/carb/controller.rb
CHANGED
@@ -12,17 +12,18 @@ module Carb
|
|
12
12
|
##################################
|
13
13
|
|
14
14
|
def assemble(type, target)
|
15
|
+
|
15
16
|
@type = type
|
16
17
|
@target = target || "."
|
17
18
|
|
18
19
|
set_up()
|
19
20
|
|
20
21
|
case @type
|
21
|
-
when
|
22
|
+
when Config::TYPE_OCTAPLUS
|
22
23
|
cook_octaplus()
|
23
|
-
when
|
24
|
+
when Config::TYPE_BEARDED_OCTO
|
24
25
|
cook_bearded_octo()
|
25
|
-
when
|
26
|
+
when Config::TYPE_ON_FIRE
|
26
27
|
cook_on_fire()
|
27
28
|
end
|
28
29
|
|
@@ -30,40 +31,28 @@ module Carb
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def set_up
|
33
|
-
|
34
|
+
Logger::log("⚡ Preparing your package, hold on ⚡", Logger::INFO)
|
34
35
|
|
35
36
|
# save pwd
|
36
37
|
@pwd = Dir.pwd
|
37
38
|
|
38
|
-
# remove previous
|
39
|
-
%x[rm -rf #{Carb::TMP_FOLDER}]
|
40
|
-
|
41
|
-
# FileUtils.rm_rf = "#{TMP_FOLDER}"
|
42
|
-
|
43
39
|
# create tmp folder
|
44
|
-
|
45
|
-
|
46
|
-
# create some collecting folders
|
47
|
-
#
|
48
|
-
# TODO these subfolder names should be the same as the PROJECT_TYPES
|
49
|
-
# used by the CLI app. Maybe create a Config class with static members ?
|
50
|
-
# Or how can you handle config files in ruby?
|
51
|
-
#
|
52
|
-
# %x[mkdir -p #{TMP_FOLDER}/octaplus #{TMP_FOLDER}/bearded #{TMP_FOLDER}/boilerplate]
|
40
|
+
FileUtils.mkdir_p "#{Config::TMP_FOLDER}"
|
53
41
|
|
54
42
|
# and move to the root of them
|
55
|
-
Dir.chdir "#{
|
43
|
+
Dir.chdir "#{Config::TMP_FOLDER}"
|
56
44
|
end
|
57
45
|
|
58
46
|
def tear_down
|
59
47
|
# copy the bundle to the current working directory
|
60
|
-
|
48
|
+
FileUtils.mkdir_p "#{@pwd}/#{@target}"
|
49
|
+
FileUtils.cp_r "#{Config::DIR_COOKPOT}/.", "#{@pwd}/#{@target}"
|
50
|
+
|
61
51
|
puts ""
|
52
|
+
Logger::log("⚡⚡⚡ Et voila! All set in the ./#{@target} folder ⚡⚡⚡ ", Logger::SUCCESS)
|
62
53
|
|
63
|
-
%x[mkdir -p #{@pwd}/#{@target} | cp -R boilerplate/ #{@pwd}/#{@target}]
|
64
|
-
|
65
54
|
# clean up
|
66
|
-
#
|
55
|
+
# FileUtils.remove_dir "#{Config::TMP_FOLDER}", :force => true
|
67
56
|
end
|
68
57
|
|
69
58
|
##################################
|
@@ -71,20 +60,23 @@ module Carb
|
|
71
60
|
##################################
|
72
61
|
|
73
62
|
def get_octaplus
|
74
|
-
|
75
|
-
|
63
|
+
Logger::log(" ⚡ A bit of Octaplus goodness", Logger::INFO)
|
64
|
+
|
65
|
+
FileUtils.mkdir_p "#{Config::DIR_OCTAPLUS}"
|
76
66
|
%x[curl -L -s https://github.com/proximitybbdo/octaplus/tarball/master | tar xz --strip 1 -C octaplus]
|
77
67
|
end
|
78
68
|
|
79
69
|
def get_bearded_octo
|
80
|
-
|
81
|
-
|
70
|
+
Logger::log(" ⚡ Some bearded-octo seasoning", Logger::INFO)
|
71
|
+
|
72
|
+
FileUtils.mkdir_p "#{Config::DIR_BEARDED}"
|
82
73
|
%x[curl -L -s https://github.com/proximitybbdo/bearded-octo/tarball/master | tar xz --strip 1 -C bearded]
|
83
74
|
end
|
84
75
|
|
85
76
|
def get_moreorless
|
86
|
-
|
87
|
-
|
77
|
+
Logger::log(" ⚡ A dash of moreorless", Logger::INFO)
|
78
|
+
|
79
|
+
FileUtils.mkdir_p "#{Config::DIR_MOREORLESS}"
|
88
80
|
%x[curl -L -s https://github.com/rob-bar/moreorless/tarball/master | tar xz --strip 1 -C moreorless]
|
89
81
|
end
|
90
82
|
|
@@ -95,26 +87,27 @@ module Carb
|
|
95
87
|
def cook_octaplus
|
96
88
|
get_octaplus()
|
97
89
|
|
98
|
-
|
90
|
+
FileUtils.cp_r "#{Config::DIR_OCTAPLUS}", "#{Config::DIR_COOKPOT}"
|
99
91
|
end
|
100
92
|
|
101
93
|
def cook_bearded_octo
|
102
94
|
get_bearded_octo()
|
103
95
|
get_moreorless()
|
104
96
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
97
|
+
FileUtils.remove_dir "#{Config::DIR_OCTAPLUS}/assets"
|
98
|
+
FileUtils.mkdir_p "#{Config::DIR_COOKPOT}/assets"
|
99
|
+
|
100
|
+
FileUtils.cp_r "#{Config::DIR_BEARDED}/assets/.", "#{Config::DIR_COOKPOT}/assets"
|
101
|
+
FileUtils.remove_dir "#{Config::DIR_MOREORLESS}/tests"
|
102
|
+
FileUtils.cp_r "#{Config::DIR_MOREORLESS}/.", "#{Config::DIR_COOKPOT}/assets/css"
|
110
103
|
end
|
111
104
|
|
112
105
|
def cook_on_fire
|
113
106
|
get_octaplus()
|
114
107
|
cook_bearded_octo()
|
115
108
|
|
116
|
-
|
117
|
-
|
109
|
+
FileUtils.cp_r "#{Config::DIR_OCTAPLUS}/.", "#{Config::DIR_COOKPOT}"
|
110
|
+
FileUtils.cp_r "#{Config::DIR_BEARDED}/index.html", "#{Config::DIR_COOKPOT}/fuel/app/views/welcome"
|
118
111
|
|
119
112
|
# actions on the views
|
120
113
|
end
|
data/lib/carb/logger.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Carb
|
2
|
+
class Logger
|
3
|
+
|
4
|
+
SUCCESS = 'success'
|
5
|
+
ERROR = 'error'
|
6
|
+
WARNING = 'warning'
|
7
|
+
INFO = 'info'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def log(text, type)
|
12
|
+
case type
|
13
|
+
when ERROR
|
14
|
+
output = red(text)
|
15
|
+
when INFO
|
16
|
+
output = blue(text)
|
17
|
+
when SUCCESS
|
18
|
+
output = green(text)
|
19
|
+
when WARNING
|
20
|
+
output = grey(text)
|
21
|
+
else
|
22
|
+
output = text
|
23
|
+
end
|
24
|
+
|
25
|
+
puts output
|
26
|
+
end
|
27
|
+
|
28
|
+
def colorize(text, fg)
|
29
|
+
ret = "\e[#{fg}m#{text}\e[0m"
|
30
|
+
end
|
31
|
+
|
32
|
+
def red(text); colorize(text, 31); end
|
33
|
+
def green(text); colorize(text, 32); end
|
34
|
+
def blue(text); colorize(text, 34); end
|
35
|
+
def grey(text); colorize(text, 30); end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/carb/version.rb
CHANGED
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeroen Bourgois
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-10-
|
18
|
+
date: 2012-10-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: clamp
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: fileutils
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
@@ -45,20 +45,6 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: fileutils
|
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: :runtime
|
61
|
-
version_requirements: *id003
|
62
48
|
description: Boost the start of a Proximity BBDO Octaplus framework
|
63
49
|
email:
|
64
50
|
- jeroenbourgois@gmail.com
|
@@ -70,7 +56,9 @@ extra_rdoc_files: []
|
|
70
56
|
|
71
57
|
files:
|
72
58
|
- .gitignore
|
59
|
+
- CHANGELOG.md
|
73
60
|
- Gemfile
|
61
|
+
- Gemfile.lock
|
74
62
|
- LICENSE
|
75
63
|
- README.md
|
76
64
|
- Rakefile
|
@@ -80,6 +68,7 @@ files:
|
|
80
68
|
- lib/carb/cli.rb
|
81
69
|
- lib/carb/config.rb
|
82
70
|
- lib/carb/controller.rb
|
71
|
+
- lib/carb/logger.rb
|
83
72
|
- lib/carb/version.rb
|
84
73
|
homepage: ""
|
85
74
|
licenses: []
|