Class: Octopress::Isolate
- Inherits:
-
Object
- Object
- Octopress::Isolate
- Defined in:
- lib/octopress/isolate.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #default_array(input) ⇒ Object
- #find_other_posts(path) ⇒ Object
-
#initialize(options) ⇒ Isolate
constructor
A new instance of Isolate.
- #integrate ⇒ Object
- #isolate ⇒ Object
Constructor Details
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
5 6 7 |
# File 'lib/octopress/isolate.rb', line 5 def site @site end |
Instance Method Details
#default_array(input) ⇒ Object
48 49 50 51 52 |
# File 'lib/octopress/isolate.rb', line 48 def default_array(input) i = input || [] i = [i] unless i.is_a?(Array) i end |
#find_other_posts(path) ⇒ Object
44 45 46 |
# File 'lib/octopress/isolate.rb', line 44 def find_other_posts(path) CommandHelpers.find_posts.reject { |p| p == path } end |
#integrate ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/octopress/isolate.rb', line 12 def integrate dir = File.join(site.source, '_posts') exile_dir = File.join(dir, '_exile') if Dir.exist?(exile_dir) posts = CommandHelpers.find_exiled_posts if posts.size > 0 FileUtils.mv(posts, dir) FileUtils.rmdir(File.join(dir, '_exile')) puts "Reintegrated #{posts.size} post#{'s' if posts.size != 1} from _posts/_exile" else abort "There aren't any posts in _posts/_exile." end else abort "There aren't any posts in _posts/_exile." end end |
#isolate ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/octopress/isolate.rb', line 30 def isolate post = File.(@options['path']) if @options['path'] others = (post ? find_other_posts(post) : CommandHelpers.find_posts) exile_dir = File.join(site.source, '_posts/_exile') FileUtils.mkdir_p(exile_dir) FileUtils.mv(others, exile_dir) count = (post ? others.size : "all #{others.size}") puts "Moved #{count} post#{'s' if others.size != 1} into _posts/_exile" puts "Isolated: " << "#{post.sub(Octopress.site.source + '/_posts/', '')}".yellow if post end |