Class: MrHyde::Blog
- Inherits:
-
Object
- Object
- MrHyde::Blog
- Defined in:
- lib/mr_hyde/blog.rb
Class Method Summary collapse
-
.build(args, opts = {}) ⇒ Object
Builds the blog Params: :name String => builds the concrete blog Array => builds the correspondings blog names empty => It builds all blogs Returns boolean.
- .built?(name, opts) ⇒ Boolean
-
.create(args, opts = {}) ⇒ Object
Creates the directory and necessary files for the blog args :name String => creates the concrete blog Array => creates the correspondings blog names Returns boolean.
- .exist?(name, opts) ⇒ Boolean
- .list(path) ⇒ Object
-
.remove(args, opts = {}) ⇒ Object
Removes the blog directory Params: Hash (String) Returns boolean.
Class Method Details
.build(args, opts = {}) ⇒ Object
Builds the blog Params:
:name
String => builds the concrete blog
Array[String] => builds the correspondings blog names
empty => It builds all blogs
Returns
boolean
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/mr_hyde/blog.rb', line 67 def build(args, opts = {}) args = [args] if args.kind_of? String opts = MrHyde.configuration(opts) if opts["all"] build_blogs list(opts['sources']), opts elsif args.kind_of? Array build_blogs args, opts elsif args.kind_of? String build_blog args end rescue Exception => e MrHyde.logger.error "cannot build site: #{e}" MrHyde.logger.error e.backtrace end |
.built?(name, opts) ⇒ Boolean
93 94 95 |
# File 'lib/mr_hyde/blog.rb', line 93 def built?(name, opts) File.exist? File.join(opts['destination'], name) end |
.create(args, opts = {}) ⇒ Object
Creates the directory and necessary files for the blog args
:name
String => creates the concrete blog
Array[String] => creates the correspondings blog names
Returns
boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mr_hyde/blog.rb', line 18 def create(args, opts = {}) opts = MrHyde.configuration(opts) if args.kind_of? Array and not args.empty? args.each do |bn| begin create_blog(bn, opts) rescue Exception => e raise e unless e.class == SystemExit end end elsif args.kind_of? String create_blog args, opts end rescue Exception => e MrHyde.logger.error "cannot create blog: #{e}" end |
.exist?(name, opts) ⇒ Boolean
89 90 91 |
# File 'lib/mr_hyde/blog.rb', line 89 def exist?(name, opts) File.exist? File.join(opts['sources'], name) end |
.list(path) ⇒ Object
83 84 85 86 87 |
# File 'lib/mr_hyde/blog.rb', line 83 def list(path) entries = Dir.entries(path) entries.reject! { |item| item == '.' or item == '..' } entries end |
.remove(args, opts = {}) ⇒ Object
Removes the blog directory Params:
Hash[:path] (String)
Returns
boolean
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mr_hyde/blog.rb', line 41 def remove(args, opts = {}) opts = MrHyde.configuration(opts) if opts['all'] list(opts['sources']).each do |sm| remove_blog sm, opts end elsif args.kind_of? Array args.each do |sm| remove_blog sm, opts end else remove_blog args, opts end rescue Exception => e MrHyde.logger.error "cannot remove the blog: #{e}" end |