rollin 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c42e39cf96b5575f103f7885c082ca34738d6f4
4
- data.tar.gz: d8da97fee1a7a1f8489d8a4da9b9b043be626ec1
3
+ metadata.gz: b6ef7f3be9c83a460825f763d4c06d1b2b0ac1a6
4
+ data.tar.gz: ab3c26c1af266bb7ca8caf4ef57e9e6c15b02548
5
5
  SHA512:
6
- metadata.gz: cb5cd590651843b97c3d957c88cbb71111cd112c233c31512f9edb56fb27548df8317b2d4a30f3fbecda3b2b3e93c5d519130aa275af22f456e72f6175ba3b3d
7
- data.tar.gz: 6d30a7d567ff2ffa02d8edaf9cacc7f84b5f18551383fe0047c033658c81deeb4b0c4a732370a19d284904fb87bb7656ae17cb6d4963c7f29c02922d7d260ff5
6
+ metadata.gz: 5b52239b44ea70fd8e6d887f36958600aaa4183ee42bb34a2b3212a1cbb73919f1ba111b26f19ca688877d23c0bdc36d83e844189c6770ba48a18c7a78d37b37
7
+ data.tar.gz: e4c68146f52c7edce5aad218527fcf0e06b4011cc4569ff36a47fe1615c5eee9ab5e1239b1defce396f71df57bb0e2655a208051e67718b010d79c0d26de7f2e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -1,10 +1,11 @@
1
1
  class Rollin::Article
2
- attr_reader :title, :year, :month, :day
2
+ attr_reader :id, :title, :year, :month, :day
3
3
 
4
4
  def initialize(source_file)
5
5
  @source_file = source_file
6
6
  filename = File.basename(@source_file)
7
- @title = filename[11, filename.length - 11].gsub('_', ' ')
7
+ @id = filename[0, filename.length - 3]
8
+ @title = filename[11, filename.length - 11 - 3].gsub('_', ' ')
8
9
  @year = filename[0, 4].to_i
9
10
  @month = filename[5, 2].to_i
10
11
  @day = filename[8, 2].to_i
data/lib/rollin/blog.rb CHANGED
@@ -3,6 +3,10 @@ class Rollin::Blog
3
3
  @articles_folder = options[:articles_folder] || 'articles'
4
4
  end
5
5
 
6
+ def find_article_by_id(article_id)
7
+ articles.find { |article| article.id == article_id }
8
+ end
9
+
6
10
  def articles
7
11
  Dir["#{@articles_folder}/**/*.mk"].sort.map do |article_source|
8
12
  Rollin::Article.new(article_source)
data/spec/article_spec.rb CHANGED
@@ -3,8 +3,12 @@ require './spec/spec_helper'
3
3
  describe Rollin::Article do
4
4
  subject (:article) { Rollin::Article.new('spec/fixtures/articles/2013_05_01_My_first_post.mk') }
5
5
 
6
+ it 'tells article id' do
7
+ article.id.should == '2013_05_01_My_first_post'
8
+ end
9
+
6
10
  it 'tells article title' do
7
- article.title == 'My first post'
11
+ article.title.should == 'My first post'
8
12
  end
9
13
 
10
14
  it 'compiles article body to html' do
data/spec/blog_spec.rb CHANGED
@@ -11,5 +11,9 @@ describe Rollin::Blog do
11
11
  it 'has the right amount of monthly archives' do
12
12
  blog.monthly_archive.size.should == 2
13
13
  end
14
+
15
+ it 'finds article by its id' do
16
+ blog.find_article_by_id('2013_05_01_My_first_post').title.should == 'My first post'
17
+ end
14
18
  end
15
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - marano