utopia 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Rakefile +5 -1
- data/bin/utopia +2 -197
- data/lib/utopia/command.rb +265 -0
- data/lib/utopia/content/node.rb +0 -9
- data/lib/utopia/version.rb +1 -1
- data/spec/utopia/performance_spec.rb +4 -0
- data/spec/utopia/setup_spec.rb +7 -4
- data/utopia.gemspec +4 -2
- metadata +27 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5843f20c3064a8be2f35b08409f491b88985dc1b
|
4
|
+
data.tar.gz: 61bcbce6bc7bef8c00f42f19ea7f28ce56c53a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a6ed4e6b754a1520e9b3cda3ce28c3e86ee29ecef62fdacd19cbda34e310328bcb0b92af0b9098db98e61a7c57c0bef51a8849332794fdb64b014d4ee6ce05
|
7
|
+
data.tar.gz: a5dda959e517da9e6f58503161303cee85b3915b0c73df315d4bb307b2f6fc8ba4b0e38d66efbe2a23febc915243d4e0cc4f49779e7c88049061f43b1e22fced
|
data/.travis.yml
CHANGED
@@ -2,8 +2,8 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
before_install:
|
4
4
|
# For testing purposes:
|
5
|
-
- git config --global user.email "
|
6
|
-
- git config --global user.name "
|
5
|
+
- git config --global user.email "samuel@oriontransfer.net"
|
6
|
+
- git config --global user.name "Samuel Williams"
|
7
7
|
rvm:
|
8
8
|
- 2.1.8
|
9
9
|
- 2.2.4
|
data/Rakefile
CHANGED
@@ -2,7 +2,11 @@ require "bundler/gem_tasks"
|
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
|
-
|
5
|
+
begin
|
6
|
+
require('simplecov/version')
|
7
|
+
task.rspec_opts = %w{--require simplecov} if ENV['COVERAGE']
|
8
|
+
rescue LoadError
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
task :default => :spec
|
data/bin/utopia
CHANGED
@@ -20,201 +20,6 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
-
|
23
|
+
require 'utopia/command'
|
24
24
|
|
25
|
-
|
26
|
-
require 'fileutils'
|
27
|
-
require 'find'
|
28
|
-
|
29
|
-
$app = Rake.application = Rake::Application.new
|
30
|
-
$app.init(File.basename($0))
|
31
|
-
|
32
|
-
Rake::TaskManager.record_task_metadata = true
|
33
|
-
|
34
|
-
verbose(false)
|
35
|
-
|
36
|
-
module Setup
|
37
|
-
BASE = File.expand_path("../setup", __dir__)
|
38
|
-
|
39
|
-
module Site
|
40
|
-
CONFIGURATION_FILES = ['config.ru', 'Gemfile', 'Rakefile']
|
41
|
-
|
42
|
-
DIRECTORIES = ["cache", "cache/meta", "cache/body", "lib", "pages", "public", "tmp"]
|
43
|
-
SYMLINKS = {"public/_static" => "../pages/_static"}
|
44
|
-
|
45
|
-
# Removed during upgrade process
|
46
|
-
OLD_DIRECTORIES = ["access_log"]
|
47
|
-
|
48
|
-
ROOT = File.join(BASE, 'site')
|
49
|
-
end
|
50
|
-
|
51
|
-
module Server
|
52
|
-
ROOT = File.join(BASE, 'server')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "Create a local utopia instance which includes a basic website template.\n" +
|
57
|
-
"Uses current working directory or path argument if provided."
|
58
|
-
task :create do
|
59
|
-
destination_root = File.expand_path(ARGV.last || '.', Dir.getwd)
|
60
|
-
|
61
|
-
$stderr.puts "Setting up initial site in #{destination_root} for Utopia v#{Utopia::VERSION}..."
|
62
|
-
|
63
|
-
Setup::Site::DIRECTORIES.each do |directory|
|
64
|
-
FileUtils.mkdir_p(File.join(destination_root, directory))
|
65
|
-
end
|
66
|
-
|
67
|
-
Find.find(Setup::Site::ROOT) do |source_path|
|
68
|
-
# What is this doing?
|
69
|
-
destination_path = File.join(destination_root, source_path[Setup::Site::ROOT.size..-1])
|
70
|
-
|
71
|
-
if File.directory?(source_path)
|
72
|
-
FileUtils.mkdir_p(destination_path)
|
73
|
-
else
|
74
|
-
unless File.exist? destination_path
|
75
|
-
FileUtils.copy_entry(source_path, destination_path)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
Setup::Site::SYMLINKS.each do |path, target|
|
81
|
-
FileUtils.ln_s(target, File.join(destination_root, path), force: true)
|
82
|
-
end
|
83
|
-
|
84
|
-
Setup::Site::CONFIGURATION_FILES.each do |configuration_file|
|
85
|
-
destination_path = File.join(destination_root, configuration_file)
|
86
|
-
|
87
|
-
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
88
|
-
|
89
|
-
File.open(destination_path, "w") { |file| file.write(buffer) }
|
90
|
-
end
|
91
|
-
|
92
|
-
Dir.chdir(destination_root) do
|
93
|
-
puts "Setting up site in #{destination_root}..."
|
94
|
-
|
95
|
-
if `which bundle`.strip != ''
|
96
|
-
puts "Generating initial package list with bundle..."
|
97
|
-
sh("bundle", "install", "--quiet")
|
98
|
-
end
|
99
|
-
|
100
|
-
if `which git`.strip == ""
|
101
|
-
$stderr.puts "Now is a good time to learn about git: http://git-scm.com/"
|
102
|
-
elsif !File.exist?('.git')
|
103
|
-
puts "Setting up git repository..."
|
104
|
-
sh("git", "init")
|
105
|
-
sh("git", "add", ".")
|
106
|
-
sh("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.")
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
name = `git config user.name || whoami`.chomp
|
111
|
-
|
112
|
-
puts
|
113
|
-
puts " #{name},".ljust(78)
|
114
|
-
puts "Thank you for using Utopia!".center(78)
|
115
|
-
puts "We sincerely hope that Utopia helps to".center(78)
|
116
|
-
puts "make your life easier and more enjoyable.".center(78)
|
117
|
-
puts ""
|
118
|
-
puts "To start the development server, run:".center(78)
|
119
|
-
puts "rake server".center(78)
|
120
|
-
puts ""
|
121
|
-
puts "For extreme productivity, please consult the online documentation".center(78)
|
122
|
-
puts "https://github.com/ioquatix/utopia".center(78)
|
123
|
-
puts " ~ Samuel. ".rjust(78)
|
124
|
-
end
|
125
|
-
|
126
|
-
desc "Upgrade an existing site to use the latest configuration files from the template.\n" +
|
127
|
-
"Uses current working directory or path argument if provided."
|
128
|
-
task :upgrade do
|
129
|
-
destination_root = File.expand_path(ARGV.last || '.', Dir.getwd)
|
130
|
-
branch_name = "utopia-upgrade-#{Utopia::VERSION}"
|
131
|
-
|
132
|
-
$stderr.puts "Upgrading #{destination_root}..."
|
133
|
-
|
134
|
-
Dir.chdir(destination_root) do
|
135
|
-
sh('git', 'checkout', '-b', branch_name)
|
136
|
-
end
|
137
|
-
|
138
|
-
Setup::Site::DIRECTORIES.each do |directory|
|
139
|
-
FileUtils.mkdir_p(File.join(destination_root, directory))
|
140
|
-
end
|
141
|
-
|
142
|
-
Setup::Site::OLD_DIRECTORIES.each do |directory|
|
143
|
-
path = File.join(destination_root, directory)
|
144
|
-
$stderr.puts "\tRemoving #{path}..."
|
145
|
-
FileUtils.rm_rf(path)
|
146
|
-
end
|
147
|
-
|
148
|
-
Setup::Site::SYMLINKS.each do |path, target|
|
149
|
-
FileUtils.ln_s(target, File.join(destination_root, path), force: true)
|
150
|
-
end
|
151
|
-
|
152
|
-
Setup::Site::CONFIGURATION_FILES.each do |configuration_file|
|
153
|
-
source_path = File.join(Setup::Site::ROOT, configuration_file)
|
154
|
-
destination_path = File.join(destination_root, configuration_file)
|
155
|
-
|
156
|
-
$stderr.puts "Updating #{destination_path}..."
|
157
|
-
|
158
|
-
FileUtils.copy_entry(source_path, destination_path)
|
159
|
-
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
160
|
-
File.open(destination_path, "w") { |file| file.write(buffer) }
|
161
|
-
end
|
162
|
-
|
163
|
-
begin
|
164
|
-
Dir.chdir(destination_root) do
|
165
|
-
# Stage any files that have been changed or removed:
|
166
|
-
sh("git", "add", "-u")
|
167
|
-
|
168
|
-
# Stage any new files that we have explicitly added:
|
169
|
-
sh("git", "add", *Setup::Site::CONFIGURATION_FILES, *Setup::Site::SYMLINKS.keys)
|
170
|
-
|
171
|
-
# Commit all changes:
|
172
|
-
sh("git", "commit", "-m", "Upgrade to utopia #{Utopia::VERSION}.")
|
173
|
-
|
174
|
-
# Checkout master..
|
175
|
-
sh("git", "checkout", "master")
|
176
|
-
|
177
|
-
# and merge:
|
178
|
-
sh("git", "merge", "--no-commit", "--no-ff", branch_name)
|
179
|
-
end
|
180
|
-
rescue RuntimeError
|
181
|
-
$stderr.puts "** Detected error with upgrade, reverting changes. Some new files may still exist in tree. **"
|
182
|
-
|
183
|
-
sh("git", "checkout", "master")
|
184
|
-
sh("git", "branch", "-d", branch_name)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
namespace :server do
|
189
|
-
desc "Create a remote utopia instance suitable for deployment using git.\n" +
|
190
|
-
"Uses current working directory or path argument if provided."
|
191
|
-
task :create do
|
192
|
-
destination_root = File.expand_path(ARGV.last || '.', Dir.getwd)
|
193
|
-
|
194
|
-
FileUtils.mkdir_p File.join(destination_root, "public")
|
195
|
-
FileUtils.mkdir_p File.join(destination_root, "tmp")
|
196
|
-
|
197
|
-
Dir.chdir(destination_root) do
|
198
|
-
# Shared allows multiple users to access the site with the same group:
|
199
|
-
sh("git", "init", "--shared")
|
200
|
-
sh("git", "config", "receive.denyCurrentBranch", "ignore")
|
201
|
-
sh("git", "config", "core.worktree", destination_root)
|
202
|
-
|
203
|
-
sh("cp", "-r", File.join(Setup::Server::ROOT, 'git', 'hooks'), File.join(destination_root, '.git'))
|
204
|
-
end
|
205
|
-
|
206
|
-
hostname = `hostname`.chomp
|
207
|
-
puts "Now add the git remote to your local repository:\n\tgit remote add production ssh://#{hostname}#{destination_root}"
|
208
|
-
puts "Then push to it:\n\tgit push --set-upstream production master"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
task :help do
|
213
|
-
$app.options.show_tasks = :describe
|
214
|
-
$app.options.show_task_pattern = Regexp.new('')
|
215
|
-
$app.display_tasks_and_comments
|
216
|
-
end
|
217
|
-
|
218
|
-
task :default => :help
|
219
|
-
|
220
|
-
$app.top_level
|
25
|
+
Utopia::Command::Top.parse(ARGV).invoke
|
@@ -0,0 +1,265 @@
|
|
1
|
+
# Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative 'version'
|
22
|
+
|
23
|
+
require 'fileutils'
|
24
|
+
require 'find'
|
25
|
+
|
26
|
+
require 'samovar'
|
27
|
+
|
28
|
+
module Utopia
|
29
|
+
module Command
|
30
|
+
module Setup
|
31
|
+
# This path must point to utopia/setup in the gem source.
|
32
|
+
BASE = File.expand_path("../../setup", __dir__)
|
33
|
+
|
34
|
+
module Site
|
35
|
+
CONFIGURATION_FILES = ['config.ru', 'Gemfile', 'Rakefile']
|
36
|
+
|
37
|
+
DIRECTORIES = ["cache", "cache/meta", "cache/body", "lib", "pages", "public", "tmp"]
|
38
|
+
SYMLINKS = {"public/_static" => "../pages/_static"}
|
39
|
+
|
40
|
+
# Removed during upgrade process
|
41
|
+
OLD_DIRECTORIES = ["access_log"]
|
42
|
+
|
43
|
+
ROOT = File.join(BASE, 'site')
|
44
|
+
end
|
45
|
+
|
46
|
+
module Server
|
47
|
+
ROOT = File.join(BASE, 'server')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Server < Samovar::Command
|
52
|
+
class Create < Samovar::Command
|
53
|
+
self.description = "Create a remote Utopia website suitable for deployment using git."
|
54
|
+
|
55
|
+
def invoke(parent)
|
56
|
+
destination_root = parent.root
|
57
|
+
|
58
|
+
FileUtils.mkdir_p File.join(destination_root, "public")
|
59
|
+
FileUtils.mkdir_p File.join(destination_root, "tmp")
|
60
|
+
|
61
|
+
Dir.chdir(destination_root) do
|
62
|
+
# Shared allows multiple users to access the site with the same group:
|
63
|
+
system("git", "init", "--shared")
|
64
|
+
system("git", "config", "receive.denyCurrentBranch", "ignore")
|
65
|
+
system("git", "config", "core.worktree", destination_root)
|
66
|
+
|
67
|
+
system("cp", "-r", File.join(Setup::Server::ROOT, 'git', 'hooks'), File.join(destination_root, '.git'))
|
68
|
+
end
|
69
|
+
|
70
|
+
hostname = `hostname`.chomp
|
71
|
+
puts "Now add the git remote to your local repository:\n\tgit remote add production ssh://#{hostname}#{destination_root}"
|
72
|
+
puts "Then push to it:\n\tgit push --set-upstream production master"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
self.description = "Manage server deployments."
|
77
|
+
|
78
|
+
nested '<command>',
|
79
|
+
'create' => Create
|
80
|
+
|
81
|
+
def invoke(parent)
|
82
|
+
@command.invoke(parent)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class Site < Samovar::Command
|
87
|
+
class Create < Samovar::Command
|
88
|
+
self.description = "Create a new local Utopia website using the default template."
|
89
|
+
# self.example = "utopia --in www.example.com site create"
|
90
|
+
|
91
|
+
def invoke(parent)
|
92
|
+
destination_root = parent.root
|
93
|
+
|
94
|
+
$stderr.puts "Setting up initial site in #{destination_root} for Utopia v#{Utopia::VERSION}..."
|
95
|
+
|
96
|
+
Setup::Site::DIRECTORIES.each do |directory|
|
97
|
+
FileUtils.mkdir_p(File.join(destination_root, directory))
|
98
|
+
end
|
99
|
+
|
100
|
+
Find.find(Setup::Site::ROOT) do |source_path|
|
101
|
+
# What is this doing?
|
102
|
+
destination_path = File.join(destination_root, source_path[Setup::Site::ROOT.size..-1])
|
103
|
+
|
104
|
+
if File.directory?(source_path)
|
105
|
+
FileUtils.mkdir_p(destination_path)
|
106
|
+
else
|
107
|
+
unless File.exist? destination_path
|
108
|
+
FileUtils.copy_entry(source_path, destination_path)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
Setup::Site::SYMLINKS.each do |path, target|
|
114
|
+
FileUtils.ln_s(target, File.join(destination_root, path), force: true)
|
115
|
+
end
|
116
|
+
|
117
|
+
Setup::Site::CONFIGURATION_FILES.each do |configuration_file|
|
118
|
+
destination_path = File.join(destination_root, configuration_file)
|
119
|
+
|
120
|
+
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
121
|
+
|
122
|
+
File.open(destination_path, "w") { |file| file.write(buffer) }
|
123
|
+
end
|
124
|
+
|
125
|
+
Dir.chdir(destination_root) do
|
126
|
+
puts "Setting up site in #{destination_root}..."
|
127
|
+
|
128
|
+
if `which bundle`.strip != ''
|
129
|
+
puts "Generating initial package list with bundle..."
|
130
|
+
system("bundle", "install")
|
131
|
+
end
|
132
|
+
|
133
|
+
if `which git`.strip == ""
|
134
|
+
$stderr.puts "Now is a good time to learn about git: http://git-scm.com/"
|
135
|
+
elsif !File.exist?('.git')
|
136
|
+
puts "Setting up git repository..."
|
137
|
+
system("git", "init")
|
138
|
+
system("git", "add", ".")
|
139
|
+
system("git", "commit", "-q", "-m", "Initial Utopia v#{Utopia::VERSION} site.")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
name = `git config user.name || whoami`.chomp
|
144
|
+
|
145
|
+
puts
|
146
|
+
puts " #{name},".ljust(78)
|
147
|
+
puts "Thank you for using Utopia!".center(78)
|
148
|
+
puts "We sincerely hope that Utopia helps to".center(78)
|
149
|
+
puts "make your life easier and more enjoyable.".center(78)
|
150
|
+
puts ""
|
151
|
+
puts "To start the development server, run:".center(78)
|
152
|
+
puts "rake server".center(78)
|
153
|
+
puts ""
|
154
|
+
puts "For extreme productivity, please consult the online documentation".center(78)
|
155
|
+
puts "https://github.com/ioquatix/utopia".center(78)
|
156
|
+
puts " ~ Samuel. ".rjust(78)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class Update < Samovar::Command
|
161
|
+
self.description = "Upgrade an existing site to use the latest configuration files from the template."
|
162
|
+
|
163
|
+
def invoke(parent)
|
164
|
+
destination_root = parent.root
|
165
|
+
branch_name = "utopia-upgrade-#{Utopia::VERSION}"
|
166
|
+
|
167
|
+
$stderr.puts "Upgrading #{destination_root}..."
|
168
|
+
|
169
|
+
Dir.chdir(destination_root) do
|
170
|
+
system('git', 'checkout', '-b', branch_name)
|
171
|
+
end
|
172
|
+
|
173
|
+
Setup::Site::DIRECTORIES.each do |directory|
|
174
|
+
FileUtils.mkdir_p(File.join(destination_root, directory))
|
175
|
+
end
|
176
|
+
|
177
|
+
Setup::Site::OLD_DIRECTORIES.each do |directory|
|
178
|
+
path = File.join(destination_root, directory)
|
179
|
+
$stderr.puts "\tRemoving #{path}..."
|
180
|
+
FileUtils.rm_rf(path)
|
181
|
+
end
|
182
|
+
|
183
|
+
Setup::Site::SYMLINKS.each do |path, target|
|
184
|
+
FileUtils.ln_s(target, File.join(destination_root, path), force: true)
|
185
|
+
end
|
186
|
+
|
187
|
+
Setup::Site::CONFIGURATION_FILES.each do |configuration_file|
|
188
|
+
source_path = File.join(Setup::Site::ROOT, configuration_file)
|
189
|
+
destination_path = File.join(destination_root, configuration_file)
|
190
|
+
|
191
|
+
$stderr.puts "Updating #{destination_path}..."
|
192
|
+
|
193
|
+
FileUtils.copy_entry(source_path, destination_path)
|
194
|
+
buffer = File.read(destination_path).gsub('$UTOPIA_VERSION', Utopia::VERSION)
|
195
|
+
File.open(destination_path, "w") { |file| file.write(buffer) }
|
196
|
+
end
|
197
|
+
|
198
|
+
begin
|
199
|
+
Dir.chdir(destination_root) do
|
200
|
+
# Stage any files that have been changed or removed:
|
201
|
+
system("git", "add", "-u")
|
202
|
+
|
203
|
+
# Stage any new files that we have explicitly added:
|
204
|
+
system("git", "add", *Setup::Site::CONFIGURATION_FILES, *Setup::Site::SYMLINKS.keys)
|
205
|
+
|
206
|
+
# Commit all changes:
|
207
|
+
system("git", "commit", "-m", "Upgrade to utopia #{Utopia::VERSION}.")
|
208
|
+
|
209
|
+
# Checkout master..
|
210
|
+
system("git", "checkout", "master")
|
211
|
+
|
212
|
+
# and merge:
|
213
|
+
system("git", "merge", "--no-commit", "--no-ff", branch_name)
|
214
|
+
end
|
215
|
+
rescue RuntimeError
|
216
|
+
$stderr.puts "** Detected error with upgrade, reverting changes. Some new files may still exist in tree. **"
|
217
|
+
|
218
|
+
system("git", "checkout", "master")
|
219
|
+
system("git", "branch", "-d", branch_name)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
nested '<command>',
|
225
|
+
'create' => Create,
|
226
|
+
'update' => Update
|
227
|
+
|
228
|
+
self.description = "Manage local utopia sites."
|
229
|
+
|
230
|
+
def invoke(parent)
|
231
|
+
@command.invoke(parent)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
class Top < Samovar::Command
|
236
|
+
self.description = "A website development and deployment framework."
|
237
|
+
|
238
|
+
options do
|
239
|
+
option '-i/--in/--root <path>', "Work in the given root directory."
|
240
|
+
option '-h/--help', "Print out help information."
|
241
|
+
option '-v/--version', "Print out the application version."
|
242
|
+
end
|
243
|
+
|
244
|
+
nested '<command>',
|
245
|
+
'site' => Site,
|
246
|
+
'server' => Server
|
247
|
+
|
248
|
+
def root
|
249
|
+
@options[:root] || Dir.getwd
|
250
|
+
end
|
251
|
+
|
252
|
+
def invoke(program_name: File.basename($0))
|
253
|
+
if @options[:version]
|
254
|
+
puts "utopia v#{Teapot::VERSION}"
|
255
|
+
elsif @options[:help] or @command.nil?
|
256
|
+
print_usage(program_name)
|
257
|
+
else
|
258
|
+
track_time do
|
259
|
+
@command.invoke(self)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
data/lib/utopia/content/node.rb
CHANGED
@@ -124,15 +124,6 @@ module Utopia
|
|
124
124
|
|
125
125
|
# This is a special context in which a limited set of well defined methods are exposed in the content view.
|
126
126
|
Node::Context = Struct.new(:transaction, :state) do
|
127
|
-
def initialize(transaction, state)
|
128
|
-
# We expose all attributes as instance variables within the context:
|
129
|
-
state.attributes.each do |key, value|
|
130
|
-
self.instance_variable_set("@#{key}".to_sym, value)
|
131
|
-
end
|
132
|
-
|
133
|
-
super
|
134
|
-
end
|
135
|
-
|
136
127
|
def partial(*args, &block)
|
137
128
|
if block_given?
|
138
129
|
state.defer(&block)
|
data/lib/utopia/version.rb
CHANGED
@@ -30,6 +30,10 @@ RSpec.describe "Utopia Performance" do
|
|
30
30
|
if defined? Benchmark
|
31
31
|
def benchmark(name = nil)
|
32
32
|
Benchmark.ips do |benchmark|
|
33
|
+
# Collect more data for benchmark:
|
34
|
+
benchmark.time = 20
|
35
|
+
benchmark.warmup = 10
|
36
|
+
|
33
37
|
benchmark.report(name) do |i|
|
34
38
|
yield i
|
35
39
|
end
|
data/spec/utopia/setup_spec.rb
CHANGED
@@ -30,6 +30,9 @@ RSpec.describe "utopia executable" do
|
|
30
30
|
ENV.delete 'BUNDLE_BIN_PATH'
|
31
31
|
ENV.delete 'BUNDLE_GEMFILE'
|
32
32
|
ENV.delete 'RUBYOPT'
|
33
|
+
|
34
|
+
# This allows the utopia command to load the correct library:
|
35
|
+
ENV['RUBYLIB'] = File.expand_path("../../lib", __dir__)
|
33
36
|
end
|
34
37
|
|
35
38
|
def sh(*args)
|
@@ -50,7 +53,7 @@ RSpec.describe "utopia executable" do
|
|
50
53
|
Dir.mktmpdir('test-site') do |dir|
|
51
54
|
install_packages(dir)
|
52
55
|
|
53
|
-
result = sh(utopia, "
|
56
|
+
result = sh(utopia, "--in", dir, "site", "create")
|
54
57
|
expect(result).to be == 0
|
55
58
|
|
56
59
|
expect(Dir.entries(dir)).to include(".bowerrc", ".git", "Gemfile", "Gemfile.lock", "README.md", "Rakefile", "cache", "config.ru", "lib", "pages", "public", "tmp")
|
@@ -61,7 +64,7 @@ RSpec.describe "utopia executable" do
|
|
61
64
|
Dir.mktmpdir('test-server') do |dir|
|
62
65
|
install_packages(dir)
|
63
66
|
|
64
|
-
result = sh(utopia, "server
|
67
|
+
result = sh(utopia, "--in", dir, "server", "create")
|
65
68
|
expect(result).to be == 0
|
66
69
|
|
67
70
|
expect(Dir.entries(dir)).to include(".git")
|
@@ -76,10 +79,10 @@ RSpec.describe "utopia executable" do
|
|
76
79
|
|
77
80
|
server_path = File.join(dir, 'server')
|
78
81
|
|
79
|
-
result = sh(utopia, "
|
82
|
+
result = sh(utopia, "--in", site_path, "site", "create")
|
80
83
|
expect(result).to be == 0
|
81
84
|
|
82
|
-
result = sh(utopia, "server
|
85
|
+
result = sh(utopia, "--in", server_path, "server", "create")
|
83
86
|
expect(result).to be == 0
|
84
87
|
|
85
88
|
Dir.chdir(site_path) do
|
data/utopia.gemspec
CHANGED
@@ -25,14 +25,16 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.required_ruby_version = '~> 2.0'
|
26
26
|
|
27
27
|
spec.add_dependency 'trenni', '~> 1.6.0'
|
28
|
-
spec.add_dependency 'mime-types', '
|
28
|
+
spec.add_dependency 'mime-types', ['>= 2.0', '< 4']
|
29
|
+
|
30
|
+
spec.add_dependency 'samovar', '~> 1.1.0'
|
29
31
|
|
30
32
|
spec.add_dependency 'rack', '~> 1.6'
|
31
33
|
spec.add_dependency 'rack-cache', '~> 1.2.0'
|
32
34
|
|
33
35
|
spec.add_dependency 'http-accept', '~> 1.4.0'
|
34
36
|
|
35
|
-
spec.add_dependency 'mail', '~> 2.6.
|
37
|
+
spec.add_dependency 'mail', '~> 2.6.4'
|
36
38
|
|
37
39
|
spec.add_dependency 'concurrent-ruby', '~> 1.0.0'
|
38
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -28,16 +28,36 @@ dependencies:
|
|
28
28
|
name: mime-types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '4'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '2.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: samovar
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.1.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.1.0
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: rack
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +106,14 @@ dependencies:
|
|
86
106
|
requirements:
|
87
107
|
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.6.
|
109
|
+
version: 2.6.4
|
90
110
|
type: :runtime
|
91
111
|
prerelease: false
|
92
112
|
version_requirements: !ruby/object:Gem::Requirement
|
93
113
|
requirements:
|
94
114
|
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.6.
|
116
|
+
version: 2.6.4
|
97
117
|
- !ruby/object:Gem::Dependency
|
98
118
|
name: concurrent-ruby
|
99
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +208,7 @@ files:
|
|
188
208
|
- ext/utopia/xnode/fast_scanner/extconf.rb
|
189
209
|
- ext/utopia/xnode/fast_scanner/parser.c
|
190
210
|
- lib/utopia.rb
|
211
|
+
- lib/utopia/command.rb
|
191
212
|
- lib/utopia/content.rb
|
192
213
|
- lib/utopia/content/link.rb
|
193
214
|
- lib/utopia/content/links.rb
|