pave 0.5.0 → 0.6.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: 73f1328426b5077aeaa1d8f9a7056cb0d23f4966
4
- data.tar.gz: 6d44d7901e194239707394d3c46739a71c358869
3
+ metadata.gz: f7b913d65cca08e6ccdef3280bea1a2189e7be14
4
+ data.tar.gz: 6066f4e6a7b53448d9c3592659aecf2ce925e354
5
5
  SHA512:
6
- metadata.gz: a4cd5bb23917e1b6d991a298409cefbb36e0c649ddb8e9d3bbd50e384e7d0df7e5d7f043b2be73f58d412a213076eb90fef38c8afee1369efe9dff248074272a
7
- data.tar.gz: dce87fdfcb7ef23f116001cde04e2fcb1b134856432dec4462555e7367bfb1120de4a5bb1f270d4dfa2c69c93391dd8060e332ad6b258e4c3ef0ac04fed69406
6
+ metadata.gz: d25936c38deeb4e435975b4e158d5408aeafdc7cb8b8c0e83804d240854837e48639636ea788cae6fb20c1d69ef46b9e2da5d7caf9f71730c0181b706ae2211a
7
+ data.tar.gz: dbfae2536ed7f62cecf071407760d5054466cf8fa2a5700fe39d870a3af0e36d394817466ebc2556d98aa3631f74d424bff61030ce6576209f01019b8c9eddfe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pave (0.4.3999)
4
+ pave (0.6.0)
5
5
  commander (~> 4.1.5)
6
6
 
7
7
  GEM
@@ -9,11 +9,20 @@ GEM
9
9
  specs:
10
10
  commander (4.1.5)
11
11
  highline (~> 1.6.11)
12
+ diff-lcs (1.2.5)
12
13
  highline (1.6.20)
13
- json (1.8.0)
14
+ json (1.8.1)
14
15
  rake (0.9.6)
15
16
  rdoc (4.0.1)
16
17
  json (~> 1.4)
18
+ rspec (2.14.1)
19
+ rspec-core (~> 2.14.0)
20
+ rspec-expectations (~> 2.14.0)
21
+ rspec-mocks (~> 2.14.0)
22
+ rspec-core (2.14.7)
23
+ rspec-expectations (2.14.4)
24
+ diff-lcs (>= 1.1.3, < 2.0)
25
+ rspec-mocks (2.14.4)
17
26
 
18
27
  PLATFORMS
19
28
  ruby
@@ -23,3 +32,4 @@ DEPENDENCIES
23
32
  pave!
24
33
  rake (~> 0.9.2)
25
34
  rdoc
35
+ rspec (~> 2)
data/Rakefile CHANGED
@@ -1,53 +1,11 @@
1
- def dump_load_path
2
- puts $LOAD_PATH.join("\n")
3
- found = nil
4
- $LOAD_PATH.each do |path|
5
- if File.exists?(File.join(path,"rspec"))
6
- puts "Found rspec in #{path}"
7
- if File.exists?(File.join(path,"rspec","core"))
8
- puts "Found core"
9
- if File.exists?(File.join(path,"rspec","core","rake_task"))
10
- puts "Found rake_task"
11
- found = path
12
- else
13
- puts "!! no rake_task"
14
- end
15
- else
16
- puts "!!! no core"
17
- end
18
- end
19
- end
20
- if found.nil?
21
- puts "Didn't find rspec/core/rake_task anywhere"
22
- else
23
- puts "Found in #{path}"
24
- end
25
- end
26
- require "bundler"
27
- require "rake/clean"
28
-
29
- require "rake/testtask"
30
-
31
- require "cucumber"
32
- require "cucumber/rake/task"
33
- gem "rdoc" # we need the installed RDoc gem, not the system one
34
- require "rdoc/task"
35
-
36
- include Rake::DSL
37
-
38
- Bundler::GemHelper.install_tasks
39
-
40
-
41
- Rake::TestTask.new do |t|
42
- t.pattern = "test/tc_*.rb"
43
- end
44
-
45
- Rake::RDocTask.new do |rd|
46
-
47
- rd.main = "README.rdoc"
1
+ require "rspec/core/rake_task"
2
+ require "bundler/gem_tasks"
48
3
 
49
- rd.rdoc_files.include("lib/**/*.rb","bin/**/*")
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.verbose = false
7
+ t.rspec_opts = '--color --order random'
50
8
  end
51
9
 
52
- task :default => [:test,:features]
10
+ task :default => :spec
53
11
 
data/bin/pave CHANGED
@@ -132,11 +132,58 @@ command :"db:dump" do |c|
132
132
  end
133
133
  alias_command :"db:backup", :"db:dump"
134
134
 
135
+ command :"db:remote:dump" do |c|
136
+ c.syntax = "pave db:remote:dump DATABASE"
137
+ c.description = "Create SQL dump of the project's live database."
138
+ c.action do |args|
139
+ name = args.first || "#{File.basename(Dir.pwd)}"
140
+ Pave::Database.new(name).dump_remote
141
+ end
142
+ end
143
+ alias_command :"db:remote:backup", :"db:remote:dump"
144
+
145
+ command :"db:execute" do |c|
146
+ c.syntax = "pave db:execute DATABASE"
147
+ c.description = "Execute SQL dump on the project's database."
148
+ c.action do |args|
149
+ name = args.first || "#{File.basename(Dir.pwd)}"
150
+ Pave::Database.new(name).execute
151
+ end
152
+ end
153
+
154
+ command :"db:remote:execute" do |c|
155
+ c.syntax = "pave db:remote:execute DATABASE"
156
+ c.description = "Execute SQL dump on the project's live database."
157
+ c.action do |args|
158
+ name = args.first || "#{File.basename(Dir.pwd)}"
159
+ Pave::Database.new(name).execute_remote
160
+ end
161
+ end
162
+
163
+ command :"db:download" do |c|
164
+ c.syntax = "pave db:download DATABASE"
165
+ c.description = "Download SQL dump of the project's live database."
166
+ c.action do |args|
167
+ name = args.first || "#{File.basename(Dir.pwd)}"
168
+ Pave::Database.new(name).download
169
+ end
170
+ end
171
+
172
+ command :"db:upload" do |c|
173
+ c.syntax = "pave db:upload DATABASE"
174
+ c.description = "Upload SQL dump of the project's database."
175
+ c.action do |args|
176
+ name = args.first || "#{File.basename(Dir.pwd)}"
177
+ Pave::Database.new(name).upload
178
+ end
179
+ end
180
+
135
181
  command :"db:pull" do |c|
136
182
  c.syntax = "pave db:pull"
137
183
  c.description = "Download the project's live database and replace local database."
138
184
  c.action do |args|
139
- say "`db:pull` command not implemented yet."
185
+ name = args.first || "#{File.basename(Dir.pwd)}"
186
+ Pave::Database.new(name).pull
140
187
  end
141
188
  end
142
189
 
@@ -144,7 +191,8 @@ command :"db:push" do |c|
144
191
  c.syntax = "pave db:push"
145
192
  c.description = "Upload the project's local database and replace the live database."
146
193
  c.action do |args|
147
- say "`db:push` command not implemented yet."
194
+ name = args.first || "#{File.basename(Dir.pwd)}"
195
+ Pave::Database.new(name).push
148
196
  end
149
197
  end
150
198
 
@@ -172,7 +220,7 @@ command :"deploy" do |c|
172
220
  c.action do |args|
173
221
  remote = args[0] || "live"
174
222
  branch = args[1] || "master"
175
- Pave::Deploy.new.deploy(remote, branch)
223
+ Pave::Remote.deploy(remote, branch)
176
224
  end
177
225
  end
178
226
 
@@ -180,6 +228,6 @@ command :"deploy:setup" do |c|
180
228
  c.syntax = "pave deploy:setup"
181
229
  c.description = "Setup deployment via git to web server."
182
230
  c.action do
183
- Pave::Deploy.new.setup
231
+ Pave::Remote.setup
184
232
  end
185
233
  end
data/lib/pave/database.rb CHANGED
@@ -19,6 +19,28 @@ module Pave
19
19
  sh "mysql -uroot -e 'CREATE DATABASE #{name}'"
20
20
  end
21
21
 
22
+ def remote_db
23
+ require 'json'
24
+ live_domain = shell("php -r \"error_reporting(0);require('./config/site.php');echo LIVE_DOMAIN;\"").output
25
+ db_json = shell("php -r \"error_reporting(0);"\
26
+ "\\$_SERVER = array('HTTP_HOST' => '#{live_domain}');"\
27
+ "require('./config/site.php');"\
28
+ "echo json_encode("\
29
+ "array('host' => DB_SERVER,"\
30
+ "'user' => DB_USERNAME,"\
31
+ "'pass' => DB_PASSWORD,"\
32
+ "'name' => DB_DATABASE));\"").output
33
+ JSON.parse(db_json)
34
+ end
35
+
36
+ def remote_url(remote="live")
37
+ "#{Pave::Remote.server(remote)}:#{Pave::Remote.directory(remote)}"
38
+ end
39
+
40
+ def dump_file
41
+ "#{Time.now.strftime("%Y-%m-%d")}-#{name}.sql.gz"
42
+ end
43
+
22
44
  def dump
23
45
  if !File.directory?('db')
24
46
  sh "mkdir ./db"
@@ -26,19 +48,54 @@ module Pave
26
48
  sh "echo 'deny from all' > ./db/.htaccess"
27
49
  sh "sudo chmod -R 700 ./db/"
28
50
  end
29
- dbname = Time.now.strftime("%Y-%m-%d-%H%M") + "-" + name + ".sql.gz"
30
- say "Creating dump of #{name} at #{Dir.pwd}/db/#{dbname}"
31
- sh "mysqldump -uroot #{name} | gzip > ./db/#{dbname}"
32
- say "Dump complete."
51
+ say "Creating dump of #{name} at #{Dir.pwd}/db/#{dump_file}"
52
+ sh "mysqldump -uroot #{name} | gzip > ./db/#{dump_file}"
33
53
  end
34
54
 
35
- def download(host, user, password)
36
- # Download the project's live database and replace local database.
37
- # sh "mysqldump -h#{host} -u#{user} -p#{password} #{name} | mysql -uroot #{name}"
55
+ def dump_remote(remote="live")
56
+ server = Pave::Remote.server(remote)
57
+ directory = Pave::Remote.directory(remote)
58
+ db = remote_db
59
+ say "Remotely creating dump of #{db['name']} at #{server}:#{directory}/db/#{dump_file}"
60
+ sh "ssh #{server} \"cd #{directory}/db; mysqldump -u#{db['user']} -p#{db['pass']} #{db['name']} | gzip > #{dump_file}\""
61
+ end
62
+
63
+ def execute
64
+ say "Executing #{dump_file} on #{name}"
65
+ sh "gzip -dc ./db/#{dump_file} | mysql -uroot #{name}"
38
66
  end
39
67
 
40
- def upload
68
+ def execute_remote(remote="live")
69
+ server = Pave::Remote.server(remote)
70
+ directory = Pave::Remote.directory(remote)
71
+ say "Remotely executing #{dump_file} on live #{db['name']}"
72
+ sh "ssh #{server} \"cd #{directory}/db; gzip -dc #{dump_file} | mysql -u#{db['user']} -p#{db['pass']} #{db['name']}\""
73
+ end
74
+
75
+ def upload(remote="live")
76
+ # Upload the project's local database dump to remotes db directory.
77
+ say "Uploading SQL dump to #{remote_url}/db/#{dump_file}"
78
+ sh "scp ./db/#{dump_file} #{remote_url}/db"
79
+ end
80
+
81
+ def download(remote="live")
82
+ # Download the project's live database dump to local db directory.
83
+ say "Downloading SQL dump from #{remote_url}/db/#{dump_file}"
84
+ sh "scp #{remote_url}/db/#{dump_file} ./db"
85
+ end
86
+
87
+ def push(remote="live")
41
88
  # Upload the project's local database and replace the live database.
89
+ dump
90
+ upload(remote)
91
+ execute_remote(remote)
92
+ end
93
+
94
+ def pull(remote="live")
95
+ # Download the project's live database and replace local database.
96
+ dump_remote(remote)
97
+ download(remote)
98
+ execute
42
99
  end
43
100
  end
44
101
  end
@@ -1,8 +1,8 @@
1
1
  module Pave
2
- class Deploy
2
+ class Remote
3
3
  include Pave::Shell
4
4
 
5
- def setup
5
+ def self.setup
6
6
  server = ask "Username and hostname of the remote server (e.g. user@server.com): "
7
7
  folder = ask "Name of the remote directory (e.g. ~/webapps/appname/): "
8
8
  remote = ask "Desired git remote name (e.g. live): "
@@ -17,9 +17,22 @@ module Pave
17
17
  puts "Finished! You may now run `pave deploy` to deploy your application."
18
18
  end
19
19
 
20
- def deploy(remote="live", branch="master")
20
+ def self.deploy(remote="live", branch="master")
21
21
  sh "git push #{remote} #{branch}"
22
22
  end
23
+
24
+ def self.url(remote="live")
25
+ remotes = shell("git remote -v").output
26
+ remotes.match(/#{remote}\s+(.*)\s+\(push\)/)[1]
27
+ end
28
+
29
+ def self.server(remote="live")
30
+ self.url(remote).split(":").first
31
+ end
32
+
33
+ def self.directory(remote="live")
34
+ self.url(remote).split(":").last.gsub("/deploy.git", "")
35
+ end
23
36
  end
24
37
  end
25
38
 
data/lib/pave/shell.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  module Pave
2
2
  module Shell
3
+ def Shell.included base
4
+ base.extend Shell
5
+ end
6
+
3
7
  def shell(command)
4
8
  output = `#{command}`
5
9
  Struct.new(:status, :output).new($?, output)
data/lib/pave/theme.rb CHANGED
@@ -39,7 +39,7 @@ module Pave
39
39
  say "Installing Bitters"
40
40
  sh "gem install bitters"
41
41
  sh "cd themes/#{self.name}/css/ && bitters install && cd -"
42
- end
42
+ end
43
43
 
44
44
  def copy_theme
45
45
  sh "cp -a #{Pave.template_folder}/themes/blank #{Dir.pwd}/themes/#{self.name}"
@@ -59,4 +59,4 @@ module Pave
59
59
  end
60
60
 
61
61
  end
62
- end
62
+ end
data/lib/pave/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pave
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/pave.rb CHANGED
@@ -4,8 +4,8 @@ require "pave/shell"
4
4
  require "pave/concrete"
5
5
  require "pave/database"
6
6
  require "pave/virtual_host"
7
+ require "pave/remote"
7
8
  require "pave/theme"
8
- require "pave/deploy"
9
9
 
10
10
  module Pave
11
11
  def update
@@ -15,9 +15,8 @@ module Pave
15
15
  end
16
16
  module_function :update
17
17
 
18
- def template_folder
18
+ def template_folder
19
19
  script = File.join(File.expand_path("../", File.dirname(__FILE__)), "templates")
20
- end
20
+ end
21
21
  module_function :template_folder
22
-
23
22
  end
data/pave.gemspec CHANGED
@@ -15,12 +15,12 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test)/})
18
+ spec.test_files = spec.files.grep(%r{^(spec)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency("bundler", "~> 1.3")
22
- spec.add_development_dependency("rake")
23
22
  spec.add_development_dependency("rdoc")
24
23
  spec.add_development_dependency("rake", "~> 0.9.2")
24
+ spec.add_development_dependency("rspec", "~> 2")
25
25
  spec.add_dependency("commander", "~> 4.1.5")
26
26
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pave::Concrete do
4
+ let(:subject) { Pave::Concrete.new("test") }
5
+
6
+ before :each do
7
+ mock_terminal
8
+ end
9
+
10
+ describe '#setup' do
11
+ it "returns a string with /templates" do
12
+ subject.setup.should be_kind_of(Pave::Concrete)
13
+ end
14
+ end
15
+
16
+ end
File without changes
data/spec/pave_spec.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pave do
4
+
5
+ before :each do
6
+ mock_terminal
7
+ end
8
+
9
+ describe '.template_folder' do
10
+ it "returns a string with /templates" do
11
+ Pave.template_folder.should include("/templates")
12
+ end
13
+ end
14
+
15
+ end
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'stringio'
3
+
4
+ # Unshift so that local files load instead of something in gems
5
+ $:.unshift File.dirname(__FILE__) + '/../lib'
6
+
7
+ require 'pave'
8
+
9
+ # Mock terminal IO streams so we can spec against them
10
+
11
+ def mock_terminal
12
+ @input = StringIO.new
13
+ @output = StringIO.new
14
+ $terminal = HighLine.new @input, @output
15
+ end
16
+
File without changes
@@ -1,2 +1,2 @@
1
1
  @import 'bourbon/_bourbon';
2
- @import 'neat/_neat';
2
+ @import 'neat/_neat';
@@ -14,7 +14,7 @@
14
14
  <![endif]-->
15
15
  </head>
16
16
 
17
- <body class="<?= $c->getCollectionTypeHandle(); ?>">
17
+ <body class="<?= $c->getCollectionTypeHandle(); ?>">
18
18
 
19
19
 
20
20
  <!-- BLOCK EXAMPLE -->
@@ -33,4 +33,4 @@
33
33
  $nav->controller->displaySubPageLevels = 'custom';
34
34
  $nav->controller->displaySubPageLevelsNum = 1;
35
35
  $nav->render('templates/header_menu');
36
- ?>
36
+ ?>
@@ -0,0 +1,8 @@
1
+ <?
2
+ function editmode() {
3
+ global $c;
4
+ if ($c->isEditMode()) {
5
+ echo "editMode";
6
+ }
7
+ }
8
+ ?>
@@ -1,7 +1,3 @@
1
1
  $(document).ready(function(){
2
2
 
3
-
4
-
5
-
6
-
7
- });
3
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamon Holmgren
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-14 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -26,7 +26,7 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: rdoc
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '>='
@@ -40,33 +40,33 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rdoc
43
+ name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 0.9.2
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 0.9.2
56
56
  - !ruby/object:Gem::Dependency
57
- name: rake
57
+ name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 0.9.2
62
+ version: '2'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 0.9.2
69
+ version: '2'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: commander
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -101,23 +101,30 @@ files:
101
101
  - lib/pave.rb
102
102
  - lib/pave/concrete.rb
103
103
  - lib/pave/database.rb
104
- - lib/pave/deploy.rb
104
+ - lib/pave/remote.rb
105
105
  - lib/pave/shell.rb
106
106
  - lib/pave/theme.rb
107
107
  - lib/pave/version.rb
108
108
  - lib/pave/virtual_host.rb
109
109
  - pave.gemspec
110
110
  - resources/deploy.sh
111
+ - spec/concrete_spec.rb
112
+ - spec/database_spec.rb
113
+ - spec/pave_spec.rb
114
+ - spec/remote_spec.rb
115
+ - spec/shell_spec.rb
116
+ - spec/spec_helper.rb
117
+ - spec/virtual_host_spec.rb
111
118
  - templates/themes/blank/css/styles.scss
112
119
  - templates/themes/blank/default.php
113
120
  - templates/themes/blank/description.txt
114
121
  - templates/themes/blank/elements/footer.php
115
122
  - templates/themes/blank/elements/header.php
123
+ - templates/themes/blank/includes/functions.php
116
124
  - templates/themes/blank/includes/view_helpers.php
117
125
  - templates/themes/blank/js/scripts.js
118
126
  - templates/themes/blank/thumbnail.png
119
127
  - templates/themes/blank/view.php
120
- - test/pave_test.rb
121
128
  homepage: https://github.com/jamonholmgren/pave
122
129
  licenses:
123
130
  - MIT
@@ -143,4 +150,10 @@ signing_key:
143
150
  specification_version: 4
144
151
  summary: Provides a set of command line tools for Concrete5.
145
152
  test_files:
146
- - test/pave_test.rb
153
+ - spec/concrete_spec.rb
154
+ - spec/database_spec.rb
155
+ - spec/pave_spec.rb
156
+ - spec/remote_spec.rb
157
+ - spec/shell_spec.rb
158
+ - spec/spec_helper.rb
159
+ - spec/virtual_host_spec.rb
data/test/pave_test.rb DELETED
@@ -1,7 +0,0 @@
1
- require "test/unit"
2
-
3
- class PaveTest < Test::Unit::TestCase
4
- def test_is_module
5
- assert Pave.is_a?(Module)
6
- end
7
- end