ignoramos 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +18 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +8 -0
- data/bin/ignoramos +5 -0
- data/ignoramos.gemspec +22 -0
- data/lib/commands/build_command.rb +188 -0
- data/lib/commands/new_command.rb +34 -0
- data/lib/commands/tweet_command.rb +64 -0
- data/lib/ignoramos.rb +29 -0
- data/lib/models/app_config.rb +32 -0
- data/lib/models/page.rb +11 -0
- data/lib/models/post.rb +123 -0
- data/rebuild_gem +7 -0
- data/spec/commands/build_command_spec.rb +379 -0
- data/spec/commands/new_command_spec.rb +36 -0
- data/spec/commands/tweet_command_spec.rb +59 -0
- data/spec/models/app_config_spec.rb +66 -0
- data/spec/models/page_spec.rb +47 -0
- data/spec/models/post_spec.rb +156 -0
- data/spec/spec_helper.rb +2 -0
- metadata +105 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require './lib/commands/new_command'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
RSpec.describe NewCommand do
|
5
|
+
describe '#execute' do
|
6
|
+
include FakeFS::SpecHelpers
|
7
|
+
|
8
|
+
let(:command) { NewCommand.new('testdir') }
|
9
|
+
|
10
|
+
before { command.execute }
|
11
|
+
|
12
|
+
it 'creates folder for drafts' do
|
13
|
+
expect(File.directory?('testdir/_drafts')).to be_truthy
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates folder for posts' do
|
17
|
+
expect(File.directory?('testdir/_posts')).to be_truthy
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'creates folder for pages' do
|
21
|
+
expect(File.directory?('testdir/_pages')).to be_truthy
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'creates folder for includes' do
|
25
|
+
expect(File.directory?('testdir/_includes')).to be_truthy
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'creates folder for layout templates' do
|
29
|
+
expect(File.directory?('testdir/_layouts')).to be_truthy
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'creates folder for generated site' do
|
33
|
+
expect(File.directory?('testdir/_site')).to be_truthy
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require './lib/commands/new_command'
|
2
|
+
require './lib/commands/tweet_command'
|
3
|
+
require 'fakefs/spec_helpers'
|
4
|
+
require 'timecop'
|
5
|
+
|
6
|
+
RSpec.describe TweetCommand do
|
7
|
+
describe '#execute' do
|
8
|
+
include FakeFS::SpecHelpers
|
9
|
+
|
10
|
+
let(:command) { TweetCommand.new('testdir') }
|
11
|
+
let(:tweet) { 'this is a tweet' }
|
12
|
+
let(:tweet_id) { '525483671584002048' }
|
13
|
+
let(:tweet_url) { "https://twitter.com/amoschan/status/#{tweet_id}" }
|
14
|
+
let(:tweet_post) do
|
15
|
+
<<-TWEET
|
16
|
+
---
|
17
|
+
title: tweet #{tweet_id}
|
18
|
+
timestamp: #{now}
|
19
|
+
layout: tweet
|
20
|
+
tweet: #{tweet_url}
|
21
|
+
---
|
22
|
+
|
23
|
+
this is a tweet
|
24
|
+
TWEET
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:now) { DateTime.now }
|
28
|
+
|
29
|
+
let(:created_tweet) do
|
30
|
+
double()
|
31
|
+
end
|
32
|
+
|
33
|
+
before do
|
34
|
+
created_tweet.stub(:uri).and_return(URI(tweet_url))
|
35
|
+
created_tweet.stub(:id).and_return(tweet_id)
|
36
|
+
allow_any_instance_of(AppConfig).
|
37
|
+
to receive(:vars).and_return({
|
38
|
+
'twitter' => { 'access_token' => 'token',
|
39
|
+
'access_token_secret' => 'secret' }
|
40
|
+
})
|
41
|
+
|
42
|
+
expect_any_instance_of(Twitter::REST::Client).
|
43
|
+
to receive(:update).with(tweet).and_return(created_tweet)
|
44
|
+
|
45
|
+
Timecop.freeze do
|
46
|
+
NewCommand.new('testdir').execute
|
47
|
+
Dir.chdir('testdir')
|
48
|
+
TweetCommand.new('this is a tweet').execute
|
49
|
+
now
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'creates new tweet' do
|
54
|
+
File.open("_posts/tweet-#{tweet_id}.md", 'r') do |file|
|
55
|
+
expect(file.read()).to eq(tweet_post)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'models/app_config'
|
2
|
+
|
3
|
+
RSpec.describe AppConfig do
|
4
|
+
context 'Configuration set' do
|
5
|
+
let(:content) do
|
6
|
+
<<-CONTENT
|
7
|
+
---
|
8
|
+
site:
|
9
|
+
description: this is **awesome**
|
10
|
+
user: Test User
|
11
|
+
site_map: >
|
12
|
+
[hello][h]
|
13
|
+
|
14
|
+
[h]: http://hello.world
|
15
|
+
CONTENT
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:config) { AppConfig.new(content) }
|
19
|
+
|
20
|
+
describe '#site_map' do
|
21
|
+
it 'returns site map in html' do
|
22
|
+
expect(config.site_map).to eq('<p><a href="http://hello.world">hello</a></p>')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#site_description' do
|
27
|
+
it 'returns site description in html' do
|
28
|
+
expect(config.site_description).to eq('<p>this is <strong>awesome</strong></p>')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#user' do
|
33
|
+
it 'returns user name' do
|
34
|
+
expect(config.user).to eq('Test User')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'Configuration not set' do
|
40
|
+
let(:content) do
|
41
|
+
<<-CONTENT
|
42
|
+
---
|
43
|
+
CONTENT
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:config) { AppConfig.new(content) }
|
47
|
+
|
48
|
+
describe '#site_map' do
|
49
|
+
it 'returns empty string' do
|
50
|
+
expect(config.site_map).to eq('')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#site_description' do
|
55
|
+
it 'returns empty string' do
|
56
|
+
expect(config.site_description).to eq('')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#user' do
|
61
|
+
it 'returns empty string' do
|
62
|
+
expect(config.user).to eq('')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'models/page'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
RSpec.describe Page do
|
5
|
+
let(:content) do
|
6
|
+
<<-CONTENT
|
7
|
+
---
|
8
|
+
title: Test Post
|
9
|
+
timestamp: 2014-06-22T00:15:50-04:00
|
10
|
+
tags: test, beginning, randomtag
|
11
|
+
---
|
12
|
+
|
13
|
+
This is a test post. It is title is {{title}}.
|
14
|
+
CONTENT
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:page) { Page.new(content) }
|
18
|
+
|
19
|
+
describe '#permalink' do
|
20
|
+
context 'not provided' do
|
21
|
+
it 'consists of just the slug' do
|
22
|
+
expect(page.permalink).to eq('/test-post.html')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'provided in yaml' do
|
27
|
+
let(:custom_permalink_content) do
|
28
|
+
<<-CONTENT
|
29
|
+
---
|
30
|
+
title: Test Post
|
31
|
+
timestamp: 2014-06-22T00:15:50-04:00
|
32
|
+
tags: test, beginning, randomtag
|
33
|
+
permalink: custom-permalink
|
34
|
+
---
|
35
|
+
|
36
|
+
This is a test post. It is title is {{title}}.
|
37
|
+
CONTENT
|
38
|
+
end
|
39
|
+
|
40
|
+
let (:custom_permalink_page) { Page.new(custom_permalink_content) }
|
41
|
+
|
42
|
+
it 'uses the permalink provided from yaml' do
|
43
|
+
expect(custom_permalink_page.permalink).to eq('/custom-permalink.html')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'models/post'
|
2
|
+
require 'fakefs/spec_helpers'
|
3
|
+
|
4
|
+
RSpec.describe Post do
|
5
|
+
context 'YAML front-matter string provided' do
|
6
|
+
let(:content) do
|
7
|
+
<<-CONTENT
|
8
|
+
---
|
9
|
+
title: Test Post
|
10
|
+
markup: text
|
11
|
+
timestamp: 2014-06-22T00:15:50-04:00
|
12
|
+
tags: test, beginning, randomtag
|
13
|
+
---
|
14
|
+
|
15
|
+
This is a test post. It is title is {{title}}.
|
16
|
+
CONTENT
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:post) { Post.new(content) }
|
20
|
+
|
21
|
+
describe '#content' do
|
22
|
+
it 'returns post content' do
|
23
|
+
expect(post.content).
|
24
|
+
to eq('This is a test post. It is title is {{title}}.')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#vars' do
|
29
|
+
it 'returns variables from YAML front-matter' do
|
30
|
+
expect(post.vars['title']).to eq('Test Post')
|
31
|
+
expect(post.vars['markup']).to eq('text')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'falls back to defaults when variables not provided' do
|
35
|
+
expect(post.vars['layout']).to eq('default')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#permalink' do
|
40
|
+
it 'returns the permalink' do
|
41
|
+
expect(post.permalink).to eq('/2014/06/22/test-post.html')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#slug' do
|
46
|
+
it 'returns the slugified title' do
|
47
|
+
expect(post.slug).to eq('test-post')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#path' do
|
52
|
+
it 'returns the directory the post belongs in' do
|
53
|
+
expect(post.path).to eq('/2014/06/22')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#html' do
|
58
|
+
it 'populates variables within the post content' do
|
59
|
+
expect(post.html).
|
60
|
+
to eq('<p>This is a test post. It is title is Test Post.</p>')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#tags' do
|
65
|
+
it 'returns the alphatical list of tags associated to post' do
|
66
|
+
expect(post.tags).to eq(['beginning', 'randomtag', 'test'])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#external_link' do
|
71
|
+
it 'returns nil' do
|
72
|
+
expect(post.external_link).to be_nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#title_link' do
|
77
|
+
it 'returns the permalink' do
|
78
|
+
expect(post.title_link).to eq('/2014/06/22/test-post.html')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#post_type' do
|
83
|
+
it 'returns :self_post' do
|
84
|
+
expect(post.post_type).to eq(:self_post)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'permalink provided' do
|
90
|
+
let(:content) do
|
91
|
+
<<-CONTENT
|
92
|
+
---
|
93
|
+
title: Test
|
94
|
+
permalink: custom-permalink
|
95
|
+
timestamp: 2014-06-22T00:15:50-04:00
|
96
|
+
external_link: http://nba.com
|
97
|
+
---
|
98
|
+
|
99
|
+
This is a test.
|
100
|
+
CONTENT
|
101
|
+
end
|
102
|
+
|
103
|
+
let(:post) { Post.new(content) }
|
104
|
+
|
105
|
+
describe "#permalink" do
|
106
|
+
it 'uses the custom permalink' do
|
107
|
+
expect(post.permalink).to eq('/2014/06/22/custom-permalink.html')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#tags" do
|
112
|
+
it 'returns [] if none provided' do
|
113
|
+
expect(post.tags).to eq([])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#external_link' do
|
118
|
+
it 'returns the external link' do
|
119
|
+
expect(post.external_link).to eq('http://nba.com')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#title_link' do
|
124
|
+
it 'returns the external link' do
|
125
|
+
expect(post.title_link).to eq('http://nba.com')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#post_type' do
|
130
|
+
it 'returns :link_post' do
|
131
|
+
expect(post.post_type).to eq(:link_post)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'Markdown rendering' do
|
137
|
+
let(:content) do
|
138
|
+
<<-CONTENT
|
139
|
+
---
|
140
|
+
title: Markdown Test
|
141
|
+
---
|
142
|
+
|
143
|
+
This is a **Markdown test**.
|
144
|
+
CONTENT
|
145
|
+
end
|
146
|
+
|
147
|
+
let(:post) { Post.new(content) }
|
148
|
+
|
149
|
+
describe "#html" do
|
150
|
+
it 'renders markdown' do
|
151
|
+
expect(post.html).
|
152
|
+
to eq('<p>This is a <strong>Markdown test</strong>.</p>')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ignoramos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amos Chan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A static site generator for blogs and microposts.
|
42
|
+
email:
|
43
|
+
- amosschan@gmail.com
|
44
|
+
executables:
|
45
|
+
- ignoramos
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- .rspec
|
51
|
+
- .travis.yml
|
52
|
+
- Gemfile
|
53
|
+
- Guardfile
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- bin/ignoramos
|
58
|
+
- ignoramos.gemspec
|
59
|
+
- lib/commands/build_command.rb
|
60
|
+
- lib/commands/new_command.rb
|
61
|
+
- lib/commands/tweet_command.rb
|
62
|
+
- lib/ignoramos.rb
|
63
|
+
- lib/models/app_config.rb
|
64
|
+
- lib/models/page.rb
|
65
|
+
- lib/models/post.rb
|
66
|
+
- rebuild_gem
|
67
|
+
- spec/commands/build_command_spec.rb
|
68
|
+
- spec/commands/new_command_spec.rb
|
69
|
+
- spec/commands/tweet_command_spec.rb
|
70
|
+
- spec/models/app_config_spec.rb
|
71
|
+
- spec/models/page_spec.rb
|
72
|
+
- spec/models/post_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: http://rubygems.org/gems/ignoramos
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A static site generator for blogs and microposts.
|
98
|
+
test_files:
|
99
|
+
- spec/commands/build_command_spec.rb
|
100
|
+
- spec/commands/new_command_spec.rb
|
101
|
+
- spec/commands/tweet_command_spec.rb
|
102
|
+
- spec/models/app_config_spec.rb
|
103
|
+
- spec/models/page_spec.rb
|
104
|
+
- spec/models/post_spec.rb
|
105
|
+
- spec/spec_helper.rb
|