wordless 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +18 -12
- data/README.md +43 -4
- data/lib/wordless/cli.rb +63 -15
- data/lib/wordless/cli_helper.rb +3 -3
- data/lib/wordless/compile_assets.php +5 -5
- data/lib/wordless/theme_builder.php +4 -4
- data/lib/wordless/version.rb +1 -1
- data/lib/wordless/wordless_bridge.php +3 -3
- data/spec/cli_helper_spec.rb +15 -18
- data/spec/cli_spec.rb +113 -28
- data/spec/spec_helper.rb +2 -24
- data/wordless.gemspec +4 -3
- metadata +52 -15
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wordless (0.2.
|
5
|
-
|
4
|
+
wordless (0.2.2)
|
5
|
+
activesupport (~> 3.2.0)
|
6
|
+
thor (~> 0.16.0)
|
6
7
|
wordpress_tools (~> 0.0.1)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
12
|
+
activesupport (3.2.8)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
multi_json (~> 1.0)
|
11
15
|
diff-lcs (1.1.3)
|
12
16
|
fakeweb (1.3.0)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rspec-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
rspec-
|
21
|
-
|
17
|
+
i18n (0.6.1)
|
18
|
+
multi_json (1.3.6)
|
19
|
+
rspec (2.11.0)
|
20
|
+
rspec-core (~> 2.11.0)
|
21
|
+
rspec-expectations (~> 2.11.0)
|
22
|
+
rspec-mocks (~> 2.11.0)
|
23
|
+
rspec-core (2.11.1)
|
24
|
+
rspec-expectations (2.11.3)
|
25
|
+
diff-lcs (~> 1.1.3)
|
26
|
+
rspec-mocks (2.11.3)
|
27
|
+
thor (0.16.0)
|
22
28
|
wordpress_tools (0.0.1)
|
23
29
|
thor
|
24
30
|
|
@@ -27,5 +33,5 @@ PLATFORMS
|
|
27
33
|
|
28
34
|
DEPENDENCIES
|
29
35
|
fakeweb
|
30
|
-
rspec
|
36
|
+
rspec (~> 2.11.0)
|
31
37
|
wordless!
|
data/README.md
CHANGED
@@ -25,20 +25,59 @@ Compile your site's static assets:
|
|
25
25
|
|
26
26
|
wordless compile
|
27
27
|
|
28
|
-
|
28
|
+
Clean your compiled static assets:
|
29
29
|
|
30
|
-
wordless
|
31
|
-
|
30
|
+
wordless clean
|
31
|
+
|
32
|
+
Deploy your wordless installation using the `deploy_command` specified in your Wordfile:
|
33
|
+
|
34
|
+
wordless deploy
|
35
|
+
|
36
|
+
You can also use the refresh option `-r` to compile your assets before deploying and clean your assets after:
|
37
|
+
|
38
|
+
wordless deploy -r
|
32
39
|
|
33
40
|
Get some help:
|
34
41
|
|
35
42
|
wordless help
|
36
43
|
|
44
|
+
## Configuration
|
45
|
+
|
46
|
+
You can create a Wordfile to customize the behaviour of wordless:
|
47
|
+
|
48
|
+
```yaml
|
49
|
+
wordless_repo: 'git://github.com/welaika/wordless.git'
|
50
|
+
static_css:
|
51
|
+
- 'wp-content/themes/mytheme/assets/stylesheets/screen.css'
|
52
|
+
- 'wp-content/themes/mytheme/assets/stylesheets/print.css'
|
53
|
+
static_js:
|
54
|
+
- 'wp-content/themes/mytheme/assets/javascripts/application.js'
|
55
|
+
- 'wp-content/themes/mytheme/assets/javascripts/mobile.js'
|
56
|
+
deploy_command: 'wordmove push -du'
|
57
|
+
```
|
58
|
+
|
37
59
|
## Caveats
|
38
60
|
|
39
61
|
- If you attempt to download a WordPress localization that's outdated, the latest English version will be downloaded instead.
|
40
62
|
- Only tested on Mac OS X
|
41
|
-
|
63
|
+
|
64
|
+
## Running specs
|
65
|
+
|
66
|
+
Clone the wordless repo inside `spec/fixtures/wordless`:
|
67
|
+
|
68
|
+
git clone https://github.com/welaika/wordless.git spec/fixtures/wordless && cd spec/fixtures/wordless
|
69
|
+
|
70
|
+
Set your compass and ruby paths:
|
71
|
+
|
72
|
+
vim wordless/theme_builder/vanilla_theme/config/initializers/wordless_preferences.php
|
73
|
+
|
74
|
+
Commit your changes:
|
75
|
+
|
76
|
+
git commit -am "Set compass and ruby paths"
|
77
|
+
|
78
|
+
Go back to the wordless_gem directory and have fun:
|
79
|
+
|
80
|
+
cd - && rspec
|
42
81
|
|
43
82
|
## Contributing
|
44
83
|
|
data/lib/wordless/cli.rb
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
require 'thor'
|
2
|
-
|
2
|
+
require 'yaml'
|
3
3
|
require 'net/http'
|
4
4
|
require 'rbconfig'
|
5
5
|
require 'tempfile'
|
6
6
|
require 'wordpress_tools/cli'
|
7
7
|
require 'wordless/cli_helper'
|
8
|
+
require 'active_support/all'
|
8
9
|
|
9
10
|
module Wordless
|
10
11
|
class CLI < Thor
|
11
12
|
include Thor::Actions
|
12
13
|
include Wordless::CLIHelper
|
13
|
-
|
14
|
+
|
14
15
|
@@lib_dir = File.expand_path(File.dirname(__FILE__))
|
15
|
-
|
16
|
+
@@config = if File.exists?('Wordfile')
|
17
|
+
YAML::load(File.open('Wordfile')).symbolize_keys
|
18
|
+
else
|
19
|
+
{}
|
20
|
+
end
|
21
|
+
|
16
22
|
no_tasks do
|
17
23
|
def wordless_repo
|
18
|
-
'git://github.com/welaika/wordless.git'
|
24
|
+
@@config[:wordless_repo] || 'git://github.com/welaika/wordless.git'
|
19
25
|
end
|
20
26
|
end
|
21
|
-
|
22
|
-
desc "new [NAME]", "
|
27
|
+
|
28
|
+
desc "new [NAME]", "Download WordPress in specified directory, install the Wordless plugin and create a Wordless theme"
|
23
29
|
method_option :locale, :aliases => "-l", :desc => "WordPress locale (default is en_US)"
|
24
30
|
def new(name)
|
25
31
|
WordPressTools::CLI.new.invoke('new', [name], :bare => true, :locale => options['locale'])
|
26
32
|
Dir.chdir(name)
|
27
|
-
|
28
|
-
|
33
|
+
install
|
34
|
+
theme(name)
|
29
35
|
end
|
30
|
-
|
31
|
-
desc "install", "
|
36
|
+
|
37
|
+
desc "install", "Install the Wordless plugin into an existing WordPress installation"
|
32
38
|
def install
|
33
39
|
unless git_installed?
|
34
40
|
error "Git is not available. Please install git."
|
@@ -46,14 +52,14 @@ module Wordless
|
|
46
52
|
error "There was an error installing the Wordless plugin."
|
47
53
|
end
|
48
54
|
end
|
49
|
-
|
50
|
-
desc "theme NAME", "
|
55
|
+
|
56
|
+
desc "theme [NAME]", "Create a new Wordless theme NAME"
|
51
57
|
def theme(name)
|
52
58
|
unless File.directory? 'wp-content/themes'
|
53
59
|
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
54
60
|
return
|
55
61
|
end
|
56
|
-
|
62
|
+
|
57
63
|
# Run PHP helper script
|
58
64
|
if system "php #{File.join(@@lib_dir, 'theme_builder.php')} #{name}"
|
59
65
|
success "Created a new Wordless theme in 'wp-content/themes/#{name}'."
|
@@ -62,8 +68,8 @@ module Wordless
|
|
62
68
|
return
|
63
69
|
end
|
64
70
|
end
|
65
|
-
|
66
|
-
desc "compile", "
|
71
|
+
|
72
|
+
desc "compile", "Compile static assets"
|
67
73
|
def compile
|
68
74
|
if system "php #{File.join(@@lib_dir, 'compile_assets.php')}"
|
69
75
|
success "Compiled static assets."
|
@@ -71,5 +77,47 @@ module Wordless
|
|
71
77
|
error "Couldn't compile static assets."
|
72
78
|
end
|
73
79
|
end
|
80
|
+
|
81
|
+
desc "clean", "Clean static assets"
|
82
|
+
def clean
|
83
|
+
unless File.directory? 'wp-content/themes'
|
84
|
+
error "Directory 'wp-content/themes' not found. Make sure you're at the root level of a WordPress installation."
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
static_css = Array(@@config[:static_css] || Dir['wp-content/themes/*/assets/stylesheets/screen.css'])
|
89
|
+
static_js = Array(@@config[:static_js] || Dir['wp-content/themes/*/assets/javascripts/application.js'])
|
90
|
+
|
91
|
+
begin
|
92
|
+
(static_css + static_js).each do |file|
|
93
|
+
FileUtils.rm_f(file) if File.exists?(file)
|
94
|
+
end
|
95
|
+
success "Cleaned static assets."
|
96
|
+
rescue
|
97
|
+
error "Couldn't clean static assets."
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
desc "deploy", "Deploy your WordPress site using the deploy_command defined in your Wordfile"
|
102
|
+
method_option :refresh, :aliases => "-r", :desc => "Compile static assets before deploying and clean them afterwards"
|
103
|
+
method_option :command, :aliases => "-c", :desc => "Use a custom deploy command"
|
104
|
+
def deploy
|
105
|
+
unless File.exists? 'wp-config.php'
|
106
|
+
error "WordPress not found. Make sure you're at the root level of a WordPress installation."
|
107
|
+
return
|
108
|
+
end
|
109
|
+
|
110
|
+
compile if options['refresh']
|
111
|
+
|
112
|
+
deploy_command = options['command'].presence || @@config[:deploy_command]
|
113
|
+
|
114
|
+
if deploy_command
|
115
|
+
system "#{deploy_command}"
|
116
|
+
else
|
117
|
+
error "deploy_command not set. Make sure it is included in your Wordfile."
|
118
|
+
end
|
119
|
+
|
120
|
+
clean if options['refresh']
|
121
|
+
end
|
74
122
|
end
|
75
123
|
end
|
data/lib/wordless/cli_helper.rb
CHANGED
@@ -13,7 +13,7 @@ module Wordless
|
|
13
13
|
def warning(message)
|
14
14
|
say message, :yellow
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def download(url, destination)
|
18
18
|
begin
|
19
19
|
f = open(destination, "wb")
|
@@ -34,9 +34,9 @@ module Wordless
|
|
34
34
|
void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
|
35
35
|
system "git --version >>#{void} 2>&1"
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def add_git_repo(repo, destination)
|
39
39
|
run "git clone #{repo} #{destination}", :verbose => false, :capture => true
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
@@ -5,13 +5,13 @@ require 'wordless_bridge.php';
|
|
5
5
|
class CompileAssets extends WordlessBridge {
|
6
6
|
public static function start() {
|
7
7
|
parent::initialize();
|
8
|
-
|
8
|
+
|
9
9
|
// Determine theme name
|
10
10
|
foreach (scandir(self::$current_dir . '/wp-content/themes') as $theme_dir) {
|
11
|
-
if (in_array($theme_dir, array('.', '..')) && !is_dir($theme_dir)) {
|
11
|
+
if (in_array($theme_dir, array('.', '..', 'index.php')) && !is_dir($theme_dir)) {
|
12
12
|
continue;
|
13
13
|
}
|
14
|
-
|
14
|
+
|
15
15
|
$previous_theme_name = WordlessBridge::$theme_name;
|
16
16
|
WordlessBridge::$theme_name = $theme_dir;
|
17
17
|
if (Wordless::theme_is_wordless_compatible()) {
|
@@ -23,9 +23,9 @@ class CompileAssets extends WordlessBridge {
|
|
23
23
|
WordlessBridge::$theme_name = $previous_theme_name;
|
24
24
|
}
|
25
25
|
}
|
26
|
-
|
26
|
+
|
27
27
|
require(get_template_directory() . '/config/initializers/wordless_preferences.php');
|
28
|
-
|
28
|
+
|
29
29
|
Wordless::register_preprocessors();
|
30
30
|
Wordless::compile_assets();
|
31
31
|
}
|
@@ -5,14 +5,14 @@ require 'wordless_bridge.php';
|
|
5
5
|
class ThemeBuilder extends WordlessBridge {
|
6
6
|
public static function start() {
|
7
7
|
global $argv, $theme_name;
|
8
|
-
|
8
|
+
|
9
9
|
parent::initialize();
|
10
|
-
|
10
|
+
|
11
11
|
require_once Wordless::join_paths(self::$plugin_dir, "wordless", "theme_builder.php");
|
12
|
-
|
12
|
+
|
13
13
|
$theme_name = $argv[1] ? $argv[1] : 'wordless';
|
14
14
|
$permissions = substr(sprintf('%o', fileperms(self::$plugin_dir)), -4);
|
15
|
-
|
15
|
+
|
16
16
|
$builder = new WordlessThemeBuilder($theme_name, $theme_name, intval($permissions, 8));
|
17
17
|
$builder->build();
|
18
18
|
}
|
data/lib/wordless/version.rb
CHANGED
@@ -14,13 +14,13 @@ class WordlessBridge {
|
|
14
14
|
public static $current_dir;
|
15
15
|
public static $plugin_dir;
|
16
16
|
public static $theme_name = 'stub';
|
17
|
-
|
17
|
+
|
18
18
|
public static function initialize() {
|
19
19
|
self::$current_dir = getcwd();
|
20
20
|
self::$plugin_dir = self::$current_dir . '/wp-content/plugins/wordless';
|
21
|
-
|
21
|
+
|
22
22
|
require_once self::$plugin_dir . "/wordless/wordless.php";
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
26
|
-
?>
|
26
|
+
?>
|
data/spec/cli_helper_spec.rb
CHANGED
@@ -1,57 +1,54 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Wordless::CLIHelper do
|
4
|
-
|
5
|
-
# @shell ||= Thor::Shell::Basic.new
|
6
|
-
# end
|
7
|
-
|
4
|
+
|
8
5
|
before :each do
|
9
6
|
@cli = Wordless::CLI.new
|
10
7
|
end
|
11
|
-
|
8
|
+
|
12
9
|
context "::download" do
|
13
10
|
before(:each) do
|
14
11
|
@tempfile = Tempfile.new("download_test")
|
15
12
|
@valid_url = "http://www.example.com/test"
|
16
13
|
FakeWeb.register_uri(:get, @valid_url, :body => "Download test")
|
17
14
|
end
|
18
|
-
|
15
|
+
|
19
16
|
it "downloads a file to the specified location" do
|
20
17
|
@cli.download(@valid_url, @tempfile.path)
|
21
|
-
open(@tempfile.path).read.should
|
18
|
+
open(@tempfile.path).read.should == "Download test"
|
22
19
|
end
|
23
|
-
|
20
|
+
|
24
21
|
it "returns true on success" do
|
25
|
-
@cli.download(@valid_url, @tempfile.path).should
|
22
|
+
@cli.download(@valid_url, @tempfile.path).should be_true
|
26
23
|
end
|
27
|
-
|
24
|
+
|
28
25
|
it "returns false on failure" do
|
29
|
-
@cli.download("http://an.invalid.url", @tempfile.path).should
|
26
|
+
@cli.download("http://an.invalid.url", @tempfile.path).should be_false
|
30
27
|
end
|
31
|
-
|
28
|
+
|
32
29
|
after(:each) do
|
33
30
|
@tempfile.close!
|
34
31
|
end
|
35
32
|
end
|
36
|
-
|
33
|
+
|
37
34
|
context "::unzip" do
|
38
35
|
it "unzips a file" do
|
39
36
|
@cli.unzip(File.expand_path('spec/fixtures/zipped_file.zip'), 'tmp/unzip')
|
40
|
-
File.exists?('tmp/unzip/zipped_file').should
|
37
|
+
File.exists?('tmp/unzip/zipped_file').should be_true
|
41
38
|
end
|
42
|
-
|
39
|
+
|
43
40
|
after(:each) do
|
44
41
|
FileUtils.rm_rf('tmp/unzip') if File.directory? 'tmp/unzip'
|
45
42
|
end
|
46
43
|
end
|
47
|
-
|
44
|
+
|
48
45
|
context "::error" do
|
49
46
|
it "displays an error" do
|
50
47
|
$stdout.should_receive(:puts).with("\e[31mI am an error\e[0m")
|
51
48
|
@cli.error("I am an error")
|
52
49
|
end
|
53
50
|
end
|
54
|
-
|
51
|
+
|
55
52
|
context "::success" do
|
56
53
|
it "displays a success message" do
|
57
54
|
$stdout.should_receive(:puts).with("\e[32mI am a success message\e[0m")
|
@@ -65,4 +62,4 @@ describe Wordless::CLIHelper do
|
|
65
62
|
@cli.warning("I am a warning")
|
66
63
|
end
|
67
64
|
end
|
68
|
-
end
|
65
|
+
end
|
data/spec/cli_spec.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Wordless::CLI do
|
4
|
-
|
5
|
-
|
6
|
-
@original_wd = Dir.pwd
|
4
|
+
|
5
|
+
before :all do
|
7
6
|
wp_api_response = <<-eof
|
8
7
|
upgrade
|
9
8
|
http://wordpress.org/download/
|
@@ -15,30 +14,44 @@ describe Wordless::CLI do
|
|
15
14
|
eof
|
16
15
|
FakeWeb.register_uri(:get, %r|http://api.wordpress.org/core/version-check/1.5/.*|, :body => wp_api_response)
|
17
16
|
FakeWeb.register_uri(:get, "http://wordpress.org/wordpress-3.3.1.zip", :body => File.expand_path('spec/fixtures/wordpress_stub.zip'))
|
17
|
+
end
|
18
|
+
|
19
|
+
before :each do
|
20
|
+
Wordless::CLI.class_variable_set :@@config, {
|
21
|
+
:wordless_repo => File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'wordless'))
|
22
|
+
}
|
23
|
+
@original_wd = Dir.pwd
|
18
24
|
Dir.chdir('tmp')
|
19
25
|
end
|
20
|
-
|
26
|
+
|
27
|
+
after :each do
|
28
|
+
Dir.chdir(@original_wd)
|
29
|
+
%w(tmp/wordpress tmp/myapp).each do |dir|
|
30
|
+
FileUtils.rm_rf(dir) if File.directory? dir
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
21
34
|
context "#new" do
|
22
35
|
it "downloads a copy of WordPress, installs Wordless and creates a theme" do
|
23
36
|
Wordless::CLI.start ['new', 'myapp']
|
24
|
-
File.exists?('wp-content/index.php').should
|
25
|
-
(File.exists?('wp-content/plugins/plugin.php') || File.directory?('wp-content/themes/theme')).should
|
26
|
-
File.directory?('wp-content/plugins/wordless').should
|
27
|
-
File.directory?('wp-content/themes/myapp').should
|
28
|
-
File.exists?('wp-content/themes/myapp/index.php').should
|
37
|
+
File.exists?('wp-content/index.php').should be_true
|
38
|
+
(File.exists?('wp-content/plugins/plugin.php') || File.directory?('wp-content/themes/theme')).should be_false
|
39
|
+
File.directory?('wp-content/plugins/wordless').should be_true
|
40
|
+
File.directory?('wp-content/themes/myapp').should be_true
|
41
|
+
File.exists?('wp-content/themes/myapp/index.php').should be_true
|
29
42
|
end
|
30
43
|
end
|
31
|
-
|
44
|
+
|
32
45
|
context "#install" do
|
33
46
|
context "with a valid WordPress installation" do
|
34
47
|
it "installs the Wordless plugin" do
|
35
48
|
WordPressTools::CLI.start ['new']
|
36
49
|
Dir.chdir 'wordpress'
|
37
50
|
Wordless::CLI.start ['install']
|
38
|
-
File.directory?('wp-content/plugins/wordless').should
|
39
|
-
end
|
51
|
+
File.directory?('wp-content/plugins/wordless').should be_true
|
52
|
+
end
|
40
53
|
end
|
41
|
-
|
54
|
+
|
42
55
|
context "without a valid WordPress installation" do
|
43
56
|
it "fails to install the Wordless plugin" do
|
44
57
|
content = capture(:stdout) { Wordless::CLI.start ['install'] }
|
@@ -46,7 +59,7 @@ describe Wordless::CLI do
|
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
49
|
-
|
62
|
+
|
50
63
|
context "#theme" do
|
51
64
|
context "with a valid WordPress installation and the Wordless plugin" do
|
52
65
|
before :each do
|
@@ -54,14 +67,14 @@ describe Wordless::CLI do
|
|
54
67
|
Dir.chdir 'wordpress'
|
55
68
|
Wordless::CLI.start ['install']
|
56
69
|
end
|
57
|
-
|
70
|
+
|
58
71
|
it "creates a Wordless theme" do
|
59
72
|
Wordless::CLI.start ['theme', 'mytheme']
|
60
|
-
File.directory?('wp-content/themes/mytheme').should
|
61
|
-
File.exists?('wp-content/themes/mytheme/index.php').should
|
73
|
+
File.directory?('wp-content/themes/mytheme').should be_true
|
74
|
+
File.exists?('wp-content/themes/mytheme/index.php').should be_true
|
62
75
|
end
|
63
76
|
end
|
64
|
-
|
77
|
+
|
65
78
|
context "without a valid WordPress installation" do
|
66
79
|
it "fails to create a Wordless theme" do
|
67
80
|
content = capture(:stdout) { Wordless::CLI.start ['theme', 'mytheme'] }
|
@@ -69,25 +82,97 @@ describe Wordless::CLI do
|
|
69
82
|
end
|
70
83
|
end
|
71
84
|
end
|
72
|
-
|
85
|
+
|
73
86
|
context "#compile" do
|
74
87
|
context "with a valid Wordless installation" do
|
75
88
|
before :each do
|
76
89
|
Wordless::CLI.start ['new', 'myapp']
|
77
90
|
end
|
78
|
-
|
91
|
+
|
79
92
|
it "compiles static assets" do
|
80
93
|
Wordless::CLI.start ['compile']
|
81
|
-
File.exists?('wp-content/themes/myapp/assets/stylesheets/screen.css').should
|
82
|
-
File.exists?('wp-content/themes/myapp/assets/javascripts/application.js').should
|
94
|
+
File.exists?('wp-content/themes/myapp/assets/stylesheets/screen.css').should be_true
|
95
|
+
File.exists?('wp-content/themes/myapp/assets/javascripts/application.js').should be_true
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
FileUtils.
|
99
|
+
|
100
|
+
context "#clean" do
|
101
|
+
before do
|
102
|
+
FileUtils.mkdir_p('myapp/wp-content/themes/myapp/assets/stylesheets')
|
103
|
+
FileUtils.mkdir_p('myapp/wp-content/themes/myapp/assets/javascripts')
|
104
|
+
Dir.chdir('myapp')
|
105
|
+
end
|
106
|
+
|
107
|
+
let(:default_css) { 'wp-content/themes/myapp/assets/stylesheets/screen.css' }
|
108
|
+
let(:default_js) { 'wp-content/themes/myapp/assets/javascripts/application.js' }
|
109
|
+
|
110
|
+
let(:first_css) { 'wp-content/themes/myapp/assets/stylesheets/foo.css' }
|
111
|
+
let(:second_css) { 'wp-content/themes/myapp/assets/stylesheets/bar.css' }
|
112
|
+
let(:first_js) { 'wp-content/themes/myapp/assets/javascripts/robin.js' }
|
113
|
+
let(:second_js) { 'wp-content/themes/myapp/assets/javascripts/galahad.js' }
|
114
|
+
|
115
|
+
it "should remove default default assets" do
|
116
|
+
FileUtils.touch(default_css)
|
117
|
+
FileUtils.touch(default_js)
|
118
|
+
|
119
|
+
Wordless::CLI.start ['clean']
|
120
|
+
|
121
|
+
File.exists?(default_css).should be_false
|
122
|
+
File.exists?(default_js).should be_false
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should remove assets specified on config" do
|
126
|
+
Wordless::CLI.class_variable_set :@@config, {
|
127
|
+
:static_css => [ first_css, second_css ],
|
128
|
+
:static_js => [ first_js, second_js ]
|
129
|
+
}
|
130
|
+
|
131
|
+
[ first_css, second_css, first_js, second_js ].each do |file|
|
132
|
+
FileUtils.touch(file)
|
133
|
+
end
|
134
|
+
|
135
|
+
Wordless::CLI.start ['clean']
|
136
|
+
|
137
|
+
[ first_css, second_css, first_js, second_js ].each do |file|
|
138
|
+
File.exists?(file).should be_false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "#deploy" do
|
144
|
+
|
145
|
+
let(:cli) { Wordless::CLI.new }
|
146
|
+
let(:file) { 'shrubbery.txt' }
|
147
|
+
|
148
|
+
before :each do
|
149
|
+
FileUtils.mkdir_p('myapp') and Dir.chdir('myapp')
|
150
|
+
FileUtils.touch('wp-config.php')
|
151
|
+
Wordless::CLI.class_variable_set :@@config, {
|
152
|
+
:deploy_command => "touch #{file}"
|
153
|
+
}
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should deploy via the deploy command" do
|
157
|
+
cli.deploy
|
158
|
+
File.exists?(file).should be_true
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should compile and clean if refresh option is passed" do
|
162
|
+
cli.should_receive(:compile).and_return(true)
|
163
|
+
cli.should_receive(:clean).and_return(true)
|
164
|
+
cli.stub(:options).and_return({ 'refresh' => true })
|
165
|
+
cli.deploy
|
166
|
+
end
|
167
|
+
|
168
|
+
context "if a custom deploy is passed" do
|
169
|
+
let(:file) { 'knights.txt' }
|
170
|
+
|
171
|
+
it "should launch the custom deploy command" do
|
172
|
+
cli.stub(:options).and_return({ 'command' => "touch #{file}" })
|
173
|
+
cli.deploy
|
174
|
+
File.exists?(file).should be_true
|
175
|
+
end
|
91
176
|
end
|
92
177
|
end
|
93
|
-
end
|
178
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,33 +2,11 @@ require 'wordless/cli'
|
|
2
2
|
require 'fakeweb'
|
3
3
|
require 'thor'
|
4
4
|
|
5
|
-
# Set shell to basic
|
6
|
-
# $0 = "thor"
|
7
|
-
# $thor_runner = true
|
8
|
-
# ARGV.clear
|
9
|
-
# Thor::Base.shell = Thor::Shell::Basic
|
10
|
-
|
11
5
|
RSpec.configure do |config|
|
12
6
|
FakeWeb.allow_net_connect = false
|
13
|
-
|
14
|
-
$stdout = StringIO.new
|
15
|
-
|
16
|
-
# Stub Wordless::CLI#wordless_repo to avoid hitting the network when testing Wordless installation
|
17
|
-
# FIXME - Need to be able to selectively stub this
|
18
|
-
# config.before(:each, :stub_wordless_install => true) do
|
19
|
-
# module Wordless
|
20
|
-
# class CLI
|
21
|
-
# no_tasks do
|
22
|
-
# def wordless_repo
|
23
|
-
# File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'wordless_stub'))
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
|
30
7
|
FileUtils.mkdir('tmp') unless File.directory? 'tmp'
|
31
|
-
|
8
|
+
|
9
|
+
# utility to log commands output or errors
|
32
10
|
def capture(stream)
|
33
11
|
begin
|
34
12
|
stream = stream.to_s
|
data/wordless.gemspec
CHANGED
@@ -2,16 +2,17 @@
|
|
2
2
|
require File.expand_path('../lib/wordless/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Étienne Després"]
|
5
|
+
gem.authors = ["Étienne Després", "Ju Liu"]
|
6
6
|
gem.email = ["etienne@molotov.ca"]
|
7
7
|
gem.description = %q{Command line tool to manage Wordless themes.}
|
8
8
|
gem.summary = %q{Manage Wordless themes.}
|
9
9
|
gem.homepage = "http://github.com/etienne/wordless_gem"
|
10
10
|
|
11
|
-
gem.add_dependency "thor"
|
11
|
+
gem.add_dependency "thor", "~> 0.16.0"
|
12
12
|
gem.add_dependency "wordpress_tools", '~> 0.0.1'
|
13
|
+
gem.add_dependency "activesupport", '~> 3.2.0'
|
13
14
|
|
14
|
-
gem.add_development_dependency 'rspec'
|
15
|
+
gem.add_development_dependency 'rspec', "~> 2.11.0"
|
15
16
|
gem.add_development_dependency 'fakeweb'
|
16
17
|
|
17
18
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Étienne Després
|
9
|
+
- Ju Liu
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: thor
|
16
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
|
-
- -
|
20
|
+
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
+
version: 0.16.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.16.0
|
25
31
|
- !ruby/object:Gem::Dependency
|
26
32
|
name: wordpress_tools
|
27
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
28
34
|
none: false
|
29
35
|
requirements:
|
30
36
|
- - ~>
|
@@ -32,21 +38,47 @@ dependencies:
|
|
32
38
|
version: 0.0.1
|
33
39
|
type: :runtime
|
34
40
|
prerelease: false
|
35
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.0.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activesupport
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.2.0
|
36
63
|
- !ruby/object:Gem::Dependency
|
37
64
|
name: rspec
|
38
|
-
requirement:
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
39
66
|
none: false
|
40
67
|
requirements:
|
41
|
-
- -
|
68
|
+
- - ~>
|
42
69
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
70
|
+
version: 2.11.0
|
44
71
|
type: :development
|
45
72
|
prerelease: false
|
46
|
-
version_requirements:
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.11.0
|
47
79
|
- !ruby/object:Gem::Dependency
|
48
80
|
name: fakeweb
|
49
|
-
requirement:
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
50
82
|
none: false
|
51
83
|
requirements:
|
52
84
|
- - ! '>='
|
@@ -54,7 +86,12 @@ dependencies:
|
|
54
86
|
version: '0'
|
55
87
|
type: :development
|
56
88
|
prerelease: false
|
57
|
-
version_requirements:
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
58
95
|
description: Command line tool to manage Wordless themes.
|
59
96
|
email:
|
60
97
|
- etienne@molotov.ca
|
@@ -104,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
141
|
version: '0'
|
105
142
|
requirements: []
|
106
143
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
144
|
+
rubygems_version: 1.8.23
|
108
145
|
signing_key:
|
109
146
|
specification_version: 3
|
110
147
|
summary: Manage Wordless themes.
|