Top Level Namespace
Defined Under Namespace
Modules: Behaviors, Bloggit
Classes: Action, FixedHoe, Hash, Json, Main, String
Constant Summary
collapse
- SVN =
ENV['SCM'] || 'svk'
- VERBOSE =
true
- PLUGIN_BOILERPLATE =
<<EOF
# = Examples for creating your own plugins...
include Bloggit
# = Registering the plugin to retrieve settings from settings.yml
Plugin.register :example do |settings|
# this will read from the settings.yml under plugins.example
# $username = settings.fetch('username', '')
end
# = Registering custom tags in the template engine
#
# This will register the tag `example` for use in any template page
# (including layouts). Example usage of this tag:
#
# <%= example :version %>
#
# Output:
#
# Bloggit 1.0.0
#
Template.register_tag :example do |*args|
kind, opts = args
opts ||= {}
case kind
when :version
"Bloggit "+ Bloggit::RELEASE_INFO
else
"Unknown tag "+ kind
end
end
# = Responding to application events...
Bloggit::on_event(:after_generate) do |site, cache_dir|
# puts "I'm called after the rest of the site has been generated..."
end
# = Adding a command line tool...
Cmdline.register do |cmd, site|
example_cmd = CmdParse::Command.new( 'example', true, true )
example_cmd.short_desc = "Example tool from plugin"
cmd.add_command( example_cmd )
sub_cmd = CmdParse::Command.new( 'sub', false )
sub_cmd.short_desc = "A sub command"
sub_cmd.set_execution_block do |args|
puts "Sub-command has been called, w00t!"
end
example_cmd.add_command( sub_cmd )
end
# = Registering a custom text format:
begin
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'
Bloggit::TextFormatter.register :rdoc do |text|
p = SM::SimpleMarkup.new
h = SM::ToHtml.new
p.convert(text, h)
end
rescue LoadError
puts "There was an error registering the :rdoc text format:"+ $!
end
EOF
- NOISE_WORDS =
%w(about after all also an and another any are as at be because been before
being between both but by came can come could did do each for from get
got has had he have her here him himself his how if in into is it like
make many me might more most much must my never now of on only or other
our out over said same see should since some still such take than that
the their them then there these they this those through to too under up
very was way we well were what where which while who with would you your a
b c d e f g h i j k l m n o p q r s t u v w x y z $ 1 2 3 4 5 6 7 8 9 0 _)
Instance Method Summary
collapse
Instance Method Details
#add(dir) ⇒ Object
29
30
31
|
# File 'lib/bloggit/tasks/scm.rb', line 29
def add(dir)
sh %(#{SVN} add #{dir})
end
|
#project_name ⇒ Object
42
43
44
|
# File 'lib/bloggit/tasks/scm.rb', line 42
def project_name
File.basename(File.expand_path(RAILS_ROOT))
end
|
#propset(prop, value, *targets) ⇒ Object
25
26
27
|
# File 'lib/bloggit/tasks/scm.rb', line 25
def propset(prop, value, *targets)
sh %(#{SVN} propset #{prop} "#{value}" #{targets.join(' ')})
end
|
#remove(file) ⇒ Object
33
34
35
36
|
# File 'lib/bloggit/tasks/scm.rb', line 33
def remove(file)
sh %(#{SVN} revert #{file})
sh %(#{SVN} delete #{file})
end
|
#scm_processor(mode, no_targets_msg = "Nothing to do") ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/bloggit/tasks/scm.rb', line 46
def scm_processor(mode, no_targets_msg="Nothing to do")
raise "Requires mode :add or :remove" if mode.nil? or ![:add,:remove].include?(mode)
re = (mode == :add) ? [ /^\?/, /^\?\s*/ ] : [ /^\!/, /^\!\s*/ ]
files = stat.select{ |e| re[0] =~ e}.collect{|e| e.sub(re[1], '').chomp }
puts
if files.length == 0
puts no_targets_msg
else
files.map {|f| puts " #{f}"}
print "\n#{mode.to_s.capitalize} all of these? (y/n/i) : "
affected_files = 0
if STDIN.gets =~ /^(y|i)/i
case $1.downcase
when 'y'
(mode == :add) ? add(files.join(' ')) : files.map { |f| remove(f) }
affected_files = files.length
when 'i'
puts "\n[Interactive Mode]\n"
files.each do |file|
print "#{mode.to_s.capitalize} '#{file}'? (y/n) : "
if /^y/i =~ STDIN.gets
(mode == :add) ? add(file) : remove(file)
affected_files += 1
else
puts "Ignored"
end
end
end
end
puts "\n#{affected_files} file(s) affected, #{files.length - affected_files} ignored"
end
puts
end
|
#stat ⇒ Object
38
39
40
|
# File 'lib/bloggit/tasks/scm.rb', line 38
def stat
`#{SVN} stat`
end
|