module Writefully::Source
Public Class Methods
content_path()
click to toggle source
# File lib/writefully/source.rb, line 7 def content_path Writefully.options[:content] end
models_path()
click to toggle source
# File lib/writefully/source.rb, line 11 def models_path File.join(Writefully.options[:app_directory], 'app', 'models') end
sample_content(file)
click to toggle source
# File lib/writefully/source.rb, line 15 def sample_content file open(File.dirname(__FILE__) + "/../sample/#{file}").read end
sample_content_paths()
click to toggle source
# File lib/writefully/source.rb, line 19 def sample_content_paths valid_resources.map do |resource| ["#{resource}/1-change-me/README.md", "#{resource}/1-change-me/meta.yml", "#{resource}/1-change-me/assets/writefully.png"] end.flatten end
sample_content_properties(file)
click to toggle source
# File lib/writefully/source.rb, line 27 def sample_content_properties file { path: file, content: sample_content(file), message: "added sample #{file}" } end
skim_for(matcher)
click to toggle source
# File lib/writefully/source.rb, line 43 def skim_for matcher Dir.chdir(models_path) do Dir.glob('*').select do |file| open(File.join(models_path, file)).read.strip.match(matcher) if File.file?(file) end.collect { |file| file.split('.')[0] } end end
to_load()
click to toggle source
# File lib/writefully/source.rb, line 39 def to_load skim_for ::Regexp.new('Writefully') end
valid_resources()
click to toggle source
# File lib/writefully/source.rb, line 35 def valid_resources skim_for(::Regexp.new('Writefully::Post')).map { |r| r.pluralize } end