marv 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.3.1 ==
2
+ - Remove command servers
3
+ - Add option --list to server command
4
+ - Remove option --create from server command
5
+ - Add option --start to server command
6
+ - Remove marv link options except --folder
7
+ - Link projects by default to global folders
8
+
1
9
  == 0.3.0 ==
2
10
  - Marv server (Wordpress local install)
3
11
  - Global plugins & themes for Marv servers
data/Gemfile CHANGED
@@ -15,6 +15,7 @@ gem 'uglifier', '>= 2.5.0'
15
15
 
16
16
  # Add dependencies to develop your gem here.
17
17
  # Include everything needed to run rake, tests, features, etc.
18
+
18
19
  group :development do
19
20
  gem 'rake'
20
21
  gem 'rspec'
data/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  ## What is Marv?
2
2
 
3
- Marv is a free command-line toolkit for bootstrapping and developing WordPress themes in a tidy environment using front-end languages like Sass, LESS, and CoffeeScript.
3
+ Marv is a free command-line toolkit for bootstrapping and developing WordPress themes and plugins in a tidy environment using front-end languages like Sass, LESS, and CoffeeScript.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/marv.png)](http://badge.fury.io/rb/marv)
6
6
 
7
7
 
8
8
  ## How does it work?
9
9
 
10
- Marv creates a neatly organized source folder with clean and simple scaffolding (base template files, SCSS files). The source folder is automatically compiled to your local WordPress install(s) as you save changes and work on your theme. When you are ready to distribute your theme Marv will build it to a folder of your choice or bundle the theme up into an easy to install zip package.
10
+ Marv creates a neatly organized source folder with clean and simple scaffolding (base template files, SCSS files). The source folder is automatically compiled to your Marv development server(s) or local WordPress install(s) as you save changes and work on your project. When you are ready to distribute your project Marv will build it to a folder of your choice or bundle the project up into an easy to install zip package.
11
11
 
12
12
 
13
13
  ## Why use Marv?
14
14
 
15
- Marv accelerates development by giving you access to higher-level languages like Sass, LESS, and CoffeeScript. These languages are much quicker and cleaner to code, but still compile to normal CSS and JavaScript. Marv also makes it easy to quickly bootstrap into and a more modular development environment, while still compiling "by the book" WordPress theme code.
15
+ Marv accelerates development by giving you access to higher-level languages like Sass, LESS, and CoffeeScript. These languages are much quicker and cleaner to code, but still compile to normal CSS and JavaScript. Marv also makes it easy to quickly bootstrap into and a more modular development environment, while still compiling "by the book" WordPress code.
16
16
 
17
17
 
18
18
  ## Basic setup
@@ -21,28 +21,40 @@ Install Marv (requires [Ruby](http://www.ruby-lang.org/) and [RubyGems](http://r
21
21
 
22
22
  $ gem install marv
23
23
 
24
- Create your new theme project:
24
+ Create your new project:
25
25
 
26
- $ marv create themename
26
+ $ marv create project-name
27
27
 
28
- Link to your WordPress theme folder:
28
+ Create a Marv development server:
29
29
 
30
- $ marv link /wordpress/wp-content/themes/my-theme
30
+ $ marv server server-name
31
+
32
+ Link to your Marv server:
33
+
34
+ $ cd project-name
35
+ $ marv link server-name --folder themes
36
+ $ marv link server-name --folder plugins
37
+
38
+ Also you can link to a WordPress installation:
39
+
40
+ $ cd project-name
41
+ $ marv link /var/www/wordpress --folder themes
42
+ $ marv link /var/www/wordpress --folder plugins
31
43
 
32
44
  Watch for changes and start developing!
33
45
 
34
- $ cd themename
46
+ $ cd project-name
35
47
  $ marv watch
36
48
 
37
49
  Press Ctrl + Z to exit watch mode
38
50
 
39
- Build your theme into the build_here directory:
51
+ Build your project into the build_here directory:
40
52
 
41
53
  $ marv build build_here
42
54
 
43
- Package your theme as themename.zip:
55
+ Package your project as package-name.zip:
44
56
 
45
- $ marv package themename
57
+ $ marv package package-name
46
58
 
47
59
 
48
60
  ## Help
@@ -50,6 +62,7 @@ Package your theme as themename.zip:
50
62
  Get a little help with the Marv commands:
51
63
 
52
64
  $ marv help
65
+ $ marv help command
53
66
 
54
67
 
55
68
  See the [user's manual](https://github.com/hardpixel/marv/wiki) for more information.
data/Rakefile CHANGED
@@ -20,8 +20,8 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.executables = ["marv"]
21
21
  gem.homepage = "http://hardpixel.github.io/marv"
22
22
  gem.license = "MIT"
23
- gem.summary = %Q{A tool for developing wordpress themes}
24
- gem.description = %Q{A toolkit for bootstrapping and developing WordPress themes using Sass, LESS, and CoffeeScript.}
23
+ gem.summary = %Q{A command-line tool for developing wordpress themes and plugins}
24
+ gem.description = %Q{A toolkit for bootstrapping and developing WordPress themes and plugins using Sass, LESS, and CoffeeScript.}
25
25
  gem.email = "info@hardpixel.eu"
26
26
  gem.authors = ["Jonian Guveli", "Olibia Tsati"]
27
27
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -8,31 +8,25 @@ module Guard
8
8
  super
9
9
  end
10
10
 
11
+ # Runs on marv watch
11
12
  def start
12
- UI.info "Building all assets"
13
- build_assets
13
+ build_assets("Building all assets", true)
14
14
  end
15
15
 
16
- # Called on Ctrl-\ signal
17
- # This method should be principally used for long action like running all specs/tests/...
16
+ # Runs on all command in guard console
18
17
  def run_all
19
- UI.info "Rebuilding all assets"
20
- clean_build_assets
18
+ build_assets("Rebuilding all assets", true)
21
19
  end
22
20
 
23
21
  # Called on file(s) modifications
24
22
  def run_on_change(paths)
25
- UI.info "Assets have changed, rebuilding..."
26
- clean_build_assets
23
+ build_assets("Assets have changed, rebuilding...", nil)
27
24
  end
28
25
 
29
- def build_assets
30
- ::Marv::Guard.builder.build_assets
31
- end
32
-
33
- def clean_build_assets
34
- ::Marv::Guard.builder.clean_images
35
- ::Marv::Guard.builder.build_assets
26
+ # Build assets
27
+ def build_assets(message, clean)
28
+ UI.info message
29
+ ::Marv::Guard.builder.build_assets(clean)
36
30
  end
37
31
 
38
32
  end
@@ -8,15 +8,13 @@ module Guard
8
8
  super
9
9
  end
10
10
 
11
- # Called on Ctrl-Z signal
12
- # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
11
+ # This method should be mainly used for "reload"
13
12
  def reload
14
13
  UI.info "Reloading project config"
15
14
  ::Marv::Guard.project.load_config
16
15
  end
17
16
 
18
- # Called on Ctrl-\ signal
19
- # This method should be principally used for long action like running all specs/tests/...
17
+ # Runs on all command in guard console
20
18
  def run_all
21
19
  UI.info "Reloading project config"
22
20
  ::Marv::Guard.project.load_config
@@ -28,6 +26,7 @@ module Guard
28
26
  UI.info "Project config changed, reloading"
29
27
  ::Marv::Guard.project.load_config
30
28
  ::Marv::Guard.builder = ::Marv::Builder.new(::Marv::Guard.project)
29
+
31
30
  # Rebuild everything if the config changes
32
31
  ::Marv::Guard.builder.build
33
32
  end
@@ -8,29 +8,25 @@ module Guard
8
8
  super
9
9
  end
10
10
 
11
+ # Runs on marv watch
11
12
  def start
12
- UI.info "Copying folders over"
13
- copy_folders
13
+ copy_folders("Copying folders over", true)
14
14
  end
15
15
 
16
+ # Runs on all command in guard console
16
17
  def run_all
17
- UI.info "Rebuilding all folders"
18
- clean_copy_folders
18
+ copy_folders("Rebuilding all folders", true)
19
19
  end
20
20
 
21
21
  # Called on file(s) modifications
22
22
  def run_on_change(paths)
23
- UI.info "Folders have changed, copying over"
24
- clean_copy_folders
23
+ copy_folders("Folders have changed, copying over", nil)
25
24
  end
26
25
 
27
- def copy_folders
28
- ::Marv::Guard.builder.copy_folders
29
- end
30
-
31
- def clean_copy_folders
32
- ::Marv::Guard.builder.clean_folders
33
- ::Marv::Guard.builder.copy_folders
26
+ # Copy folders
27
+ def copy_folders(message, clean)
28
+ UI.info message
29
+ ::Marv::Guard.builder.copy_folders(clean)
34
30
  end
35
31
 
36
32
  end
@@ -8,32 +8,26 @@ module Guard
8
8
  super
9
9
  end
10
10
 
11
+ # Runs on marv watch
11
12
  def start
12
- UI.info "Copying functions over"
13
- copy_functions
13
+ copy_functions("Copying functions over", true)
14
14
  end
15
15
 
16
+ # Runs on all command in guard console
16
17
  def run_all
17
- UI.info "Rebuilding all functions"
18
- clean_copy_functions
18
+ copy_functions("Rebuilding all functions", true)
19
19
  end
20
20
 
21
21
  # Called on file(s) modifications
22
22
  def run_on_change(paths)
23
- UI.info "Functions have changed, copying over"
24
- clean_copy_functions
23
+ copy_functions("Functions have changed, copying over", nil)
25
24
  end
26
25
 
27
- def copy_functions
28
- ::Marv::Guard.builder.copy_functions
29
- ::Marv::Guard.builder.copy_includes
30
- end
31
-
32
- def clean_copy_functions
33
- ::Marv::Guard.builder.clean_functions
34
- ::Marv::Guard.builder.copy_functions
35
- ::Marv::Guard.builder.clean_includes
36
- ::Marv::Guard.builder.copy_includes
26
+ # Copy and clean functions and includes folder
27
+ def copy_functions(message, clean)
28
+ UI.info message
29
+ ::Marv::Guard.builder.copy_functions(clean)
30
+ ::Marv::Guard.builder.copy_includes(clean)
37
31
  end
38
32
 
39
33
  end
@@ -8,29 +8,25 @@ module Guard
8
8
  super
9
9
  end
10
10
 
11
+ # Runs on marv watch
11
12
  def start
12
- UI.info "Copying templates over"
13
- copy_templates
13
+ copy_templates("Copying templates over", true)
14
14
  end
15
15
 
16
+ # Runs on all command in guard console
16
17
  def run_all
17
- UI.info "Rebuilding all templates"
18
- clean_copy_templates
18
+ copy_templates("Rebuilding all templates", true)
19
19
  end
20
20
 
21
21
  # Called on file(s) modifications
22
22
  def run_on_change(paths)
23
- UI.info "Templates have changed, copying over"
24
- clean_copy_templates
23
+ copy_templates("Templates have changed, copying over", nil)
25
24
  end
26
25
 
27
- def copy_templates
28
- ::Marv::Guard.builder.copy_templates
29
- end
30
-
31
- def clean_copy_templates
32
- ::Marv::Guard.builder.clean_templates
33
- ::Marv::Guard.builder.copy_templates
26
+ # Copy templates
27
+ def copy_templates(message, clean)
28
+ UI.info message
29
+ ::Marv::Guard.builder.copy_templates(clean)
34
30
  end
35
31
 
36
32
  end
data/lib/marv/builder.rb CHANGED
@@ -67,7 +67,9 @@ module Marv
67
67
  # Empty out the build directory
68
68
  def clean_build_directory
69
69
  # create build path if it does not exist
70
- FileUtils.mkdir_p(@project.build_path) unless File.exists?(@project.build_path)
70
+ unless File.exists?(@project.build_path)
71
+ FileUtils.mkdir_p(@project.build_path)
72
+ end
71
73
  # Empty the build path
72
74
  FileUtils.rm_rf Dir.glob(File.join(@project.build_path, '*'))
73
75
  end
@@ -79,7 +81,11 @@ module Marv
79
81
  end
80
82
  end
81
83
 
82
- def copy_templates
84
+ def copy_templates(clean=nil)
85
+ unless clean.nil?
86
+ clean_templates
87
+ end
88
+
83
89
  template_paths.each do |template_path|
84
90
  # Skip directories
85
91
  next if File.directory?(template_path)
@@ -98,14 +104,26 @@ module Marv
98
104
 
99
105
  def clean_functions
100
106
  #remove functions php
101
- FileUtils.rm File.join(@project.build_path, 'functions.php') if File.exists?(File.join(@project.build_path, 'functions.php'))
107
+ if File.exists?(File.join(@project.build_path, 'functions.php'))
108
+ FileUtils.rm File.join(@project.build_path, 'functions.php')
109
+ end
102
110
  # Remove plugin file
103
- FileUtils.rm File.join(@project.build_path, @project.project_php_file) if File.exists?(@project.project_php_file)
111
+ if File.exists?(@project.project_php_file)
112
+ FileUtils.rm File.join(@project.build_path, @project.project_php_file)
113
+ end
104
114
  # Remove functions folder
105
- FileUtils.rm_rf File.join(@project.build_path, 'functions') if File.directory?(File.join(@project.build_path, 'functions'))
115
+ if File.directory?(File.join(@project.build_path, 'functions'))
116
+ FileUtils.rm_rf File.join(@project.build_path, 'functions')
117
+ end
106
118
  end
107
119
 
108
- def copy_functions
120
+ def copy_functions(clean=nil)
121
+ # Clean functions
122
+ unless clean.nil?
123
+ clean_functions
124
+ end
125
+
126
+ # Copy functions
109
127
  functions_erb_path = File.join(@functions_path, 'functions.php.erb')
110
128
  functions_php_path = File.join(@functions_path, 'functions.php')
111
129
  plugin_php_path = File.join(@functions_path, @project.project_php_file)
@@ -127,10 +145,14 @@ module Marv
127
145
 
128
146
  unless functions_paths.empty?
129
147
  # Create the functions folder in the build directory
130
- FileUtils.mkdir_p(File.join(@project.build_path, 'functions'))
148
+ unless File.directory?(File.join(@project.build_path, 'functions'))
149
+ FileUtils.mkdir_p(File.join(@project.build_path, 'functions'))
150
+ end
131
151
 
132
152
  # Iterate over all files in source/functions, skipping the actual functions.php file
133
- paths = Dir.glob(File.join(@functions_path, '**', '*')).reject {|filename| [functions_erb_path, functions_php_path, plugin_php_path].include?(filename) }
153
+ paths = Dir.glob(File.join(@functions_path, '**', '*')).reject do |filename|
154
+ [functions_erb_path, functions_php_path, plugin_php_path].include?(filename)
155
+ end
134
156
 
135
157
  copy_paths_with_erb(paths, @functions_path, File.join(@project.build_path, 'functions'))
136
158
  end
@@ -140,10 +162,18 @@ module Marv
140
162
  FileUtils.rm_rf File.join(@project.build_path, 'includes')
141
163
  end
142
164
 
143
- def copy_includes
165
+ def copy_includes(clean=nil)
166
+ # Clean Includes
167
+ unless clean.nil?
168
+ clean_includes
169
+ end
170
+
171
+ # Copy includes
144
172
  unless Dir.glob(File.join(@includes_path, '*')).empty?
145
173
  # Create the includes folder in the build directory
146
- FileUtils.mkdir(File.join(@project.build_path, 'includes'))
174
+ unless File.directory?(File.join(@project.build_path, 'includes'))
175
+ FileUtils.mkdir(File.join(@project.build_path, 'includes'))
176
+ end
147
177
 
148
178
  # Iterate over all files in source/includes, so we can exclude if necessary
149
179
  paths = Dir.glob(File.join(@includes_path, '**', '*'))
@@ -151,23 +181,25 @@ module Marv
151
181
  end
152
182
  end
153
183
 
154
- def clean_folders
155
- Dir.glob(File.join(@project.source_path, '*')).each do |folder|
156
- unless [@assets_path, @templates_path, @functions_path, @includes_path].include?(folder)
157
- if File.directory?(folder)
158
- relative_path = folder.gsub(@project.source_path, '')
159
- destination = File.join(@project.build_path, relative_path)
184
+ def clean_folders(folder)
185
+ # Clean folder
186
+ relative_path = folder.gsub(@project.source_path, '')
187
+ destination = File.join(@project.build_path, relative_path)
160
188
 
161
- FileUtils.rm_rf destination
162
- end
163
- end
164
- end
189
+ FileUtils.rm_rf destination
165
190
  end
166
191
 
167
- def copy_folders
168
- Dir.glob(File.join(@project.source_path, '*')).each do |folder|
169
- unless [@assets_path, @templates_path, @functions_path, @includes_path].include?(folder)
170
- if File.directory?(folder)
192
+ def copy_folders(clean=nil)
193
+ folders = Dir.glob(File.join(@project.source_path, '*'))
194
+
195
+ folders.each do |folder|
196
+ if File.directory?(folder)
197
+ unless [@assets_path, @templates_path, @functions_path, @includes_path].include?(folder)
198
+ # Clean folders
199
+ unless clean.nil?
200
+ clean_folders(folder)
201
+ end
202
+ # Copy folders
171
203
  paths = Dir.glob(File.join(folder, '**', '*'))
172
204
  copy_paths_with_erb(paths, @project.source_path, @project.build_path)
173
205
  end
@@ -179,7 +211,13 @@ module Marv
179
211
  FileUtils.rm_rf File.join(@project.build_path, 'images')
180
212
  end
181
213
 
182
- def build_assets
214
+ def build_assets(clean=nil)
215
+ # Clean images
216
+ unless clean.nil?
217
+ clean_images
218
+ end
219
+
220
+ # Build assets
183
221
  default_assets = [['style.css'], ['admin.css'], ['javascripts', 'theme.js'], ['javascripts', 'admin.js']]
184
222
  additional_assets = @project.config[:additional_assets]
185
223
 
@@ -215,7 +253,9 @@ module Marv
215
253
  end
216
254
 
217
255
  # Copy the images directory over
218
- FileUtils.cp_r(File.join(@assets_path, 'images'), @project.build_path) if File.exists?(File.join(@assets_path, 'images'))
256
+ if File.directory?(File.join(@assets_path, 'images'))
257
+ FileUtils.cp_r(File.join(@assets_path, 'images'), @project.build_path)
258
+ end
219
259
 
220
260
  # Check for screenshot and move it into main build directory
221
261
  Dir.glob(File.join(@project.build_path, 'images', '*')).each do |filename|
data/lib/marv/cli.rb CHANGED
@@ -25,41 +25,23 @@ module Marv
25
25
  project = Marv::Project.create(dir, theme, self, options[:layout], options[:local])
26
26
  end
27
27
 
28
- desc "link SERVER", "Create a symbolic link to the compilation directory"
29
- long_desc "This command will symlink the compiled version of the project to the specified server or WordPress install path"
30
- method_option :folder, :type => :string, :aliases => "-f" , :enum => %w{themes plugins}, :required => true, :desc => "Link Marv project in themes or plugins folfer"
31
- method_option :global, :type => :boolean, :aliases => "-g" , :force => false, :desc => "Link Marv project in global folder"
32
- method_option :path, :type => :string, :aliases => "-p" , :desc => "Create a symbolic link to a WordPress folder"
33
- def link(server=nil)
28
+ desc "link SERVER or DIRECTORY", "Create a symbolic link to the compilation directory"
29
+ long_desc "This command will symlink the compiled version of the project to the specified server or WordPress install path."+
30
+ "If you don't provide a directory or a server name, the symlink will be created in Marv global themes or plugins folder."
31
+ method_option :folder, :type => :string, :enum => %w{themes plugins}, :required => true, :desc => "Link Marv project in themes or plugins folfer"
32
+ def link(dir='global')
34
33
  project = Marv::Project.new('.', self)
35
- project_folder = project.project_id.gsub('_', '-')
36
-
37
- FileUtils.mkdir_p project.build_path unless File.directory?(project.build_path)
38
-
39
- unless server.nil?
40
- server_path = File.join(ENV['HOME'], '.marv', 'servers', server, 'wp-content', options[:folder])
41
-
42
- unless options[:global]
43
- do_link(project, File.join(server_path, project_folder))
44
- end
45
- end
46
-
47
- if options[:global]
48
- global_folder = File.join(ENV['HOME'], '.marv', options[:folder])
49
- FileUtils.mkdir_p global_folder unless File.directory?(global_folder)
50
-
51
- do_link(project, File.join(global_folder, project_folder))
52
34
 
53
- servers = Dir.glob(File.join(ENV['HOME'], '.marv', 'servers' , '*'))
54
-
55
- servers.each do |server|
56
- shell.mute { do_link(project, File.join(server, 'wp-content', options[:folder], project_folder)) }
57
- end
35
+ unless File.directory?(project.build_path)
36
+ FileUtils.mkdir_p project.build_path
58
37
  end
59
38
 
60
- if options[:path]
61
- wp_path = File.join(options[:path], 'wp-content', options[:folder])
62
- do_link(project, File.join(wp_path, project_folder))
39
+ if dir == 'global'
40
+ link_project_globaly(options, project)
41
+ else
42
+ wp_path = File.join(dir, 'wp-content', options[:folder])
43
+ server_path = File.join(ENV['HOME'], '.marv', 'servers', dir, 'wp-content', options[:folder])
44
+ link_project(wp_path, server_path, project)
63
45
  end
64
46
  end
65
47
 
@@ -102,98 +84,105 @@ module Marv
102
84
  end
103
85
 
104
86
  desc "server SERVER", "Start a Marv server by name"
105
- method_option :create, :type => :boolean, :aliases => "-c" , :force => false, :desc => "Create a new Marv server"
106
- method_option :stop, :type => :boolean, :aliases => "-s" , :force => false, :desc => "Stop a running Marv server"
107
- method_option :restart, :type => :boolean, :aliases => "-r" , :force => false, :desc => "Restart a Marv server"
87
+ method_option :list, :type => :boolean, :force => false, :desc => "List all available Marv servers"
88
+ method_option :start, :type => :boolean, :force => false, :desc => "Create a new Marv server"
89
+ method_option :stop, :type => :boolean, :force => false, :desc => "Stop a running Marv server"
90
+ method_option :restart, :type => :boolean, :force => false, :desc => "Restart a Marv server"
108
91
  # method_option :backup, :type => :boolean, :force => false, :desc => "Backup a Marv server"
109
92
  # method_option :restore, :type => :boolean, :force => false, :desc => "Restore a Marv server"
110
93
  method_option :remove, :type => :boolean, :force => false, :desc => "Remove a Marv server"
111
- def server(name)
112
- config = {}
94
+ def server(name=nil)
95
+ if options.empty?
96
+ server = Marv::Server.new(name, self, server_config)
97
+ server.create_server
98
+ end
113
99
 
114
- if options[:create]
115
- say "This will create a new Marv server with WordPress installed:", :green
116
- config[:user] = ask("Mysql username:", nil, {:default => "root"})
117
- config[:password] = ask("Mysql user password:", nil, {:default => "required"})
118
- config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
119
- config[:port] = ask("Mysql port:", nil, {:default => "3306"})
120
- config[:version] = ask("WordPress version:", nil, {:default => "latest"})
100
+ if options[:remove]
101
+ server = Marv::Server.new(name, self, server_config(true, name))
102
+ server.remove_server
103
+ end
121
104
 
122
- server = Marv::Server.new(name, self, config)
123
- server.create_server
124
- else
105
+ if options[:start] or options[:stop] or options[:restart]
125
106
  server = Marv::Server.new(name, self, nil)
107
+ control_server(options, name, server)
108
+ end
126
109
 
127
- if options.empty?
128
- server.start_server
129
- end
110
+ if options[:list]
111
+ list_servers
112
+ end
113
+ end
130
114
 
131
- if options[:stop]
132
- server.stop_server
133
- end
115
+ protected
134
116
 
135
- if options[:restart]
136
- server.restart_server
137
- end
117
+ def link_project_globaly(options, project)
118
+ project_folder = project.project_id.gsub('_', '-')
119
+ global_folder = File.join(ENV['HOME'], '.marv', options[:folder])
138
120
 
139
- if options[:remove]
140
- say "This will remove the specified Marv server:", :green
141
- config[:user] = ask("Mysql username:", nil, {:default => "root"})
142
- config[:password] = ask("Mysql user password:", nil, {:default => "required"})
143
- config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
144
- config[:port] = ask("Mysql port:", nil, {:default => "3306"})
145
- config[:version] = "latest"
121
+ unless File.directory?(global_folder)
122
+ FileUtils.mkdir_p global_folder
123
+ end
146
124
 
147
- server = Marv::Server.new(name, self, config)
148
- server.remove_server
149
- end
125
+ do_link(project, File.join(global_folder, project_folder))
126
+
127
+ servers = Dir.glob(File.join(ENV['HOME'], '.marv', 'servers' , '*'))
128
+
129
+ servers.each do |server|
130
+ shell.mute { do_link(project, File.join(server, 'wp-content', options[:folder], project_folder)) }
150
131
  end
151
- exit
152
132
  end
153
133
 
154
- desc "servers OPTION", "List all available Marv servers"
155
- method_option :remove, :type => :boolean, :force => false, :desc => "Remove all Marv servers"
156
- # method_option :backup, :type => :boolean, :force => false, :desc => "Backup existing Marv servers"
157
- # method_option :restore, :type => :boolean, :force => false, :desc => "Restore Marv servers from backup file"
158
- def servers
159
- if options.empty?
160
- list_all_servers
161
- end
134
+ def server_config(remove=nil, name=nil)
135
+ config = {}
162
136
 
163
- if options[:remove]
164
- config = {}
137
+ if remove.nil?
138
+ say "This will create a new Marv server with WordPress installed:", :green
139
+ else
140
+ say "This will remove #{name} server:", :yellow
141
+ end
165
142
 
166
- say "This will remove all available Marv servers:", :green
167
- config[:user] = ask("Mysql username:", nil, {:default => "root"})
168
- config[:password] = ask("Mysql user password:", nil, {:default => "required"})
169
- config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
170
- config[:port] = ask("Mysql port:", nil, {:default => "3306"})
171
- config[:version] = "latest"
143
+ config[:user] = ask("Mysql username:", nil, {:default => "root"})
144
+ config[:password] = ask("Mysql user password:", nil, {:default => "required"})
145
+ config[:host] = ask("Mysql host:", nil, {:default => "localhost"})
146
+ config[:port] = ask("Mysql port:", nil, {:default => "3306"})
172
147
 
173
- remove_all_servers(config)
148
+ if remove.nil?
149
+ config[:version] = ask("WordPress version:", nil, {:default => "latest"})
174
150
  end
175
- exit
151
+
152
+ config
176
153
  end
177
154
 
178
- protected
155
+ def control_server(options, name, server)
156
+ if options[:start]
157
+ server.start_server
158
+ end
179
159
 
180
- def list_all_servers
181
- servers_root = File.join(ENV['HOME'], '.marv', 'servers')
182
- servers = Dir.glob(File.join(servers_root, '*'))
160
+ if options[:stop]
161
+ server.stop_server
162
+ end
183
163
 
184
- servers.each do |server|
185
- say "Available marv servers:", :yellow
186
- say '- ' + File.basename(server), :green
164
+ if options[:restart]
165
+ server.restart_server
187
166
  end
188
167
  end
189
168
 
190
- def remove_all_servers(config)
169
+ def list_servers
191
170
  servers_root = File.join(ENV['HOME'], '.marv', 'servers')
192
171
  servers = Dir.glob(File.join(servers_root, '*'))
193
172
 
173
+ say "Available marv servers:"
194
174
  servers.each do |server|
195
- server = Marv::Server.new(File.basename(server), self, config)
196
- server.remove_server
175
+ say '- ' + File.basename(server), :cyan
176
+ end
177
+ end
178
+
179
+ def link_project( wp_path, server_path, project)
180
+ project_folder = project.project_id.gsub('_', '-')
181
+
182
+ if File.directory?(wp_path)
183
+ do_link(project, File.join(wp_path, project_folder))
184
+ else
185
+ do_link(project, File.join(server_path, project_folder))
197
186
  end
198
187
  end
199
188
 
@@ -39,56 +39,36 @@ module Marv
39
39
  self
40
40
  end
41
41
 
42
- def copy_stylesheets
43
- source = File.expand_path(File.join(self.layout_path, 'stylesheets'))
44
- target = File.expand_path(File.join(@project.assets_path, 'stylesheets'))
42
+ def copy_assets
43
+ ['stylesheets', 'javascripts', 'images'].each do |folder|
44
+ source = File.expand_path(File.join(self.layout_path, folder))
45
+ target = File.expand_path(File.join(@project.assets_path, folder))
45
46
 
46
- render_directory(source, target)
47
-
48
- self
49
- end
50
-
51
- def copy_javascript
52
- source = File.expand_path(File.join(self.layout_path, 'javascripts'))
53
- target = File.expand_path(File.join(@project.assets_path, 'javascripts'))
54
-
55
- render_directory(source, target)
56
-
57
- self
58
- end
59
-
60
- def copy_images
61
- source = File.expand_path(File.join(self.layout_path, 'images'))
62
- target = File.expand_path(File.join(@project.assets_path, 'images'))
63
-
64
- render_directory(source, target)
47
+ render_directory(source, target)
48
+ end
65
49
 
66
50
  self
67
51
  end
68
52
 
69
- def copy_templates
70
- source = File.expand_path(File.join(self.layout_path, 'templates'))
71
- target = File.expand_path(File.join(@project.source_path, 'templates'))
53
+ def copy_folders
54
+ ['templates', 'includes'].each do |folder|
55
+ source = File.expand_path(File.join(self.layout_path, folder))
56
+ target = File.expand_path(File.join(@project.source_path, folder))
72
57
 
73
- render_directory(source, target)
58
+ render_directory(source, target)
59
+ end
74
60
 
75
61
  self
76
62
  end
77
63
 
78
64
  def copy_functions
79
- source = File.expand_path(File.join(self.layout_path, 'functions', 'functions.php.erb'))
80
- target = File.expand_path(File.join(@project.source_path, 'functions', 'functions.php'))
81
-
82
- write_template(source, target)
83
- end
84
-
85
- def copy_includes
86
- source = File.expand_path(File.join(self.layout_path, 'includes'))
87
- target = File.expand_path(File.join(@project.source_path, 'includes'))
88
-
89
- render_directory(source, target)
90
-
91
- self
65
+ ['functions.php', @project.project_php_file].each do |file|
66
+ source = File.expand_path(File.join(self.layout_path, 'functions', "#{file}.erb"))
67
+ if File.exist?(source)
68
+ target = File.expand_path(File.join(@project.source_path, 'functions', file))
69
+ write_template(source, target)
70
+ end
71
+ end
92
72
  end
93
73
 
94
74
  def layout_path
@@ -102,12 +82,9 @@ module Marv
102
82
  def run
103
83
  write_config
104
84
  create_structure
105
- copy_stylesheets
106
- copy_javascript
107
- copy_images
108
- copy_templates
85
+ copy_assets
86
+ copy_folders
109
87
  copy_functions
110
- copy_includes
111
88
 
112
89
  return self
113
90
  end
data/lib/marv/server.rb CHANGED
@@ -71,12 +71,13 @@ module Marv
71
71
 
72
72
  add_global_content
73
73
 
74
- @task.say "Server #{@server_name} created", :green
74
+ @task.say "Server #{@server_name} created successfuly!", :green
75
+ @task.say "Start server using marv server #{@server_name} --start"
75
76
  exit
76
77
  end
77
78
 
78
79
  def start_server
79
- update_global_content
80
+ update_global_projects
80
81
 
81
82
  begin
82
83
  @task.shell.mute do
@@ -85,7 +86,6 @@ module Marv
85
86
  rescue Exception => e
86
87
  @task.say "Error while starting server:"
87
88
  @task.say e.message + "\n", :red
88
- exit
89
89
  end
90
90
  @task.say "Server #{@server_name} running", :green
91
91
  end
@@ -101,15 +101,14 @@ module Marv
101
101
  php_pid = File.read(php_pid_file).to_i
102
102
 
103
103
  Process.kill(9, ruby_pid, php_pid)
104
- @task.say "Server #{@server_name} stopped", :green
104
+ @task.say "Server #{@server_name} stopped", :yellow
105
105
  else
106
- @task.say "Server #{@server_name} is not running", :yellow
106
+ @task.say "Server #{@server_name} is not running", :red
107
107
  end
108
108
  end
109
109
  rescue Exception => e
110
110
  @task.say "Error while stoping server:"
111
111
  @task.say e.message + "\n", :red
112
- exit
113
112
  end
114
113
  end
115
114
 
@@ -119,16 +118,17 @@ module Marv
119
118
  end
120
119
 
121
120
  def remove_server
122
- @task.say "Removing server...", :green
121
+ @task.say "Removing server..."
123
122
  @task.shell.mute do
124
123
  stop_server
125
124
  end
126
- @task.say "Removing server files...", :green
125
+ @task.say "Removing server files..."
127
126
 
128
127
  begin
129
128
  @task.shell.mute do
130
129
  FileUtils.rm_r(@server_path)
131
130
  end
131
+ @task.say "Server files removed", :green
132
132
  rescue Exception => e
133
133
  @task.say "Error while removing server files:"
134
134
  @task.say e.message + "\n", :red
@@ -136,7 +136,7 @@ module Marv
136
136
 
137
137
  remove_server_database
138
138
 
139
- @task.say "Server successfuly removed", :yellow
139
+ @task.say "Server successfuly removed!", :green
140
140
  exit
141
141
  end
142
142
 
@@ -154,7 +154,7 @@ module Marv
154
154
  end
155
155
 
156
156
  def download_wordpress
157
- @task.say "Starting server installation:", :green
157
+ @task.say "Starting server installation:"
158
158
 
159
159
  begin
160
160
  @task.shell.mute do
@@ -174,7 +174,6 @@ module Marv
174
174
  @task.say e.message + "\n", :red
175
175
  exit
176
176
  end
177
- @task.say "wordpress-#{@wp_version}.tar.gz downloaded"
178
177
  end
179
178
 
180
179
  def extract_wordpress
@@ -195,6 +194,7 @@ module Marv
195
194
  @task.say e.message + "\n", :red
196
195
  exit
197
196
  end
197
+ @task.say "WordPress files created", :green
198
198
  end
199
199
 
200
200
  def add_wordpress_config
@@ -238,6 +238,7 @@ module Marv
238
238
 
239
239
  def remove_server_database
240
240
  begin
241
+ @task.say "Removing Mysql database..."
241
242
  @task.shell.mute do
242
243
  client = Mysql2::Client.new(:host => @db_host, :port => @db_port, :username => @db_user, :password => @db_password)
243
244
  client.query("DROP DATABASE IF EXISTS #{@db_name}")
@@ -248,9 +249,8 @@ module Marv
248
249
  rescue Exception => e
249
250
  @task.say "Error while removing Mysql database:"
250
251
  @task.say e.message + "\n", :red
251
- exit
252
252
  end
253
- @task.say "Mysql database removed", :yellow
253
+ @task.say "Mysql database removed", :green
254
254
  end
255
255
 
256
256
  def add_global_content
@@ -270,31 +270,28 @@ module Marv
270
270
  end
271
271
  end
272
272
 
273
- def update_global_content
274
- @task.shell.mute do
275
- themes = Dir.glob(File.join(@server_path, 'wp-content', 'themes', '*'))
276
-
277
- themes.each do |theme|
278
- if File.symlink?(theme)
279
- unless File.exists?(theme)
280
- File.delete(theme)
281
- File.delete(File.join(ENV['HOME'], '.marv', 'themes', File.basename(theme)))
273
+ def update_global_folders(dir, folders)
274
+ begin
275
+ folders.each do |folder|
276
+ if File.symlink?(folder)
277
+ unless File.exists?(folder)
278
+ File.delete(folder)
279
+ File.delete(File.join(ENV['HOME'], '.marv', dir, File.basename(folder)))
282
280
  end
283
281
  end
284
282
  end
283
+ rescue Exception => e
284
+ @task.say "Error while updating global projects:"
285
+ @task.say e.message + "\n", :red
286
+ end
287
+ end
285
288
 
286
- plugins = Dir.glob(File.join(@server_path, 'wp-content', 'plugins', '*'))
287
-
288
- plugins.each do |plugin|
289
- if File.symlink?(plugin)
290
- unless File.exists?(plugin)
291
- File.delete(plugin)
292
- File.delete(File.join(ENV['HOME'], '.marv', 'themes', File.basename(plugin)))
293
- end
294
- end
295
- end
289
+ def update_global_projects
290
+ themes = Dir.glob(File.join(@server_path, 'wp-content', 'themes', '*'))
291
+ update_global_folders('themes', themes)
296
292
 
297
- end
293
+ plugins = Dir.glob(File.join(@server_path, 'wp-content', 'plugins', '*'))
294
+ update_global_folders('plugins', plugins)
298
295
  end
299
296
 
300
297
  end
data/lib/marv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marv
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/marv.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "marv"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonian Guveli", "Olibia Tsati"]
12
- s.date = "2014-09-08"
13
- s.description = "A toolkit for bootstrapping and developing WordPress themes using Sass, LESS, and CoffeeScript."
12
+ s.date = "2014-09-10"
13
+ s.description = "A toolkit for bootstrapping and developing WordPress themes and plugins using Sass, LESS, and CoffeeScript."
14
14
  s.email = "info@hardpixel.eu"
15
15
  s.executables = ["marv"]
16
16
  s.extra_rdoc_files = [
@@ -84,7 +84,7 @@ Gem::Specification.new do |s|
84
84
  "lib/marv/project.rb",
85
85
  "lib/marv/server.rb",
86
86
  "lib/marv/version.rb",
87
- "marv-0.3.0.gem",
87
+ "marv-0.3.1.gem",
88
88
  "marv.gemspec",
89
89
  "spec/lib/marv/project_spec.rb",
90
90
  "spec/spec_helper.rb"
@@ -93,7 +93,7 @@ Gem::Specification.new do |s|
93
93
  s.licenses = ["MIT"]
94
94
  s.require_paths = ["lib"]
95
95
  s.rubygems_version = "1.8.23"
96
- s.summary = "A tool for developing wordpress themes"
96
+ s.summary = "A command-line tool for developing wordpress themes and plugins"
97
97
 
98
98
  if s.respond_to? :specification_version then
99
99
  s.specification_version = 3
@@ -1,6 +1,7 @@
1
1
  require 'marv/project'
2
2
 
3
3
  describe Marv::Project do
4
+
4
5
  before(:each) do
5
6
  @project = Marv::Project.new('/tmp/', nil, {:name => 'Hello'})
6
7
  end
data/spec/spec_helper.rb CHANGED
@@ -9,5 +9,4 @@ p "HEY"
9
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
10
 
11
11
  RSpec.configure do |config|
12
-
13
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-09-08 00:00:00.000000000 Z
13
+ date: 2014-09-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -252,8 +252,8 @@ dependencies:
252
252
  - - ! '>='
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
- description: A toolkit for bootstrapping and developing WordPress themes using Sass,
256
- LESS, and CoffeeScript.
255
+ description: A toolkit for bootstrapping and developing WordPress themes and plugins
256
+ using Sass, LESS, and CoffeeScript.
257
257
  email: info@hardpixel.eu
258
258
  executables:
259
259
  - marv
@@ -328,7 +328,7 @@ files:
328
328
  - lib/marv/project.rb
329
329
  - lib/marv/server.rb
330
330
  - lib/marv/version.rb
331
- - marv-0.3.0.gem
331
+ - marv-0.3.1.gem
332
332
  - marv.gemspec
333
333
  - spec/lib/marv/project_spec.rb
334
334
  - spec/spec_helper.rb
@@ -356,5 +356,5 @@ rubyforge_project:
356
356
  rubygems_version: 1.8.23
357
357
  signing_key:
358
358
  specification_version: 3
359
- summary: A tool for developing wordpress themes
359
+ summary: A command-line tool for developing wordpress themes and plugins
360
360
  test_files: []