Module: ActiveCopy::Paths
- Included in:
- Base
- Defined in:
- lib/active_copy/paths.rb
Instance Method Summary collapse
-
#collection_path ⇒ Object
Return the collection_path in the instance.
-
#index_path ⇒ Object
Return absolute path to public HTML file.
-
#path ⇒ Object
Return absolute path to public cached copy.
-
#relative_path ⇒ Object
Return relative path with the Rails.root/public part out.
-
#source_path(options = {}) ⇒ Object
Return absolute path to Markdown file on this machine.
Instance Method Details
#collection_path ⇒ Object
Return the collection_path in the instance.
18 19 20 |
# File 'lib/active_copy/paths.rb', line 18 def collection_path self.class.collection_path end |
#index_path ⇒ Object
Return absolute path to public HTML file.
4 5 6 |
# File 'lib/active_copy/paths.rb', line 4 def index_path "#{path}/index.html" end |
#path ⇒ Object
Return absolute path to public cached copy.
9 10 11 12 13 14 15 |
# File 'lib/active_copy/paths.rb', line 9 def path @public_path ||= if Rails.env.test? "#{Rails.root}/tmp/site/#{relative_path}" else "#{Rails.root}/public/#{relative_path}" end end |
#relative_path ⇒ Object
Return relative path with the Rails.root/public part out.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_copy/paths.rb', line 23 def relative_path @rel_path ||= begin date_array = id.split("-")[0..2] date_path = date_array.join("/") article_id = begin str = id.gsub date_array.join("-"), '' if str[0] == "-" str[1..-1] else str end end "#{category}/#{date_path}/#{article_id}" end end |
#source_path(options = {}) ⇒ Object
Return absolute path to Markdown file on this machine.
40 41 42 43 44 45 46 |
# File 'lib/active_copy/paths.rb', line 40 def source_path ={} @source_path ||= if [:relative] File.join collection_path, "#{self.id}.md" else File.join root_path, collection_path, "#{self.id}.md" end end |