smallcage 0.2.4 → 0.2.5
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.
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +1 -1
- data/Gemfile +16 -5
- data/Guardfile +4 -0
- data/History.rdoc +9 -5
- data/README.rdoc +3 -3
- data/Rakefile +1 -1
- data/bin/smc +4 -12
- data/lib/smallcage.rb +4 -1
- data/lib/smallcage/anonymous_loader.rb +32 -0
- data/lib/smallcage/application.rb +4 -5
- data/lib/smallcage/commands/auto.rb +16 -17
- data/lib/smallcage/commands/base.rb +4 -5
- data/lib/smallcage/commands/clean.rb +5 -5
- data/lib/smallcage/commands/export.rb +5 -5
- data/lib/smallcage/commands/import.rb +25 -27
- data/lib/smallcage/commands/manifest.rb +4 -4
- data/lib/smallcage/commands/server.rb +4 -4
- data/lib/smallcage/commands/update.rb +4 -5
- data/lib/smallcage/commands/uri.rb +3 -5
- data/lib/smallcage/document_path.rb +6 -9
- data/lib/smallcage/http_server.rb +9 -10
- data/lib/smallcage/loader.rb +19 -49
- data/lib/smallcage/misc.rb +1 -1
- data/lib/smallcage/renderer.rb +1 -1
- data/lib/smallcage/resources/auto.html +7 -7
- data/lib/smallcage/runner.rb +6 -6
- data/lib/smallcage/update_list.rb +2 -3
- data/lib/smallcage/version.rb +1 -1
- data/project/base/_smc/helpers/base_helper.rb +8 -9
- data/project/bluecloth/_smc/helpers/blue_cloth_helper.rb +2 -3
- data/project/cache/_smc/filters/cache_filter.rb +10 -12
- data/project/cache/_smc/rakelib/cache.rake +7 -8
- data/project/gdata/_smc/rakelib/gdata.rake +3 -5
- data/project/lang/_smc/helpers/lang_helper.rb +3 -3
- data/project/news/_smc/helpers/news_helper.rb +3 -4
- data/project/nkf/_smc/filters/nkf_filter.rb +6 -6
- data/project/nkf/_smc/helpers/nkf_helper.rb +8 -9
- data/project/rake/_smc/rakelib/svn.rake +5 -6
- data/project/redcloth/_smc/helpers/red_cloth_helper.rb +3 -3
- data/project/standard/_smc/helpers/menu_helper.rb +4 -5
- data/project/standard/_smc/templates/redirect.rhtml +1 -1
- data/spec/data/anonymous_loader/1/error1.rb +1 -0
- data/spec/data/anonymous_loader/1/error2.rb +1 -0
- data/spec/data/anonymous_loader/1/test1.rb +1 -0
- data/spec/data/anonymous_loader/1/test2.rb +1 -0
- data/spec/lib/smallcage/anonymous_loader_spec.rb +37 -0
- data/spec/lib/smallcage/application_spec.rb +271 -0
- data/spec/{smallcage → lib/smallcage}/commands/auto_spec.rb +0 -0
- data/spec/{export_spec.rb → lib/smallcage/commands/export_spec.rb} +8 -10
- data/spec/{import_spec.rb → lib/smallcage/commands/import_spec.rb} +5 -6
- data/spec/{manifest_spec.rb → lib/smallcage/commands/manifest_spec.rb} +4 -3
- data/spec/{smallcage → lib/smallcage}/commands/server_spec.rb +0 -0
- data/spec/{update_spec.rb → lib/smallcage/commands/update_spec.rb} +15 -19
- data/spec/{uri_spec.rb → lib/smallcage/commands/uri_spec.rb} +3 -4
- data/spec/{document_path_spec.rb → lib/smallcage/document_path_spec.rb} +19 -31
- data/spec/{loader_spec.rb → lib/smallcage/loader_spec.rb} +16 -18
- data/spec/lib/smallcage/misc_spec.rb +18 -0
- data/spec/{update_list_spec.rb → lib/smallcage/update_list_spec.rb} +18 -21
- data/spec/{smallcage_spec.rb → lib/smallcage_spec.rb} +1 -1
- data/spec/spec_helper.rb +5 -4
- metadata +85 -55
- checksums.yaml +0 -7
- data/Gemfile.lock +0 -32
- data/spec/misc_spec.rb +0 -25
- data/spec/smallcage/application_spec.rb +0 -271
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem 'syck', :platforms =>
|
3
|
+
gem 'syck', :platforms => :ruby_20
|
4
4
|
|
5
|
-
group :test do
|
6
|
-
gem 'rake'
|
5
|
+
group :development, :test do
|
7
6
|
gem 'rspec'
|
8
|
-
|
9
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'rake'
|
11
|
+
|
12
|
+
platforms :ruby_19, :ruby_20 do
|
13
|
+
gem 'simplecov', :require => false
|
14
|
+
gem 'rubocop', :require => false
|
15
|
+
|
16
|
+
if RUBY_VERSION >= '1.9.3'
|
17
|
+
gem 'guard', :require => false
|
18
|
+
gem 'guard-rspec', :require => false
|
19
|
+
end
|
20
|
+
end
|
10
21
|
end
|
data/Guardfile
ADDED
data/History.rdoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= History
|
2
2
|
|
3
|
+
== 0.2.5 2014-03-08
|
4
|
+
|
5
|
+
* fix ignoring LoadError bug. When LoadError occurred in the helper modules, smc finished without any message.
|
6
|
+
|
3
7
|
== 0.2.4 2014-01-06
|
4
8
|
|
5
9
|
* install syck gem only when the Ruby version is 2.0.0 or above.
|
@@ -54,12 +58,12 @@
|
|
54
58
|
* add get directory config method to base_helper.rb.
|
55
59
|
* add NKF helper to nkf project template.
|
56
60
|
* avoid error when filter config is empty.
|
57
|
-
* add statistics line to update command.
|
61
|
+
* add statistics line to update command.
|
58
62
|
* do not abort auto update server when ERB error occurred.
|
59
63
|
|
60
64
|
== 0.1.4 2009-07-27
|
61
65
|
|
62
|
-
* add cache control filter and rake task (for CDN, etag, etc.).
|
66
|
+
* add cache control filter and rake task (for CDN, etag, etc.).
|
63
67
|
* add csv rake task which creates smc files from csv file.
|
64
68
|
* move rake tasks into *.rake files.
|
65
69
|
* switch 'smc import' default answer to 'Yes'.
|
@@ -67,8 +71,8 @@
|
|
67
71
|
* add project template to explain smc object and template: tutorial2.
|
68
72
|
* added 'body' to default smc object keys.
|
69
73
|
* avoid error when helper directory doesn't exist.
|
70
|
-
* show smc filename when template error occurs.
|
71
|
-
|
74
|
+
* show smc filename when template error occurs.
|
75
|
+
|
72
76
|
== 0.1.3 2009-05-01
|
73
77
|
|
74
78
|
* moved to github.
|
@@ -77,7 +81,7 @@
|
|
77
81
|
|
78
82
|
== 0.1.2 2009-01-16
|
79
83
|
|
80
|
-
* stop using /dev/null for WEBrick access log.
|
84
|
+
* stop using /dev/null for WEBrick access log.
|
81
85
|
|
82
86
|
== 0.1.1 2008-09-22
|
83
87
|
|
data/README.rdoc
CHANGED
@@ -35,14 +35,14 @@ If successfully installed, smc command will be available.
|
|
35
35
|
export [path] [outputpath] Export project.
|
36
36
|
uri [path] Print URIs.
|
37
37
|
manifest [path] Generate Manifest.html file.
|
38
|
-
|
38
|
+
|
39
39
|
Options are:
|
40
|
-
|
40
|
+
|
41
41
|
-h, --help Show this help message.
|
42
42
|
-v, --version Show version info.
|
43
43
|
|
44
44
|
Create document root.
|
45
|
-
|
45
|
+
|
46
46
|
$ mkdir htdocs
|
47
47
|
$ cd htdocs
|
48
48
|
|
data/Rakefile
CHANGED
data/bin/smc
CHANGED
@@ -1,16 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created on 2007-8-22.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
2
|
|
6
|
-
|
7
|
-
$:.unshift File.dirname(__FILE__) + "/../lib"
|
8
|
-
end
|
3
|
+
$:.unshift(File.join(File.dirname( __FILE__), '../lib'))
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
require 'smallcage'
|
13
|
-
SmallCage::Application.execute
|
14
|
-
rescue LoadError
|
15
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
require 'smallcage'
|
16
7
|
|
8
|
+
SmallCage::Application.execute
|
data/lib/smallcage.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
$:.unshift
|
1
|
+
$:.unshift(File.dirname( __FILE__)) if __FILE__ == $0
|
2
2
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'syck'
|
@@ -11,6 +11,7 @@ require 'delegate'
|
|
11
11
|
require 'smallcage/version'
|
12
12
|
require 'smallcage/misc'
|
13
13
|
require 'smallcage/loader'
|
14
|
+
require 'smallcage/anonymous_loader'
|
14
15
|
require 'smallcage/erb_base'
|
15
16
|
require 'smallcage/renderer'
|
16
17
|
require 'smallcage/runner'
|
@@ -18,3 +19,5 @@ require 'smallcage/document_path'
|
|
18
19
|
require 'smallcage/http_server'
|
19
20
|
require 'smallcage/application'
|
20
21
|
require 'smallcage/update_list'
|
22
|
+
|
23
|
+
SmallCage::Application.execute if __FILE__ == $0
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module SmallCage
|
2
|
+
# load files into anonymous module
|
3
|
+
class AnonymousLoader
|
4
|
+
attr_reader :module, :module_names
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@module = Module.new
|
8
|
+
@module_names = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_match_files(dir, rex)
|
12
|
+
return unless File.exist?(dir)
|
13
|
+
|
14
|
+
Dir.entries(dir).sort.each do |h|
|
15
|
+
next unless h =~ rex
|
16
|
+
|
17
|
+
module_name = Regexp.last_match(1).camelize
|
18
|
+
path = File.join(dir, h)
|
19
|
+
src = File.read(path)
|
20
|
+
|
21
|
+
@module.module_eval(src, path)
|
22
|
+
@module_names << module_name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load(dir, rex)
|
27
|
+
loader = new
|
28
|
+
loader.load_match_files(dir, rex)
|
29
|
+
{ :module => loader.module, :names => loader.module_names }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class SmallCage::Application
|
2
2
|
require 'optparse'
|
3
3
|
VERSION_NOTE = "SmallCage #{SmallCage::VERSION} - a simple website generator"
|
4
|
-
|
4
|
+
|
5
5
|
@@signal_handlers = nil
|
6
6
|
|
7
7
|
def self.init_signal_handlers
|
@@ -18,7 +18,7 @@ class SmallCage::Application
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def self.add_signal_handler(signal, handler)
|
23
23
|
init_signal_handlers if @@signal_handlers.nil?
|
24
24
|
signal.to_a.each do |s|
|
@@ -76,7 +76,7 @@ BANNER
|
|
76
76
|
puts VERSION_NOTE
|
77
77
|
exit(true)
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
@options[:quiet] = false
|
81
81
|
parser.on("-q", "--quiet", "Do not print message.") do |boolean|
|
82
82
|
@options[:quiet] = boolean
|
@@ -254,7 +254,7 @@ EOT
|
|
254
254
|
|
255
255
|
def get_port_number(default)
|
256
256
|
return default if @argv.empty?
|
257
|
-
|
257
|
+
|
258
258
|
port = @argv.shift
|
259
259
|
if port.to_i == 0
|
260
260
|
$stderr.puts "illegal port number: #{port}"
|
@@ -263,5 +263,4 @@ EOT
|
|
263
263
|
return port.to_i
|
264
264
|
end
|
265
265
|
private :get_port_number
|
266
|
-
|
267
266
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module SmallCage::Commands
|
2
2
|
class Auto < SmallCage::Commands::Base
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(opts)
|
5
5
|
super(opts)
|
6
6
|
@target = Pathname.new(opts[:path])
|
@@ -29,10 +29,10 @@ module SmallCage::Commands
|
|
29
29
|
sleep @sleep
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def modified_special_files
|
34
34
|
root = @loader.root
|
35
|
-
|
35
|
+
|
36
36
|
result = []
|
37
37
|
Dir.chdir(root) do
|
38
38
|
Dir.glob("_smc/{templates,filters,helpers}/*") do |f|
|
@@ -44,7 +44,7 @@ module SmallCage::Commands
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
return result
|
49
49
|
end
|
50
50
|
private :modified_special_files
|
@@ -61,11 +61,11 @@ module SmallCage::Commands
|
|
61
61
|
return result
|
62
62
|
end
|
63
63
|
private :modified_files
|
64
|
-
|
64
|
+
|
65
65
|
def update_target
|
66
66
|
# load @mtimes
|
67
67
|
modified_special_files
|
68
|
-
target_files = modified_files
|
68
|
+
target_files = modified_files
|
69
69
|
|
70
70
|
runner = SmallCage::Runner.new({ :path => @target, :quiet => @opts[:quiet] })
|
71
71
|
begin
|
@@ -75,7 +75,7 @@ module SmallCage::Commands
|
|
75
75
|
STDERR.puts $@[0..4].join("\n")
|
76
76
|
STDERR.puts ":"
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
update_http_server(target_files)
|
80
80
|
puts_line
|
81
81
|
notify
|
@@ -91,7 +91,7 @@ module SmallCage::Commands
|
|
91
91
|
target_files = [@loader.root + "./_dir.smc"]
|
92
92
|
reload = true
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
return if target_files.empty?
|
96
96
|
target_files.each do |tf|
|
97
97
|
if tf.basename.to_s == "_dir.smc"
|
@@ -101,7 +101,7 @@ module SmallCage::Commands
|
|
101
101
|
end
|
102
102
|
runner.update
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
if reload
|
106
106
|
@http_server.reload
|
107
107
|
else
|
@@ -118,7 +118,7 @@ module SmallCage::Commands
|
|
118
118
|
notify
|
119
119
|
end
|
120
120
|
private :update_modified_files
|
121
|
-
|
121
|
+
|
122
122
|
def puts_banner
|
123
123
|
return if quiet?
|
124
124
|
puts "SmallCage Auto Update"
|
@@ -126,13 +126,13 @@ module SmallCage::Commands
|
|
126
126
|
puts
|
127
127
|
end
|
128
128
|
private :puts_banner
|
129
|
-
|
129
|
+
|
130
130
|
def puts_line
|
131
131
|
return if quiet?
|
132
132
|
puts "-" * 60
|
133
133
|
end
|
134
134
|
private :puts_line
|
135
|
-
|
135
|
+
|
136
136
|
def notify
|
137
137
|
return unless @opts[:bell]
|
138
138
|
print "\a" # Bell
|
@@ -162,17 +162,16 @@ module SmallCage::Commands
|
|
162
162
|
end
|
163
163
|
private :init_sig_handler
|
164
164
|
|
165
|
-
def start_http_server
|
165
|
+
def start_http_server
|
166
166
|
document_root = @opts[:path]
|
167
167
|
port = @opts[:port]
|
168
|
-
|
168
|
+
|
169
169
|
@http_server = SmallCage::HTTPServer.new(document_root, port)
|
170
|
-
|
170
|
+
|
171
171
|
Thread.new do
|
172
|
-
@http_server.start
|
172
|
+
@http_server.start
|
173
173
|
end
|
174
174
|
end
|
175
175
|
private :start_http_server
|
176
|
-
|
177
176
|
end
|
178
177
|
end
|
@@ -3,11 +3,11 @@ module SmallCage::Commands
|
|
3
3
|
def self.execute(opts)
|
4
4
|
self.new(opts).execute
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(opts)
|
8
8
|
@opts = opts
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def execute
|
12
12
|
start = Time.now
|
13
13
|
count = 0
|
@@ -16,7 +16,7 @@ module SmallCage::Commands
|
|
16
16
|
unless target.exist?
|
17
17
|
raise "target directory or file does not exist.: " + target.to_s
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
loader = SmallCage::Loader.new(target)
|
21
21
|
root = loader.root
|
22
22
|
list = SmallCage::UpdateList.create(root, target)
|
@@ -29,7 +29,7 @@ module SmallCage::Commands
|
|
29
29
|
count += 1
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
tmpdir = root + "_smc/tmp"
|
34
34
|
if tmpdir.exist?
|
35
35
|
FileUtils.rm_r(tmpdir)
|
@@ -42,4 +42,4 @@ module SmallCage::Commands
|
|
42
42
|
" #{"%.3f" % (count == 0 ? 0 : elapsed/count)} sec/file." unless @opts[:quiet]
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
@@ -5,10 +5,10 @@ module SmallCage::Commands
|
|
5
5
|
unless target.exist?
|
6
6
|
raise target.to_s + " does not exist."
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
loader = SmallCage::Loader.new(target)
|
10
10
|
root = loader.root
|
11
|
-
|
11
|
+
|
12
12
|
if @opts[:out].nil?
|
13
13
|
out = root + ("./_smc/tmp/export/" + Time.now.strftime("%Y%m%d%H%M%S"))
|
14
14
|
else
|
@@ -19,7 +19,7 @@ module SmallCage::Commands
|
|
19
19
|
end
|
20
20
|
FileUtils.makedirs(out)
|
21
21
|
out = out.realpath
|
22
|
-
|
22
|
+
|
23
23
|
# TODO create empty directories
|
24
24
|
loader.each_not_smc_file do |docpath|
|
25
25
|
dir = Pathname.new(docpath.uri).parent
|
@@ -30,7 +30,7 @@ module SmallCage::Commands
|
|
30
30
|
end
|
31
31
|
|
32
32
|
unless quiet?
|
33
|
-
puts ""
|
33
|
+
puts ""
|
34
34
|
puts "All contents exported to:"
|
35
35
|
puts " #{out.to_s}"
|
36
36
|
end
|
@@ -38,4 +38,4 @@ module SmallCage::Commands
|
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
41
|
-
end
|
41
|
+
end
|