wordless 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b40aab8fcbc792a7f412619b33593ee6477724f
4
- data.tar.gz: 08451c440d780863cf12d77a944cf52a3c84a0e2
3
+ metadata.gz: cdfb87db26ed86aa7c9eba8af20a05b43420779b
4
+ data.tar.gz: a5e1d58e1574feab7a0cb906093fb4178f36bab1
5
5
  SHA512:
6
- metadata.gz: b73dd76cd25890160cba93bbb9b62e36a1ce39c19a7004c02fda4ec0c126b76a2f7b5fdf8f85d5d8433ecb16f3e51788232b246c64c9c5865ce78a5fbd5bcbdb
7
- data.tar.gz: 5574d056f5af9c9a06a066eb0358c6ac9aa27ec2793e34ac728bd26e827aa4adcb43226143b449999f5ea1e41e6de608bea65e70f9fc3f2d75f9103a755546cf
6
+ metadata.gz: ebfdadfb8be11dace9245a20057a340d24bac44dd3dfb27c83d35477bd2839fe48bd54e66dc8fec068efea4a71fdc66d4f6586e8f67118ca0c10cf4a8f72671f
7
+ data.tar.gz: a3cdab7a1315b4ddb9294d1945c82e91d0f877ae0917465bcec48ce5bd6256d4e022abc9fbbef4310ca2ff7afe3c867c3957603a654de9b50be403ee25f1ef83
data/README.mdown CHANGED
@@ -114,6 +114,8 @@ static_js:
114
114
  deploy_command: 'wordmove push -t'
115
115
  ```
116
116
 
117
+ **Note**: remember to add `screen.css` and/or `application.js` if you want to define `static_css` or `static_js`
118
+
117
119
  ## Caveats
118
120
 
119
121
  - If you attempt to download a WordPress localization that's outdated, the latest English version will be downloaded instead.
data/bin/setup.sh CHANGED
@@ -3,7 +3,7 @@
3
3
  set -e
4
4
 
5
5
  FIXTURE_PATH="spec/fixtures/wordless"
6
- WORDLESS_REPO="git://github.com/welaika/wordless.git"
6
+ WORDLESS_ARCHIVE="https://github.com/welaika/wordless/archive/master.tar.gz"
7
7
  WORDLESS_PREFERENCES="wordless/theme_builder/vanilla_theme/config/initializers/wordless_preferences.php"
8
8
 
9
9
  function log {
@@ -11,22 +11,18 @@ function log {
11
11
  echo "== [ $1 ] ==";
12
12
  }
13
13
 
14
+ log "Deleting {$FIXTURE_PATH}..."
14
15
  rm -rf $FIXTURE_PATH
16
+ mkdir $FIXTURE_PATH
17
+ echo "Done!"
15
18
 
16
- log "Cloning wordless repo"
17
- git clone --branch=master $WORDLESS_REPO $FIXTURE_PATH && cd $FIXTURE_PATH
19
+ log "Downloading wordless from github..."
20
+ cd $FIXTURE_PATH
21
+ wget $WORDLESS_ARCHIVE -O - | tar -xz --strip 1
22
+ echo "Done!"
18
23
 
19
- log "Customizing ruby and compass paths"
20
- echo "# BEGIN: wordless_preferences.php"
24
+ log "Customizing ruby and compass paths..."
21
25
  cp -f ../wordless_preferences.php $WORDLESS_PREFERENCES
22
26
  perl -p -i -e "s|<RUBY_PATH>|$(which ruby)|" $WORDLESS_PREFERENCES
23
27
  perl -p -i -e "s|<COMPASS_PATH>|$(which compass)|" $WORDLESS_PREFERENCES
24
- cat $WORDLESS_PREFERENCES
25
- echo "# END: wordless_preferences.php"
26
-
27
- log "Committing changes to test repo"
28
- git config user.name "Wordless Tester"
29
- git config user.email "tester@wordless.com"
30
- git commit -am "updated ruby and compass path"
31
-
32
- log "DONE!"
28
+ echo "Done!"
data/lib/wordless/cli.rb CHANGED
@@ -5,7 +5,7 @@ module Wordless
5
5
 
6
6
  no_tasks do
7
7
  def wordless_cli
8
- Wordless::WordlessCLI.new(options, self)
8
+ Wordless::WordlessCLI.new(self, options)
9
9
  end
10
10
  end
11
11
 
@@ -18,7 +18,7 @@ module Wordless
18
18
 
19
19
  desc "install", "Install the Wordless plugin into an existing WordPress installation"
20
20
  def install
21
- wordless_cli.install
21
+ wordless_cli.install_wordless
22
22
  end
23
23
 
24
24
  desc "theme [NAME]", "Create a new Wordless theme NAME"
@@ -37,8 +37,8 @@ module Wordless
37
37
  end
38
38
 
39
39
  desc "deploy", "Deploy your WordPress site using the deploy_command defined in your Wordfile"
40
- method_option :refresh, :aliases => "-r", :desc => "Compile static assets before deploying and clean them afterwards"
41
- method_option :command, :aliases => "-c", :desc => "Use a custom deploy command"
40
+ method_option :refresh, aliases: "-r", desc: "Compile static assets before deploying and clean them afterwards"
41
+ method_option :command, aliases: "-c", desc: "Use a custom deploy command"
42
42
  def deploy
43
43
  wordless_cli.deploy
44
44
  end
@@ -1,5 +1,21 @@
1
1
  module Wordless
2
2
  module CLIHelper
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ [ :say, :run ].each do |sym|
7
+ define_method sym do |*args|
8
+ thor.send(sym, *args)
9
+ end
10
+ private sym
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def thor
17
+ raise NotImplementedError, "Including class must provide a thor instance object"
18
+ end
3
19
 
4
20
  def info(message)
5
21
  log_message message
@@ -18,27 +34,18 @@ module Wordless
18
34
  log_message message, :yellow
19
35
  end
20
36
 
21
- def download(url, destination)
22
- begin
23
- f = open(destination, "wb")
24
- f.write(open(url).read) ? true : false
25
- rescue
26
- false
27
- ensure
28
- f.close
29
- end
37
+ def ensure_wp_cli_installed!
38
+ error("Cannot continue: WP-CLI is not installed.") unless wp_cli_installed?
30
39
  end
31
40
 
32
- def unzip(file, destination)
33
- run_command "unzip #{file} -d #{destination}"
41
+ def run_command(command)
42
+ system("#{command} >>#{void} 2>&1")
34
43
  end
35
44
 
36
- def git_installed?
37
- run_command("git --version")
45
+ def wp_cli_installed?
46
+ run_command("which wp")
38
47
  end
39
48
 
40
- private
41
-
42
49
  def log_message(message, color = nil)
43
50
  say message, color
44
51
  end
@@ -46,10 +53,5 @@ module Wordless
46
53
  def void
47
54
  RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
48
55
  end
49
-
50
- def run_command(command)
51
- system("#{command} >>#{void} 2>&1")
52
- end
53
-
54
56
  end
55
57
  end
@@ -1,3 +1,3 @@
1
1
  module Wordless
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  module Wordless
2
2
  class WordlessCLI
3
3
  include CLIHelper
4
+
4
5
  attr_reader :options, :thor
5
6
 
6
7
  module PATH
@@ -17,192 +18,165 @@ module Wordless
17
18
  PATH::THEMES => 'wp-content/themes',
18
19
  }
19
20
 
20
- DEFAULT_PATHS.each do |type, value|
21
- define_method "#{type}_path" do
22
- value
23
- end
24
- end
25
-
26
- def lib_dir
27
- @@lib_dir ||= File.expand_path(File.dirname(__FILE__))
28
- end
29
-
30
- def wordpress_dir(current_dir = start_dir)
31
- @wordpress_dir ||= (
32
- current_dir = File.expand_path(current_dir)
33
-
34
- if File.exist? File.join(current_dir, wp_content_path)
35
- current_dir
36
- elsif last_dir?(current_dir)
37
- raise StandardError, "Could not find a valid Wordpress directory"
38
- else
39
- wordpress_dir(upper_dir(current_dir))
40
- end
41
- )
42
- end
43
-
44
- def last_dir?(directory)
45
- directory == "/"
46
- end
47
-
48
- def upper_dir(directory)
49
- File.join(directory, '..')
50
- end
51
-
52
- def config
53
- @@config ||= (
54
- if File.exist?(wordfile_path)
55
- YAML::load(File.open(wordfile_path)).symbolize_keys
56
- else
57
- {}
58
- end
59
- )
60
- end
61
-
62
- [ :say, :run ].each do |sym|
63
- define_method sym do |*args|
64
- thor.send(sym, *args)
65
- end
66
- end
67
-
68
- def initialize(options = {}, thor = nil)
21
+ def initialize(thor, options = {})
69
22
  @options = options
70
23
  @thor = thor
71
24
  end
72
25
 
73
26
  def start(name)
74
- WordPressTools::CLI.new.invoke('new', [name], options)
75
- Dir.chdir(name)
76
- install
27
+ install_wordpress_and_wp_cli(name)
28
+ ensure_wp_cli_installed!
29
+
30
+ install_wordless
77
31
  create_theme(name)
78
- if wp_cli_installed?
79
- activate_plugin
80
- activate_theme(name)
81
- set_permalinks
82
- else
83
- warning("WP-CLI is not installed. Cannot activate wordless plugin and theme")
84
- end
32
+ activate_theme(name)
33
+ set_permalinks
85
34
  end
86
35
 
87
- def install
88
- at_wordpress_root!
36
+ def install_wordless
37
+ ensure_wp_cli_installed!
89
38
 
90
- unless git_installed?
91
- error "Git is not available. Please install git."
92
- end
39
+ info("Installing and activating plugin...")
93
40
 
94
- if File.directory?(plugins_path)
95
- if run_command "git clone #{wordless_repo} #{wordless_plugin_path}"
96
- success "Installed Wordless plugin."
41
+ at_wordpress_root do
42
+ error("Directory '#{plugins_path}' not found.") unless File.directory?(plugins_path)
43
+ if run_command("wp plugin install wordless --activate")
44
+ success("Done!")
97
45
  else
98
- error "There was an error installing the Wordless plugin."
46
+ error("There was an error installing and/or activating the Wordless plugin.")
99
47
  end
100
- else
101
- error "Directory '#{plugins_path}' not found."
102
48
  end
103
49
  end
104
50
 
105
- def activate_plugin
106
- info("Activating wordless plugin...")
107
- run_command("wp plugin activate wordless") || error("Cannot activate wordless plugin")
108
- success("Done!")
109
- end
110
-
111
- def activate_theme(name)
112
- info("Activating theme...")
113
- run_command("wp theme activate #{name}") || error("Cannot activate theme '#{name}'")
114
- success("Done!")
115
- end
116
-
117
- def set_permalinks
118
- info("Setting permalinks for wordless...")
119
- run_command("wp rewrite structure /%postname%/") || error("Cannot set permalinks")
120
- success("Done!")
121
- end
122
-
123
51
  def create_theme(name)
124
- at_wordpress_root!
125
-
126
- if File.directory?(themes_path)
127
- if system "php #{File.join(lib_dir, 'theme_builder.php')} #{name}"
128
- success "Created a new Wordless theme in '#{File.join(themes_path, name)}'."
52
+ at_wordpress_root do
53
+ if File.directory?(themes_path)
54
+ if run_command("php #{File.join(lib_dir, 'theme_builder.php')} #{name}")
55
+ success("Created a new Wordless theme in '#{File.join(themes_path, name)}'.")
56
+ else
57
+ error("Couldn't create Wordless theme.")
58
+ end
129
59
  else
130
- error "Couldn't create Wordless theme."
60
+ error("Directory '#{themes_path}' not found.")
131
61
  end
132
- else
133
- error "Directory '#{themes_path}' not found."
134
62
  end
135
63
  end
136
64
 
137
65
  def compile
138
- at_wordpress_root!
139
-
140
- if system "php #{File.join(lib_dir, 'compile_assets.php')}"
141
- success "Compiled static assets."
142
- else
143
- error "Couldn't compile static assets."
66
+ at_wordpress_root do
67
+ if system "php #{File.join(lib_dir, 'compile_assets.php')}"
68
+ success("Compiled static assets.")
69
+ else
70
+ error("Couldn't compile static assets.")
71
+ end
144
72
  end
145
73
  end
146
74
 
147
75
  def clean
148
- at_wordpress_root!
76
+ at_wordpress_root do
77
+ if File.directory?(themes_path)
78
+ static_css = Array(config[:static_css] || Dir['wp-content/themes/*/assets/stylesheets/screen.css'])
79
+ static_js = Array(config[:static_js] || Dir['wp-content/themes/*/assets/javascripts/application.js'])
149
80
 
150
- if File.directory?(themes_path)
151
- static_css = Array(config[:static_css] || Dir['wp-content/themes/*/assets/stylesheets/screen.css'])
152
- static_js = Array(config[:static_js] || Dir['wp-content/themes/*/assets/javascripts/application.js'])
81
+ (static_css + static_js).each do |file|
82
+ FileUtils.rm_f(file) if File.exist?(file)
83
+ end
153
84
 
154
- (static_css + static_js).each do |file|
155
- FileUtils.rm_f(file) if File.exist?(file)
85
+ success("Cleaned static assets.")
86
+ else
87
+ error("Directory '#{themes_path}' not found.")
156
88
  end
157
-
158
- success "Cleaned static assets."
159
- else
160
- error "Directory '#{themes_path}' not found."
161
89
  end
162
90
  end
163
91
 
164
92
  def deploy
165
- at_wordpress_root!
93
+ at_wordpress_root do
94
+ compile if options['refresh']
166
95
 
167
- compile if options['refresh']
96
+ deploy_command = options['command'].presence || config[:deploy_command]
168
97
 
169
- deploy_command = options['command'].presence || config[:deploy_command]
98
+ if deploy_command
99
+ system("#{deploy_command}")
100
+ else
101
+ error("deploy_command not set. Make sure it is included in your Wordfile.")
102
+ end
170
103
 
171
- if deploy_command
172
- system "#{deploy_command}"
173
- else
174
- error "deploy_command not set. Make sure it is included in your Wordfile."
104
+ clean if options['refresh']
175
105
  end
176
-
177
- clean if options['refresh']
178
106
  end
179
107
 
180
108
  private
181
109
 
182
- def start_dir
183
- "."
110
+ DEFAULT_PATHS.each do |type, value|
111
+ define_method "#{type}_path" do
112
+ value
113
+ end
184
114
  end
185
115
 
186
- def at_wordpress_root!
187
- Dir.chdir(wordpress_dir)
116
+ def lib_dir
117
+ @@lib_dir ||= File.expand_path(File.dirname(__FILE__))
188
118
  end
189
119
 
190
- def wordless_plugin_path
191
- File.join(plugins_path, "wordless")
120
+ def wordpress_dir(current_dir = Dir.pwd)
121
+ @wordpress_dir ||= (
122
+ current_dir = File.expand_path(current_dir)
123
+
124
+ if File.exist?(File.join(current_dir, wp_content_path))
125
+ current_dir
126
+ elsif last_dir?(current_dir)
127
+ error("Could not find a valid Wordpress directory")
128
+ else
129
+ wordpress_dir(upper_dir(current_dir))
130
+ end
131
+ )
192
132
  end
193
133
 
194
- def wordless_repo
195
- config[:wordless_repo] || 'git://github.com/welaika/wordless.git'
134
+ def last_dir?(directory)
135
+ directory == "/"
136
+ end
137
+
138
+ def upper_dir(directory)
139
+ File.join(directory, '..')
140
+ end
141
+
142
+ def config
143
+ @@config ||= (
144
+ if File.exist?(wordfile_path)
145
+ YAML::load(File.open(wordfile_path)).symbolize_keys
146
+ else
147
+ {}
148
+ end
149
+ )
196
150
  end
197
151
 
198
- def add_git_repo(repo, destination)
199
- run_command("git clone #{repo} #{destination}")
152
+ def at_wordpress_root
153
+ pwd = Dir.pwd
154
+ Dir.chdir(wordpress_dir)
155
+ begin
156
+ yield
157
+ ensure
158
+ Dir.chdir(pwd)
159
+ end
200
160
  end
201
161
 
202
- def wp_cli_installed?
203
- run_command("which wp")
162
+ def install_wordpress_and_wp_cli(name)
163
+ WordPressTools::CLI.new.invoke('new', [name], options)
204
164
  end
205
165
 
166
+ def activate_theme(name)
167
+ at_wordpress_root do
168
+ info("Activating theme...")
169
+ run_command("wp theme activate #{name}") || error("Cannot activate theme '#{name}'")
170
+ success("Done!")
171
+ end
172
+ end
173
+
174
+ def set_permalinks
175
+ at_wordpress_root do
176
+ info("Setting permalinks for wordless...")
177
+ run_command("wp rewrite structure /%postname%/") || error("Cannot set permalinks")
178
+ success("Done!")
179
+ end
180
+ end
206
181
  end
207
182
  end
208
-
data/wordless.gemspec CHANGED
@@ -26,10 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "compass"
27
27
  spec.add_dependency "coffee-script"
28
28
  spec.add_dependency "yui-compressor"
29
- spec.add_dependency "wordpress_tools", "~> 1.1.1"
29
+ spec.add_dependency "wordpress_tools", "~> 1.1.2"
30
30
 
31
- spec.add_development_dependency "rspec", "< 3.0.0"
32
- spec.add_development_dependency "fakeweb", "~> 1.3"
31
+ spec.add_development_dependency "rspec", "~> 3.2.0"
33
32
  spec.add_development_dependency "pry-byebug", "~> 3.0"
34
33
  spec.add_development_dependency "priscilla", "~> 1.0"
35
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordless
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Étienne Després"
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2015-02-20 00:00:00.000000000 Z
15
+ date: 2015-03-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: thor
@@ -104,42 +104,28 @@ dependencies:
104
104
  requirements:
105
105
  - - "~>"
106
106
  - !ruby/object:Gem::Version
107
- version: 1.1.1
107
+ version: 1.1.2
108
108
  type: :runtime
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
- version: 1.1.1
114
+ version: 1.1.2
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rspec
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - "<"
120
- - !ruby/object:Gem::Version
121
- version: 3.0.0
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - "<"
127
- - !ruby/object:Gem::Version
128
- version: 3.0.0
129
- - !ruby/object:Gem::Dependency
130
- name: fakeweb
131
117
  requirement: !ruby/object:Gem::Requirement
132
118
  requirements:
133
119
  - - "~>"
134
120
  - !ruby/object:Gem::Version
135
- version: '1.3'
121
+ version: 3.2.0
136
122
  type: :development
137
123
  prerelease: false
138
124
  version_requirements: !ruby/object:Gem::Requirement
139
125
  requirements:
140
126
  - - "~>"
141
127
  - !ruby/object:Gem::Version
142
- version: '1.3'
128
+ version: 3.2.0
143
129
  - !ruby/object:Gem::Dependency
144
130
  name: pry-byebug
145
131
  requirement: !ruby/object:Gem::Requirement