bluemark-smallcage 0.1.3 → 0.1.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.
- data/History.txt +12 -0
- data/License.txt +1 -1
- data/README.txt +61 -1
- data/Rakefile +85 -81
- data/lib/smallcage/commands/import.rb +1 -1
- data/lib/smallcage/erb_base.rb +0 -1
- data/lib/smallcage/loader.rb +9 -3
- data/lib/smallcage/renderer.rb +7 -2
- data/lib/smallcage/version.rb +1 -1
- data/project/cache/_smc/filters/cache_filter.rb +35 -0
- data/project/cache/_smc/filters/filters.yml +2 -0
- data/project/cache/_smc/rakelib/cache.rake +34 -0
- data/project/rake/_smc/Rakefile +2 -57
- data/project/rake/_smc/rakelib/csv.rake +43 -0
- data/project/rake/_smc/rakelib/svn.rake +64 -0
- data/project/tutorial/_smc/helpers/sample_helper.rb +7 -0
- data/project/tutorial/_smc/templates/default.rhtml +6 -0
- data/project/tutorial/_smc/templates/include1.rhtml +1 -0
- data/project/tutorial/_smc/templates/include2.rhtml +1 -0
- data/project/tutorial/sample.txt.smc +7 -0
- data/project/tutorial/sample2.txt.smc +1 -0
- data/project/tutorial2/_smc/helpers/priority_sample_helper.rb +7 -0
- data/project/tutorial2/_smc/templates/priorities.rhtml +5 -0
- data/project/tutorial2/_smc/templates/priority1.rhtml +1 -0
- data/project/tutorial2/_smc/templates/priority2.rhtml +1 -0
- data/project/tutorial2/_smc/templates/priority3.rhtml +1 -0
- data/project/tutorial2/_smc/templates/smc_variables.rhtml +29 -0
- data/project/tutorial2/tutorial2/_dir.smc +2 -0
- data/project/tutorial2/tutorial2/priorities.txt.smc +4 -0
- data/project/tutorial2/tutorial2/vars.txt.smc +26 -0
- data/spec/data/htdocs1/_dir.smc +3 -0
- data/spec/loader_spec.rb +35 -1
- data/spec/manifest_spec.rb +9 -9
- data/spec/spec_helper.rb +2 -7
- metadata +49 -9
- data/test/test_helper.rb +0 -2
- data/test/test_smallcage.rb +0 -11
data/History.txt
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
== 0.1.4 2009-07-27
|
|
2
|
+
|
|
3
|
+
* add cache control filter and rake task (for CDN, etag, etc.).
|
|
4
|
+
* move rake tasks into *.rake files.
|
|
5
|
+
* switch 'smc import' default answer to 'Yes'.
|
|
6
|
+
* add the most primitive project template: tutorial.
|
|
7
|
+
* add project template to explain smc object and template: tutorial2.
|
|
8
|
+
* added 'body' to default smc object keys.
|
|
9
|
+
* avoid error when helper directory doesn't exist.
|
|
10
|
+
* show smc filename when template error occurs.
|
|
11
|
+
|
|
1
12
|
== 0.1.3 2009-05-01
|
|
2
13
|
|
|
14
|
+
* moved to github.
|
|
3
15
|
* stop using newgem and generate Rakefile using cutagem.
|
|
4
16
|
* fix svnignore_reset bug.
|
|
5
17
|
|
data/License.txt
CHANGED
data/README.txt
CHANGED
|
@@ -1 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
SmallCage - Lightweigt CMS Package.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
INSTALL
|
|
6
|
+
|
|
7
|
+
$ sudo gem install smallcage
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
USAGE
|
|
11
|
+
|
|
12
|
+
$ smc help
|
|
13
|
+
|
|
14
|
+
Usage: smc <subcommand> [options]
|
|
15
|
+
SmallCage 0.1.3 - Lightweight CMS Package.
|
|
16
|
+
Subcommands are:
|
|
17
|
+
update [path] Build smc contents.
|
|
18
|
+
clean [path] Remove files generated from *.smc source.
|
|
19
|
+
server [path] [port] Start HTTP server.
|
|
20
|
+
auto [path] [port] Start auto update daemon.
|
|
21
|
+
import [name|uri] Import project.
|
|
22
|
+
export [path] [outputpath] Export project.
|
|
23
|
+
manifest [path] Generate Manifest.html file.
|
|
24
|
+
|
|
25
|
+
Options are:
|
|
26
|
+
|
|
27
|
+
-h, --help Show this help message.
|
|
28
|
+
-v, --version Show version info.
|
|
29
|
+
|
|
30
|
+
$ mkdir htdocs
|
|
31
|
+
$ cd htdocs
|
|
32
|
+
$ smc import
|
|
33
|
+
Import: base
|
|
34
|
+
Create:
|
|
35
|
+
/_smc
|
|
36
|
+
/_smc/helpers
|
|
37
|
+
/_smc/helpers/base_helper.rb
|
|
38
|
+
/_smc/helpers/site_helper.rb
|
|
39
|
+
/_smc/templates
|
|
40
|
+
/_smc/templates/default.rhtml
|
|
41
|
+
/_smc/templates/footer.rhtml
|
|
42
|
+
/_smc/templates/header.rhtml
|
|
43
|
+
|
|
44
|
+
Import these files?[yN]: y
|
|
45
|
+
A /_smc
|
|
46
|
+
A /_smc/helpers
|
|
47
|
+
A /_smc/helpers/base_helper.rb
|
|
48
|
+
:
|
|
49
|
+
|
|
50
|
+
$ smc update
|
|
51
|
+
A /index.html
|
|
52
|
+
A /sample/index.html
|
|
53
|
+
A /sample/redirect.html
|
|
54
|
+
A /sample/sub/contents.html
|
|
55
|
+
A /sample/sub/index.html
|
|
56
|
+
|
|
57
|
+
$ smc server . 8080
|
|
58
|
+
:
|
|
59
|
+
...and access
|
|
60
|
+
http://localhost:8080/
|
|
61
|
+
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'rake'
|
|
3
3
|
require 'rake/clean'
|
|
4
|
-
require 'rake/testtask'
|
|
5
4
|
require 'rake/packagetask'
|
|
6
5
|
require 'rake/gempackagetask'
|
|
7
6
|
require 'rake/rdoctask'
|
|
@@ -9,6 +8,9 @@ require 'rake/contrib/rubyforgepublisher'
|
|
|
9
8
|
require 'rake/contrib/sshpublisher'
|
|
10
9
|
require 'fileutils'
|
|
11
10
|
require 'lib/smallcage'
|
|
11
|
+
require 'spec'
|
|
12
|
+
require 'spec/rake/spectask'
|
|
13
|
+
|
|
12
14
|
include FileUtils
|
|
13
15
|
|
|
14
16
|
NAME = "smallcage"
|
|
@@ -23,118 +25,120 @@ VERS = SmallCage::VERSION::STRING
|
|
|
23
25
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
|
24
26
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
|
25
27
|
RDOC_OPTS = [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
'--title', "#{NAME} documentation",
|
|
29
|
+
"--charset", "utf-8",
|
|
30
|
+
"--opname", "index.html",
|
|
31
|
+
"--line-numbers",
|
|
32
|
+
"--main", "README.txt",
|
|
33
|
+
"--inline-source",
|
|
32
34
|
]
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Rake::TestTask.new("test") do |t|
|
|
38
|
-
t.libs << "test"
|
|
39
|
-
t.pattern = "test/**/*_test.rb"
|
|
40
|
-
t.verbose = true
|
|
41
|
-
end
|
|
36
|
+
SRC_FILES = FileList.new(%w{Rakefile README.txt History.txt License.txt})
|
|
37
|
+
SRC_FILES.include("{bin,doc,lib,test,project,spec}/**/*")
|
|
38
|
+
SRC_FILES.exclude(/~$/)
|
|
42
39
|
|
|
43
40
|
spec = Gem::Specification.new do |s|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Dir.glob("{bin,doc,lib,test,project,spec}/**/*")
|
|
67
|
-
|
|
68
|
-
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
|
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.txt", "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
|
|
69
63
|
end
|
|
70
64
|
|
|
65
|
+
task :default => [:spec]
|
|
66
|
+
task :package => [:clean]
|
|
67
|
+
|
|
71
68
|
Rake::GemPackageTask.new(spec) do |p|
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
p.need_tar = true
|
|
70
|
+
p.gem_spec = spec
|
|
74
71
|
end
|
|
75
72
|
|
|
76
73
|
task :install do
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
name = "#{NAME}-#{VERS}.gem"
|
|
75
|
+
sh %{rake package}
|
|
76
|
+
sh %{sudo gem install pkg/#{name}}
|
|
80
77
|
end
|
|
81
78
|
|
|
82
79
|
task :uninstall => [:clean] do
|
|
83
|
-
|
|
80
|
+
sh %{sudo gem uninstall #{NAME}}
|
|
84
81
|
end
|
|
85
82
|
|
|
86
83
|
|
|
87
84
|
Rake::RDocTask.new do |rdoc|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
rdoc.rdoc_dir = 'html'
|
|
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.txt', 'History.txt')
|
|
93
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
94
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
|
95
|
+
end
|
|
99
96
|
end
|
|
100
97
|
|
|
101
98
|
desc "Publish to RubyForge"
|
|
102
99
|
task :rubyforge => [:rdoc, :package] do
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
require 'rubyforge'
|
|
101
|
+
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'bluemark').upload
|
|
105
102
|
end
|
|
106
103
|
|
|
107
104
|
desc 'Package and upload the release to rubyforge.'
|
|
108
105
|
task :release => [:clean, :package] do |t|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
130
127
|
end
|
|
131
128
|
|
|
132
129
|
desc 'Show information about the gem.'
|
|
133
130
|
task :debug_gem do
|
|
134
|
-
|
|
131
|
+
puts spec.to_ruby
|
|
135
132
|
end
|
|
136
133
|
|
|
137
134
|
desc 'Update gem spec'
|
|
138
135
|
task :gemspec do
|
|
139
136
|
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
|
140
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']
|
|
144
|
+
end
|
data/lib/smallcage/erb_base.rb
CHANGED
data/lib/smallcage/loader.rb
CHANGED
|
@@ -87,6 +87,7 @@ module SmallCage
|
|
|
87
87
|
result["uri"] = uri_out
|
|
88
88
|
result["arrays"] = []
|
|
89
89
|
result["strings"] = []
|
|
90
|
+
result["body"] = nil
|
|
90
91
|
|
|
91
92
|
# target is directory and _dir.smc is not exist.
|
|
92
93
|
return result unless source_path.exist?
|
|
@@ -110,6 +111,8 @@ module SmallCage
|
|
|
110
111
|
result["strings"] << o.to_s
|
|
111
112
|
end
|
|
112
113
|
end
|
|
114
|
+
|
|
115
|
+
result["body"] = result["strings"][0] if result["body"].nil?
|
|
113
116
|
|
|
114
117
|
return result
|
|
115
118
|
end
|
|
@@ -205,8 +208,11 @@ module SmallCage
|
|
|
205
208
|
|
|
206
209
|
def load_anonymous(dir, rex)
|
|
207
210
|
module_names = []
|
|
208
|
-
|
|
209
211
|
mod = Module.new
|
|
212
|
+
result = { :module => mod, :names => module_names }
|
|
213
|
+
|
|
214
|
+
return result unless File.exist?(dir)
|
|
215
|
+
|
|
210
216
|
Dir.entries(dir).sort.each do |h|
|
|
211
217
|
next unless h =~ rex
|
|
212
218
|
|
|
@@ -217,14 +223,14 @@ module SmallCage
|
|
|
217
223
|
begin
|
|
218
224
|
mod.module_eval(src, "#{dir}/#{h}")
|
|
219
225
|
rescue => ex
|
|
220
|
-
|
|
226
|
+
STDERR << ex.to_s # TODO show error
|
|
221
227
|
load("#{dir}/#{h}", true) # try to know error line number.
|
|
222
228
|
raise "Can't load #{dir}/#{h} / line# unknown"
|
|
223
229
|
end
|
|
224
230
|
module_names << module_name
|
|
225
231
|
end
|
|
226
232
|
|
|
227
|
-
return
|
|
233
|
+
return result
|
|
228
234
|
end
|
|
229
235
|
private :load_anonymous
|
|
230
236
|
|
data/lib/smallcage/renderer.rb
CHANGED
|
@@ -11,8 +11,13 @@ class SmallCage::Renderer
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def render_string(str, obj)
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
begin
|
|
15
|
+
erb_class = ERB.new(str, nil, '-').def_class(@loader.erb_base, "erb")
|
|
16
|
+
result = erb_class.new(@loader, self, obj).erb
|
|
17
|
+
rescue => e
|
|
18
|
+
STDERR.puts "Can't render: #{obj["uri"]}"
|
|
19
|
+
raise e
|
|
20
|
+
end
|
|
16
21
|
return result
|
|
17
22
|
end
|
|
18
23
|
|
data/lib/smallcage/version.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module SmallCage
|
|
2
|
+
class CacheFilter
|
|
3
|
+
|
|
4
|
+
def initialize(opts)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def after_rendering_filter(obj, str)
|
|
8
|
+
str.gsub %r{(\s(?:src|href)=["'])(?!https?://)([^"']+--latest\.(?:css|js|png|gif|jpg))(["'])} do
|
|
9
|
+
pre = $1
|
|
10
|
+
path = $2
|
|
11
|
+
pro = $3
|
|
12
|
+
dir = obj["dirs"][path[0] == ?/ ? 0 : -1]["path"]
|
|
13
|
+
pre + find_latest(dir, path) + pro
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def find_latest(dir, path)
|
|
18
|
+
relpath = path[0] == ?/ ? path[1..-1] : path
|
|
19
|
+
return path unless (dir + relpath).exist?
|
|
20
|
+
|
|
21
|
+
rex = /^(.+)--latest(\.[^.]+)$/
|
|
22
|
+
pattern = relpath.to_s.sub(rex, '\1-*\2')
|
|
23
|
+
|
|
24
|
+
entry = nil
|
|
25
|
+
Dir.chdir(dir) do
|
|
26
|
+
entry = Dir.glob(pattern).reject {|f| f == relpath }.sort.last
|
|
27
|
+
end
|
|
28
|
+
return path unless entry
|
|
29
|
+
|
|
30
|
+
entry = "/" + entry if path[0] == ?/
|
|
31
|
+
return entry
|
|
32
|
+
end
|
|
33
|
+
private :find_latest
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :cache do
|
|
3
|
+
|
|
4
|
+
task :update do
|
|
5
|
+
require "rexml/document"
|
|
6
|
+
list = FileList["**/*--latest.{css,js,png,gif,jpg}"]
|
|
7
|
+
|
|
8
|
+
list.each do |path|
|
|
9
|
+
src = %x{svn info --xml #{path}}
|
|
10
|
+
begin
|
|
11
|
+
doc = REXML::Document.new(src)
|
|
12
|
+
revision = doc.elements['/info/entry/commit/@revision'].value
|
|
13
|
+
rescue
|
|
14
|
+
puts "Can't get revision number: #{path}"
|
|
15
|
+
end
|
|
16
|
+
to = path.pathmap("%{--latest$,-#{revision}}X%x")
|
|
17
|
+
if File.exist?(to)
|
|
18
|
+
puts " SKIP(exists): #{path} -> #{to}"
|
|
19
|
+
next
|
|
20
|
+
else
|
|
21
|
+
puts " COPY: #{path} -> #{to}"
|
|
22
|
+
end
|
|
23
|
+
unless ENV["DRYRUN"]
|
|
24
|
+
next if File.exist?(to)
|
|
25
|
+
begin
|
|
26
|
+
FileUtils.copy(path,to)
|
|
27
|
+
rescue => e
|
|
28
|
+
puts " ERROR: #{e} #{path} -> #{to}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
data/project/rake/_smc/Rakefile
CHANGED
|
@@ -4,65 +4,10 @@ require 'pathname'
|
|
|
4
4
|
require 'rubygems'
|
|
5
5
|
require 'smallcage'
|
|
6
6
|
|
|
7
|
+
FileList["_smc/rakelib/*.rake"].each {|f| load f }
|
|
8
|
+
|
|
7
9
|
task :default => :smcupdate
|
|
8
10
|
|
|
9
11
|
task :smcupdate do
|
|
10
12
|
system "smc update"
|
|
11
13
|
end
|
|
12
|
-
|
|
13
|
-
def load_svnignores(loader, path)
|
|
14
|
-
dirs = loader.load_dirs(Pathname.new(path) + "child_dummy") # TODO
|
|
15
|
-
ignores = []
|
|
16
|
-
dirs.reverse.each do |d|
|
|
17
|
-
data = d["svnignore"]
|
|
18
|
-
ignores << data unless data.to_s.empty?
|
|
19
|
-
break if d["svnignore_reset"]
|
|
20
|
-
end
|
|
21
|
-
data = dirs.last["svnignore_current"]
|
|
22
|
-
unless data.to_s.empty?
|
|
23
|
-
ignores << data
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
ignores.flatten!
|
|
27
|
-
ignores.uniq!
|
|
28
|
-
ignores.sort!
|
|
29
|
-
return ignores
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def set_svnignore(dryrun = false)
|
|
33
|
-
loader = SmallCage::Loader.new(".")
|
|
34
|
-
|
|
35
|
-
exec_svn(loader, ".", dryrun)
|
|
36
|
-
Dir.glob("**/") do |f|
|
|
37
|
-
exec_svn(loader, f, dryrun)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def exec_svn(loader, f, dryrun)
|
|
42
|
-
return if f =~ %r{^_smc/}
|
|
43
|
-
svnignores = load_svnignores(loader, f).join("\n")
|
|
44
|
-
return if svnignores.empty?
|
|
45
|
-
cmd = "svn propset svn:ignore '#{svnignores}' #{f}"
|
|
46
|
-
puts cmd
|
|
47
|
-
return if dryrun
|
|
48
|
-
puts "FAILED: #{cmd}" unless system cmd
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# _dir.smc
|
|
52
|
-
# svnignore: *.html # set recursively.
|
|
53
|
-
# svnignore_current: .project # add only current dir.
|
|
54
|
-
# svnignore_reset: true # ignore parent directory settings.
|
|
55
|
-
#
|
|
56
|
-
# You can use list.
|
|
57
|
-
# svnignore:
|
|
58
|
-
# - *.html
|
|
59
|
-
# - *.xml
|
|
60
|
-
desc "svn propset svn:ignore ..."
|
|
61
|
-
task :svnignore do
|
|
62
|
-
set_svnignore
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
desc "confirm svn commands."
|
|
66
|
-
task :svnignore_dryrun do
|
|
67
|
-
set_svnignore(true)
|
|
68
|
-
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :csv do
|
|
3
|
+
|
|
4
|
+
task :require do
|
|
5
|
+
require "csv"
|
|
6
|
+
require "yaml"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# csv_to_smc sample task.
|
|
10
|
+
task :sample_update => [:require] do
|
|
11
|
+
csv_to_smc("_smc/sample.csv") {|data,rownum| "path/to/contents/#{"%04d" % (rownum - 1)}_#{data["key"]}.smc" }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def csv_to_smc(csv_file, label_row = 0, skip_rows = 1)
|
|
18
|
+
labels = nil
|
|
19
|
+
rownum = -1
|
|
20
|
+
CSV.foreach(csv_file) do |row|
|
|
21
|
+
rownum += 1
|
|
22
|
+
labels = row if label_row == rownum
|
|
23
|
+
next if rownum < skip_rows
|
|
24
|
+
|
|
25
|
+
if labels
|
|
26
|
+
data = {}
|
|
27
|
+
labels.each_with_index do |label,i|
|
|
28
|
+
data[label] = row[i].to_s
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
data = row.map {|cell| cell.to_s }
|
|
32
|
+
end
|
|
33
|
+
if block_given?
|
|
34
|
+
fname = yield(data,rownum)
|
|
35
|
+
else
|
|
36
|
+
fname = data[0]
|
|
37
|
+
end
|
|
38
|
+
File.open(fname, "w") do |io|
|
|
39
|
+
io << data.to_yaml
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :svn do
|
|
3
|
+
|
|
4
|
+
# _dir.smc
|
|
5
|
+
# svnignore: *.html # set recursively.
|
|
6
|
+
# svnignore_current: .project # add only current dir.
|
|
7
|
+
# svnignore_reset: true # ignore parent directory settings.
|
|
8
|
+
#
|
|
9
|
+
# You can use list.
|
|
10
|
+
# svnignore:
|
|
11
|
+
# - *.html
|
|
12
|
+
# - *.xml
|
|
13
|
+
desc "svn propset svn:ignore ..."
|
|
14
|
+
task :ignore do
|
|
15
|
+
set_svnignore
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "confirm svn commands."
|
|
19
|
+
task :ignore_dryrun do
|
|
20
|
+
set_svnignore(true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def load_svnignores(loader, path)
|
|
28
|
+
dirs = loader.load_dirs(Pathname.new(path) + "child_dummy") # XXX
|
|
29
|
+
ignores = []
|
|
30
|
+
dirs.reverse.each do |d|
|
|
31
|
+
data = d["svnignore"]
|
|
32
|
+
ignores << data unless data.to_s.empty?
|
|
33
|
+
break if d["svnignore_reset"]
|
|
34
|
+
end
|
|
35
|
+
data = dirs.last["svnignore_current"]
|
|
36
|
+
unless data.to_s.empty?
|
|
37
|
+
ignores << data
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
ignores.flatten!
|
|
41
|
+
ignores.uniq!
|
|
42
|
+
ignores.sort!
|
|
43
|
+
return ignores
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def set_svnignore(dryrun = false)
|
|
47
|
+
loader = SmallCage::Loader.new(".")
|
|
48
|
+
|
|
49
|
+
exec_svn(loader, ".", dryrun)
|
|
50
|
+
Dir.glob("**/") do |f|
|
|
51
|
+
exec_svn(loader, f, dryrun)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def exec_svn(loader, f, dryrun)
|
|
56
|
+
return if f =~ %r{^_smc/}
|
|
57
|
+
svnignores = load_svnignores(loader, f).join("\n")
|
|
58
|
+
return if svnignores.empty?
|
|
59
|
+
cmd = "svn propset svn:ignore '#{svnignores}' #{f}"
|
|
60
|
+
puts cmd
|
|
61
|
+
return if dryrun
|
|
62
|
+
puts "FAILED: #{cmd}" unless system cmd
|
|
63
|
+
end
|
|
64
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
----------------------------------------------------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
================================================================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
template: include2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
template
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
template
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
template
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
=== vars ===
|
|
2
|
+
|
|
3
|
+
<%- (@obj.keys - %w{template uri path strings arrays body dirs}).sort.each do |key| -%>
|
|
4
|
+
* <%= key %> <%= @obj[key].inspect %>
|
|
5
|
+
<%- end -%>
|
|
6
|
+
|
|
7
|
+
=== special variables ===
|
|
8
|
+
|
|
9
|
+
* template <%= template.inspect %>
|
|
10
|
+
* uri <%= uri.inspect %>
|
|
11
|
+
* uri.smc <%= uri.smc.inspect %>
|
|
12
|
+
* path <%= path.inspect %>
|
|
13
|
+
* path.smc <%= path.smc.inspect %>
|
|
14
|
+
* strings <%= strings.inspect %>
|
|
15
|
+
* arrays <%= arrays.inspect %>
|
|
16
|
+
* body <%= body.inspect %>
|
|
17
|
+
|
|
18
|
+
=== directory info ===
|
|
19
|
+
|
|
20
|
+
<%- dirs.each_with_index do |dir,i| -%>
|
|
21
|
+
* dirs[<%= i %>]
|
|
22
|
+
<%- dir.keys.sort.each do |k| -%>
|
|
23
|
+
* dirs[<%= i %>]["<%= k %>"] <%= dir[k].inspect %>
|
|
24
|
+
<%- end %>
|
|
25
|
+
<%- end -%>
|
|
26
|
+
=== smc object ===
|
|
27
|
+
|
|
28
|
+
* @obj.class.name <%= @obj.class.name %>
|
|
29
|
+
* @obj.keys.inspect <%= @obj.keys.inspect %>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
template: smc_variables
|
|
2
|
+
title: How smc file convert into smc object.
|
|
3
|
+
array_sample:
|
|
4
|
+
- item1
|
|
5
|
+
- item2
|
|
6
|
+
overwrite: OVER
|
|
7
|
+
--- |
|
|
8
|
+
text part 1.
|
|
9
|
+
foo bar
|
|
10
|
+
---
|
|
11
|
+
- AAA
|
|
12
|
+
- BBB
|
|
13
|
+
- CCC
|
|
14
|
+
---
|
|
15
|
+
- 111
|
|
16
|
+
- 222
|
|
17
|
+
- 333
|
|
18
|
+
--- |
|
|
19
|
+
text part 2.
|
|
20
|
+
baz baz
|
|
21
|
+
---
|
|
22
|
+
hash_sample:
|
|
23
|
+
key1: value-A
|
|
24
|
+
key2: value-B
|
|
25
|
+
note: All YAML hash documents gather into one hash value.
|
|
26
|
+
overwrite: WRITE
|
data/spec/data/htdocs1/_dir.smc
CHANGED
data/spec/loader_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe SmallCage::Loader do
|
|
|
7
7
|
@docroot = Pathname.new(File.dirname(__FILE__) + "/data/htdocs1")
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
it "should load path value which
|
|
10
|
+
it "should load path value which is instance of Pathname" do
|
|
11
11
|
ldr = SmallCage::Loader.new(@docroot)
|
|
12
12
|
obj = ldr.load(@docroot + "a/b/c/index.html.smc")
|
|
13
13
|
|
|
@@ -52,4 +52,38 @@ describe SmallCage::Loader do
|
|
|
52
52
|
end
|
|
53
53
|
objects[0]["strings"][0].should == "abc\ndef\n\nghi"
|
|
54
54
|
end
|
|
55
|
+
|
|
56
|
+
it "should load body value which equals strings[0]" do
|
|
57
|
+
ldr = SmallCage::Loader.new(@docroot)
|
|
58
|
+
obj = ldr.load(@docroot + "a/b/c/index.html.smc")
|
|
59
|
+
|
|
60
|
+
obj["strings"][0].should == "abc\ndef\n\nghi"
|
|
61
|
+
obj["body"].should == obj["strings"][0]
|
|
62
|
+
|
|
63
|
+
# same String instance
|
|
64
|
+
obj["strings"][0].replace("XXX")
|
|
65
|
+
obj["body"].should == "XXX"
|
|
66
|
+
|
|
67
|
+
obj["strings"][0] = "ABC"
|
|
68
|
+
obj["body"].should == "XXX"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should load dirs" do
|
|
72
|
+
ldr = SmallCage::Loader.new(@docroot)
|
|
73
|
+
obj = ldr.load(@docroot + "a/b/c/index.html.smc")
|
|
74
|
+
|
|
75
|
+
dirs = obj["dirs"]
|
|
76
|
+
dirs.length.should == 4
|
|
77
|
+
|
|
78
|
+
dirs[0]["uri"].should == "/"
|
|
79
|
+
dirs[1]["uri"].should == "/a/"
|
|
80
|
+
dirs[2]["uri"].should == "/a/b/"
|
|
81
|
+
dirs[3]["uri"].should == "/a/b/c/"
|
|
82
|
+
(dirs[3]["path"] + "index.html.smc").file?.should be_true
|
|
83
|
+
|
|
84
|
+
dirs[0]["var"].should == "xxx"
|
|
85
|
+
dirs[0]["strings"][0].should == "BODYBODYBODY"
|
|
86
|
+
dirs[0]["body"].should == "BODYBODYBODY"
|
|
87
|
+
end
|
|
88
|
+
|
|
55
89
|
end
|
data/spec/manifest_spec.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
require 'smallcage'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
4
|
describe "SmallCage::Commands::Manifest" do
|
|
7
5
|
|
|
8
6
|
before do
|
|
@@ -17,18 +15,20 @@ describe "SmallCage::Commands::Manifest" do
|
|
|
17
15
|
@manifest_file.file?.should be_true
|
|
18
16
|
|
|
19
17
|
source = @manifest_file.read
|
|
20
|
-
source.
|
|
21
|
-
|
|
18
|
+
source = source.match(%r{<ul class="files">\n(.+?)\n</ul>}m)[1].split(/\n/)
|
|
19
|
+
|
|
20
|
+
contents = <<'EOT'.split(/\n/)
|
|
21
|
+
<li><a href="./_dir.smc">./_dir.smc</a></li>
|
|
22
|
+
<li><a href="./_smc/">./_smc/</a></li>
|
|
22
23
|
<li><a href="./a/">./a/</a></li>
|
|
23
24
|
<li><a href="./a/b/">./a/b/</a></li>
|
|
24
25
|
<li><a href="./a/b/c/">./a/b/c/</a></li>
|
|
25
26
|
<li><a href="./a/b/c/index.html.smc">./a/b/c/index.html.smc</a></li>
|
|
26
|
-
<li><a href="./_dir.smc">./_dir.smc</a></li>
|
|
27
|
-
<li><a href="./_smc/">./_smc/</a></li>
|
|
28
|
-
<li><a href="./_smc/helpers/">./_smc/helpers/</a></li>
|
|
29
|
-
<li><a href="./_smc/templates/">./_smc/templates/</a></li>
|
|
30
|
-
</ul>
|
|
31
27
|
EOT
|
|
28
|
+
|
|
29
|
+
source.each do |line|
|
|
30
|
+
contents.should include(line)
|
|
31
|
+
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
after do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bluemark-smallcage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SAITO Toshihiro
|
|
@@ -11,7 +11,7 @@ autorequire:
|
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
13
|
|
|
14
|
-
date: 2009-
|
|
14
|
+
date: 2009-07-27 00:00:00 -07:00
|
|
15
15
|
default_executable: smc
|
|
16
16
|
dependencies: []
|
|
17
17
|
|
|
@@ -53,8 +53,6 @@ files:
|
|
|
53
53
|
- lib/smallcage/runner.rb
|
|
54
54
|
- lib/smallcage/version.rb
|
|
55
55
|
- lib/smallcage.rb
|
|
56
|
-
- test/test_helper.rb
|
|
57
|
-
- test/test_smallcage.rb
|
|
58
56
|
- project/base
|
|
59
57
|
- project/base/_smc
|
|
60
58
|
- project/base/_smc/helpers
|
|
@@ -70,6 +68,13 @@ files:
|
|
|
70
68
|
- project/bluecloth/_smc/helpers/blue_cloth_helper.rb
|
|
71
69
|
- project/bluecloth/_smc/templates
|
|
72
70
|
- project/bluecloth/_smc/templates/markdown.rhtml
|
|
71
|
+
- project/cache
|
|
72
|
+
- project/cache/_smc
|
|
73
|
+
- project/cache/_smc/filters
|
|
74
|
+
- project/cache/_smc/filters/cache_filter.rb
|
|
75
|
+
- project/cache/_smc/filters/filters.yml
|
|
76
|
+
- project/cache/_smc/rakelib
|
|
77
|
+
- project/cache/_smc/rakelib/cache.rake
|
|
73
78
|
- project/lang
|
|
74
79
|
- project/lang/_smc
|
|
75
80
|
- project/lang/_smc/helpers
|
|
@@ -88,6 +93,9 @@ files:
|
|
|
88
93
|
- project/rake
|
|
89
94
|
- project/rake/_smc
|
|
90
95
|
- project/rake/_smc/Rakefile
|
|
96
|
+
- project/rake/_smc/rakelib
|
|
97
|
+
- project/rake/_smc/rakelib/csv.rake
|
|
98
|
+
- project/rake/_smc/rakelib/svn.rake
|
|
91
99
|
- project/redcloth
|
|
92
100
|
- project/redcloth/_smc
|
|
93
101
|
- project/redcloth/_smc/helpers
|
|
@@ -126,9 +134,34 @@ files:
|
|
|
126
134
|
- project/standard/sample/sub/_dir.smc
|
|
127
135
|
- project/standard/sample/sub/contents.html.smc
|
|
128
136
|
- project/standard/sample/sub/index.html.smc
|
|
137
|
+
- project/tutorial
|
|
138
|
+
- project/tutorial/_smc
|
|
139
|
+
- project/tutorial/_smc/helpers
|
|
140
|
+
- project/tutorial/_smc/helpers/sample_helper.rb
|
|
141
|
+
- project/tutorial/_smc/templates
|
|
142
|
+
- project/tutorial/_smc/templates/default.rhtml
|
|
143
|
+
- project/tutorial/_smc/templates/include1.rhtml
|
|
144
|
+
- project/tutorial/_smc/templates/include2.rhtml
|
|
145
|
+
- project/tutorial/sample.txt.smc
|
|
146
|
+
- project/tutorial/sample2.txt.smc
|
|
147
|
+
- project/tutorial2
|
|
148
|
+
- project/tutorial2/_smc
|
|
149
|
+
- project/tutorial2/_smc/helpers
|
|
150
|
+
- project/tutorial2/_smc/helpers/priority_sample_helper.rb
|
|
151
|
+
- project/tutorial2/_smc/templates
|
|
152
|
+
- project/tutorial2/_smc/templates/priorities.rhtml
|
|
153
|
+
- project/tutorial2/_smc/templates/priority1.rhtml
|
|
154
|
+
- project/tutorial2/_smc/templates/priority2.rhtml
|
|
155
|
+
- project/tutorial2/_smc/templates/priority3.rhtml
|
|
156
|
+
- project/tutorial2/_smc/templates/smc_variables.rhtml
|
|
157
|
+
- project/tutorial2/tutorial2
|
|
158
|
+
- project/tutorial2/tutorial2/_dir.smc
|
|
159
|
+
- project/tutorial2/tutorial2/priorities.txt.smc
|
|
160
|
+
- project/tutorial2/tutorial2/vars.txt.smc
|
|
129
161
|
- spec/data
|
|
130
162
|
- spec/data/htdocs1
|
|
131
163
|
- spec/data/htdocs1/_dir.smc
|
|
164
|
+
- spec/data/htdocs1/_smc
|
|
132
165
|
- spec/data/htdocs1/a
|
|
133
166
|
- spec/data/htdocs1/a/b
|
|
134
167
|
- spec/data/htdocs1/a/b/c
|
|
@@ -152,8 +185,9 @@ files:
|
|
|
152
185
|
- spec/smallcage_spec.rb
|
|
153
186
|
- spec/spec.opts
|
|
154
187
|
- spec/spec_helper.rb
|
|
155
|
-
has_rdoc:
|
|
188
|
+
has_rdoc: false
|
|
156
189
|
homepage: http://www.smallcage.org
|
|
190
|
+
licenses:
|
|
157
191
|
post_install_message:
|
|
158
192
|
rdoc_options:
|
|
159
193
|
- --title
|
|
@@ -185,9 +219,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
185
219
|
requirements: []
|
|
186
220
|
|
|
187
221
|
rubyforge_project: smallcage
|
|
188
|
-
rubygems_version: 1.
|
|
222
|
+
rubygems_version: 1.3.5
|
|
189
223
|
signing_key:
|
|
190
|
-
specification_version:
|
|
224
|
+
specification_version: 3
|
|
191
225
|
summary: Lightweight CMS package.
|
|
192
|
-
test_files:
|
|
193
|
-
|
|
226
|
+
test_files:
|
|
227
|
+
- spec/document_path_spec.rb
|
|
228
|
+
- spec/export_spec.rb
|
|
229
|
+
- spec/import_spec.rb
|
|
230
|
+
- spec/loader_spec.rb
|
|
231
|
+
- spec/manifest_spec.rb
|
|
232
|
+
- spec/misc_spec.rb
|
|
233
|
+
- spec/smallcage_spec.rb
|
data/test/test_helper.rb
DELETED