Module: Writefully::Source
- Defined in:
- lib/writefully/source.rb
Class Method Summary collapse
- .content_path ⇒ Object
- .models_path ⇒ Object
- .sample_content(file) ⇒ Object
- .sample_content_paths ⇒ Object
- .sample_content_properties(file) ⇒ Object
- .skim_for(matcher) ⇒ Object
- .to_load ⇒ Object
- .valid_resources ⇒ Object
Class Method Details
.content_path ⇒ Object
7 8 9 |
# File 'lib/writefully/source.rb', line 7 def content_path Writefully.[:content] end |
.models_path ⇒ Object
11 12 13 |
# File 'lib/writefully/source.rb', line 11 def models_path File.join(Writefully.[:app_directory], 'app', 'models') end |
.sample_content(file) ⇒ Object
15 16 17 |
# File 'lib/writefully/source.rb', line 15 def sample_content file open(File.dirname(__FILE__) + "/../sample/#{file}").read end |
.sample_content_paths ⇒ Object
19 20 21 22 23 24 25 |
# 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) ⇒ Object
27 28 29 30 31 32 33 |
# 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) ⇒ Object
43 44 45 46 47 48 49 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/writefully/source.rb', line 39 def to_load skim_for ::Regexp.new('Writefully') end |
.valid_resources ⇒ Object
35 36 37 |
# File 'lib/writefully/source.rb', line 35 def valid_resources skim_for(::Regexp.new('Writefully::Post')).map { |r| r.pluralize } end |