Module: Blogpostify

Defined in:
lib/blogpostify.rb,
lib/blogpostify/blog.rb,
lib/blogpostify/post.rb,
lib/blogpostify/engine.rb,
lib/blogpostify/version.rb,
lib/blogpostify/view_helpers.rb

Defined Under Namespace

Modules: ViewHelpers Classes: Blog, BlogNotFoundError, Configuration, Engine, Post

Constant Summary collapse

VERSION =
"1.1.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



25
26
27
# File 'lib/blogpostify.rb', line 25

def configuration
  @configuration
end

Class Method Details

.blogsObject



46
47
48
# File 'lib/blogpostify.rb', line 46

def blogs
  configuration.blogs
end

.configure {|configuration| ... } ⇒ Object

Yields:



27
28
29
30
# File 'lib/blogpostify.rb', line 27

def configure
  self.configuration ||= Configuration.new
  yield configuration
end

.find_blog!(blog_short_name) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/blogpostify.rb', line 32

def find_blog!(blog_short_name)
  blog_short_name = blog_short_name.to_s

  found_blog = blogs.find do |blog|
    blog.short_name == blog_short_name
  end

  if found_blog.nil?
    raise BlogNotFoundError, "Blog #{blog_short_name} is not configured. Check Blogpostify#blogs." 
  else
    found_blog
  end
end

.update_blog(blog_name) ⇒ Object



56
57
58
# File 'lib/blogpostify.rb', line 56

def update_blog(blog_name)
  find_blog!(blog_name).update_posts
end

.update_blogsObject



50
51
52
53
54
# File 'lib/blogpostify.rb', line 50

def update_blogs
  blogs.flat_map do |blog|
    blog.update_posts
  end
end