smallcage 0.1.7 → 0.1.8
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 +5 -0
- data/History.txt +4 -0
- data/Rakefile +16 -142
- data/VERSION +1 -0
- data/lib/smallcage.rb +1 -0
- data/lib/smallcage/application.rb +107 -107
- data/lib/smallcage/commands/clean.rb +18 -5
- data/lib/smallcage/commands/update.rb +58 -73
- data/lib/smallcage/document_path.rb +26 -2
- data/lib/smallcage/loader.rb +7 -21
- data/lib/smallcage/update_list.rb +143 -0
- data/lib/smallcage/version.rb +1 -1
- data/smallcage.gemspec +172 -0
- data/spec/data/htdocs1/_smc/.gitignore +0 -0
- data/spec/data/htdocs3/_smc/.gitignore +1 -0
- data/spec/data/multifiles/_dir.smc +3 -0
- data/spec/data/multifiles/_smc/templates/default.rhtml +6 -0
- data/spec/data/multifiles/_smc/templates/items.rhtml +8 -0
- data/spec/data/multifiles/_smc/templates/items.uri.rhtml +5 -0
- data/spec/data/multifiles/items/index.html.smc +1 -0
- data/spec/data/updatelists/list1.yml +13 -0
- data/spec/manifest_spec.rb +2 -2
- data/spec/smallcage_spec.rb +1 -76
- data/spec/update_list_spec.rb +232 -0
- data/spec/update_spec.rb +79 -0
- metadata +27 -23
- data/project/standard/_smc/helpers/base_helper.rb +0 -34
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,144 +1,18 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require 'spec'
|
12
|
-
require 'spec/rake/spectask'
|
13
|
-
|
14
|
-
include FileUtils
|
15
|
-
|
16
|
-
NAME = "smallcage"
|
17
|
-
AUTHORS = ["SAITO Toshihiro", "gom", "KOSEKI Kengo"]
|
18
|
-
EMAIL = "smallcage@googlegroups.com"
|
19
|
-
DESCRIPTION = "Lightweight CMS package."
|
20
|
-
RUBYFORGE_PROJECT = "smallcage"
|
21
|
-
HOMEPATH = "http://www.smallcage.org"
|
22
|
-
BIN_FILES = %w(smc)
|
23
|
-
|
24
|
-
VERS = SmallCage::VERSION::STRING
|
25
|
-
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
26
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
27
|
-
RDOC_OPTS = [
|
28
|
-
'--title', "#{NAME} documentation",
|
29
|
-
"--charset", "utf-8",
|
30
|
-
"--opname", "index.html",
|
31
|
-
"--line-numbers",
|
32
|
-
"--main", "README.rdoc",
|
33
|
-
"--inline-source",
|
34
|
-
]
|
35
|
-
|
36
|
-
SRC_FILES = FileList.new(%w{Rakefile README.rdoc History.txt License.txt})
|
37
|
-
SRC_FILES.include("{bin,doc,lib,test,project,spec}/**/*")
|
38
|
-
SRC_FILES.exclude(/~$/)
|
39
|
-
|
40
|
-
spec = Gem::Specification.new do |s|
|
41
|
-
s.name = NAME
|
42
|
-
s.version = VERS
|
43
|
-
s.platform = Gem::Platform::RUBY
|
44
|
-
s.has_rdoc = true
|
45
|
-
s.extra_rdoc_files = ["README.rdoc", "History.txt"]
|
46
|
-
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
47
|
-
s.summary = DESCRIPTION
|
48
|
-
s.description = DESCRIPTION
|
49
|
-
s.authors = AUTHORS
|
50
|
-
s.email = EMAIL
|
51
|
-
s.homepage = HOMEPATH
|
52
|
-
s.executables = BIN_FILES
|
53
|
-
s.rubyforge_project = RUBYFORGE_PROJECT
|
54
|
-
s.bindir = "bin"
|
55
|
-
s.require_path = "lib"
|
56
|
-
s.test_files = Dir["spec/*_spec.rb"]
|
57
|
-
s.files = SRC_FILES
|
58
|
-
|
59
|
-
#s.autorequire = ""
|
60
|
-
#s.add_dependency('activesupport', '>=1.3.1')
|
61
|
-
#s.required_ruby_version = '>= 1.8.2'
|
62
|
-
#s.extensions = FileList["ext/**/extconf.rb"].to_a
|
63
|
-
end
|
64
|
-
|
65
|
-
task :default => [:spec]
|
66
|
-
task :package => [:clean]
|
67
|
-
|
68
|
-
Rake::GemPackageTask.new(spec) do |p|
|
69
|
-
p.need_tar = true
|
70
|
-
p.gem_spec = spec
|
71
|
-
end
|
72
|
-
|
73
|
-
task :install do
|
74
|
-
name = "#{NAME}-#{VERS}.gem"
|
75
|
-
sh %{rake package}
|
76
|
-
sh %{sudo gem install pkg/#{name}}
|
77
|
-
end
|
78
|
-
|
79
|
-
task :uninstall => [:clean] do
|
80
|
-
sh %{sudo gem uninstall #{NAME}}
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
Rake::RDocTask.new do |rdoc|
|
85
|
-
rdoc.rdoc_dir = 'pkg/htdocs'
|
86
|
-
rdoc.options += RDOC_OPTS
|
87
|
-
#rdoc.template = "resh"
|
88
|
-
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
89
|
-
if ENV['DOC_FILES']
|
90
|
-
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
91
|
-
else
|
92
|
-
rdoc.rdoc_files.include('README.rdoc', 'History.txt')
|
93
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
94
|
-
rdoc.rdoc_files.include('ext/**/*.c')
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "smallcage"
|
5
|
+
gemspec.summary = "Lightweight CMS package."
|
6
|
+
gemspec.description = "Lightweight CMS package."
|
7
|
+
gemspec.email = "smallcage@googlegroups.com"
|
8
|
+
gemspec.homepage = "http://www.smallcage.org"
|
9
|
+
gemspec.authors = ["SAITO Toshihiro", "gommmmmm", "KOSEKI Kengo"]
|
10
|
+
gemspec.rubyforge_project = 'smallcage'
|
95
11
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
desc 'Package and upload the release to rubyforge.'
|
105
|
-
task :release => [:clean, :package] do |t|
|
106
|
-
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
107
|
-
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
|
108
|
-
pkg = "pkg/#{NAME}-#{VERS}"
|
109
|
-
|
110
|
-
require 'rubyforge'
|
111
|
-
rf = RubyForge.new.configure
|
112
|
-
puts "Logging in"
|
113
|
-
rf.login
|
114
|
-
|
115
|
-
c = rf.userconfig
|
116
|
-
# c["release_notes"] = description if description
|
117
|
-
# c["release_changes"] = changes if changes
|
118
|
-
c["preformatted"] = true
|
119
|
-
|
120
|
-
files = [
|
121
|
-
"#{pkg}.tgz",
|
122
|
-
"#{pkg}.gem"
|
123
|
-
].compact
|
124
|
-
|
125
|
-
puts "Releasing #{NAME} v. #{VERS}"
|
126
|
-
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
|
127
|
-
end
|
128
|
-
|
129
|
-
desc 'Show information about the gem.'
|
130
|
-
task :debug_gem do
|
131
|
-
puts spec.to_ruby
|
132
|
-
end
|
133
|
-
|
134
|
-
desc 'Update gem spec'
|
135
|
-
task :gemspec do
|
136
|
-
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
137
|
-
end
|
138
|
-
|
139
|
-
desc "Run the specs under ./spec/"
|
140
|
-
Spec::Rake::SpecTask.new do |t|
|
141
|
-
t.libs << "lib"
|
142
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
143
|
-
t.spec_files = FileList['spec/*_spec.rb']
|
12
|
+
Jeweler::GemcutterTasks.new
|
13
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
14
|
+
rubyforge.doc_task = "rdoc"
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
144
18
|
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.8
|
data/lib/smallcage.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
VERSION_NOTE = "SmallCage #{SmallCage::VERSION::STRING} - Lightweight CMS Package."
|
3
|
-
OPTIONS = {}
|
4
|
-
OPTIONS[:original_argv] = ARGV.clone
|
5
|
-
|
6
1
|
class SmallCage::Application
|
7
2
|
require 'optparse'
|
3
|
+
VERSION_NOTE = "SmallCage #{SmallCage::VERSION::STRING} - Lightweight CMS Package."
|
8
4
|
|
9
5
|
@@signal_handlers = nil
|
10
6
|
|
@@ -31,12 +27,23 @@ class SmallCage::Application
|
|
31
27
|
end
|
32
28
|
|
33
29
|
def self.execute
|
30
|
+
STDOUT.sync = true
|
31
|
+
self.new.execute
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def execute
|
35
|
+
@options = {}
|
36
|
+
@parser = create_main_parser
|
37
|
+
parse_main_options
|
38
|
+
@command_parsers = create_command_parsers
|
39
|
+
parse_command
|
40
|
+
parse_command_options
|
41
|
+
SmallCage::Runner.run(@options)
|
42
|
+
end
|
38
43
|
|
39
|
-
|
44
|
+
def create_main_parser
|
45
|
+
parser = OptionParser.new
|
46
|
+
parser.banner =<<BANNER
|
40
47
|
Usage: #{File.basename($0)} <subcommand> [options]
|
41
48
|
#{VERSION_NOTE}
|
42
49
|
Subcommands are:
|
@@ -50,115 +57,108 @@ Subcommands are:
|
|
50
57
|
|
51
58
|
Options are:
|
52
59
|
BANNER
|
53
|
-
|
54
|
-
opts.separator ""
|
55
|
-
opts.on("-h", "--help", "Show this help message.") do
|
56
|
-
puts opts
|
57
|
-
exit
|
58
|
-
end
|
59
|
-
opts.on("-v", "--version", "Show version info.") do
|
60
|
-
puts VERSION_NOTE
|
61
|
-
exit
|
60
|
+
return parser
|
62
61
|
end
|
62
|
+
private :create_main_parser
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
def parse_main_options
|
65
|
+
@parser.separator ""
|
66
|
+
@parser.on("-h", "--help", "Show this help message.") do
|
67
|
+
puts @parser
|
68
|
+
exit
|
69
|
+
end
|
70
|
+
@parser.on("-v", "--version", "Show version info.") do
|
71
|
+
puts VERSION_NOTE
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
@parser.order!(ARGV)
|
73
75
|
end
|
76
|
+
private :parse_main_options
|
77
|
+
|
78
|
+
def create_command_parsers
|
79
|
+
parsers = Hash.new do |h,k|
|
80
|
+
STDERR << "no such subcommand: #{k}\n"
|
81
|
+
exit 1
|
82
|
+
end
|
83
|
+
|
84
|
+
banners = {
|
85
|
+
:update => "smc update [path]\n",
|
86
|
+
:clean => "smc clean [path]\n",
|
87
|
+
:server => "smc server [path] [port]\n",
|
88
|
+
:auto => "smc auto [path] [port]\n",
|
89
|
+
:import => "smc import [name|uri]",
|
90
|
+
:export => "smc export [path] [outputpath]",
|
91
|
+
:help => "smc help [command]\n",
|
92
|
+
}
|
74
93
|
|
75
|
-
|
76
|
-
|
77
|
-
Usage:
|
78
|
-
|
79
|
-
|
94
|
+
banners.each do |k,v|
|
95
|
+
parsers[k] = OptionParser.new do |cp|
|
96
|
+
cp.banner = "Usage: " + v
|
97
|
+
end
|
98
|
+
end
|
80
99
|
|
81
|
-
|
82
|
-
subp.banner =<<EOT
|
83
|
-
Usage: auto [PATH]
|
84
|
-
EOT
|
100
|
+
return parsers
|
85
101
|
end
|
102
|
+
private :create_command_parsers
|
86
103
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
subparsers[:export] = OptionParser.new do |subp|
|
96
|
-
end
|
97
|
-
subparsers[:manifest] = OptionParser.new do |subp|
|
98
|
-
end
|
99
|
-
subparsers[:clean] = OptionParser.new do |subp|
|
100
|
-
end
|
104
|
+
def parse_command
|
105
|
+
commands = Hash.new {|h,k| k}
|
106
|
+
commands.merge!({
|
107
|
+
:up => :update,
|
108
|
+
:sv => :server,
|
109
|
+
:au => :auto,
|
110
|
+
})
|
101
111
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
:au => :auto,
|
107
|
-
:gen => :generate,
|
108
|
-
:rel => :release,
|
109
|
-
:st => :status,
|
110
|
-
})
|
112
|
+
unless ARGV.empty?
|
113
|
+
@options[:command] = commands[ARGV.shift.to_sym]
|
114
|
+
@command_parsers[@options[:command]].parse!(ARGV)
|
115
|
+
end
|
111
116
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
subparsers[OPTIONS[:command]].parse!(ARGV)
|
116
|
-
end
|
117
|
-
|
118
|
-
if OPTIONS[:command].nil?
|
119
|
-
puts opts
|
120
|
-
exit
|
121
|
-
elsif OPTIONS[:command] == :help
|
122
|
-
subcmd = ARGV.shift
|
123
|
-
if subcmd.nil?
|
124
|
-
puts opts
|
125
|
-
else
|
126
|
-
puts subparsers[subcmd.to_sym]
|
117
|
+
if @options[:command].nil?
|
118
|
+
puts @parser
|
119
|
+
exit
|
127
120
|
end
|
128
|
-
exit
|
129
|
-
elsif OPTIONS[:command] == :update
|
130
|
-
OPTIONS[:path] = ARGV.shift
|
131
|
-
OPTIONS[:path] ||= "."
|
132
|
-
elsif OPTIONS[:command] == :server
|
133
|
-
OPTIONS[:path] = ARGV.shift
|
134
|
-
OPTIONS[:port] = ARGV.shift
|
135
|
-
OPTIONS[:path] ||= "."
|
136
|
-
OPTIONS[:port] ||= 80
|
137
|
-
elsif OPTIONS[:command] == :auto
|
138
|
-
OPTIONS[:path] = ARGV.shift
|
139
|
-
OPTIONS[:path] ||= "."
|
140
|
-
OPTIONS[:port] = ARGV.shift
|
141
|
-
elsif OPTIONS[:command] == :import
|
142
|
-
OPTIONS[:from] = ARGV.shift
|
143
|
-
OPTIONS[:from] ||= "default"
|
144
|
-
|
145
|
-
OPTIONS[:to] = ARGV.shift
|
146
|
-
OPTIONS[:to] ||= "."
|
147
|
-
elsif OPTIONS[:command] == :export
|
148
|
-
OPTIONS[:path] = ARGV.shift
|
149
|
-
OPTIONS[:path] ||= "."
|
150
|
-
|
151
|
-
OPTIONS[:out] = ARGV.shift
|
152
|
-
elsif OPTIONS[:command] == :manifest
|
153
|
-
OPTIONS[:path] = ARGV.shift
|
154
|
-
OPTIONS[:path] ||= "."
|
155
|
-
elsif OPTIONS[:command] == :clean
|
156
|
-
OPTIONS[:path] = ARGV.shift
|
157
|
-
OPTIONS[:path] ||= "."
|
158
121
|
end
|
159
|
-
|
122
|
+
private :parse_command
|
160
123
|
|
161
|
-
|
124
|
+
def parse_command_options
|
125
|
+
if @options[:command] == :help
|
126
|
+
subcmd = ARGV.shift
|
127
|
+
if subcmd.nil?
|
128
|
+
puts @parser
|
129
|
+
else
|
130
|
+
puts @command_parsers[subcmd.to_sym]
|
131
|
+
end
|
132
|
+
exit
|
133
|
+
elsif @options[:command] == :update
|
134
|
+
@options[:path] = ARGV.shift
|
135
|
+
@options[:path] ||= "."
|
136
|
+
elsif @options[:command] == :server
|
137
|
+
@options[:path] = ARGV.shift
|
138
|
+
@options[:port] = ARGV.shift
|
139
|
+
@options[:path] ||= "."
|
140
|
+
@options[:port] ||= 80
|
141
|
+
elsif @options[:command] == :auto
|
142
|
+
@options[:path] = ARGV.shift
|
143
|
+
@options[:path] ||= "."
|
144
|
+
@options[:port] = ARGV.shift
|
145
|
+
elsif @options[:command] == :import
|
146
|
+
@options[:from] = ARGV.shift
|
147
|
+
@options[:from] ||= "default"
|
148
|
+
@options[:to] = ARGV.shift
|
149
|
+
@options[:to] ||= "."
|
150
|
+
elsif @options[:command] == :export
|
151
|
+
@options[:path] = ARGV.shift
|
152
|
+
@options[:path] ||= "."
|
153
|
+
@options[:out] = ARGV.shift
|
154
|
+
elsif @options[:command] == :manifest
|
155
|
+
@options[:path] = ARGV.shift
|
156
|
+
@options[:path] ||= "."
|
157
|
+
elsif @options[:command] == :clean
|
158
|
+
@options[:path] = ARGV.shift
|
159
|
+
@options[:path] ||= "."
|
160
|
+
end
|
161
|
+
end
|
162
|
+
private :parse_command_options
|
162
163
|
|
163
164
|
end
|
164
|
-
end
|
@@ -9,24 +9,37 @@ module SmallCage::Commands
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute
|
12
|
+
start = Time.now
|
13
|
+
count = 0
|
14
|
+
|
12
15
|
target = Pathname.new(@opts[:path])
|
13
16
|
unless target.exist?
|
14
17
|
raise "target directory or file does not exist.: " + target.to_s
|
15
18
|
end
|
16
19
|
|
17
20
|
loader = SmallCage::Loader.new(target)
|
18
|
-
loader.
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
root = loader.root
|
22
|
+
list = SmallCage::UpdateList.create(root, target)
|
23
|
+
uris = list.expire
|
24
|
+
uris.each do |uri|
|
25
|
+
file = root + uri[1..-1]
|
26
|
+
if file.exist?
|
27
|
+
puts "D #{uri}" unless @opts[:quiet]
|
28
|
+
file.delete
|
29
|
+
count += 1
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
tmpdir =
|
33
|
+
tmpdir = root + "_smc/tmp"
|
26
34
|
if tmpdir.exist?
|
27
35
|
FileUtils.rm_r(tmpdir)
|
28
36
|
puts "D /_smc/tmp" unless @opts[:quiet]
|
37
|
+
count += 1
|
29
38
|
end
|
39
|
+
|
40
|
+
elapsed = Time.now - start
|
41
|
+
puts "-- #{count} files. #{"%.3f" % elapsed} sec." +
|
42
|
+
" #{"%.3f" % (count == 0 ? 0 : elapsed/count)} sec/file." unless @opts[:quiet]
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|