twirly 0.0.1
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 +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +122 -0
- data/LICENSE +20 -0
- data/README.md +56 -0
- data/bin/twirly +6 -0
- data/config/initializers/trello.rb +4 -0
- data/lib/twirly/cli.rb +22 -0
- data/lib/twirly/commands/base.rb +14 -0
- data/lib/twirly/commands/fetch_user.rb +9 -0
- data/lib/twirly/commands/pick.rb +9 -0
- data/lib/twirly/commands/pull.rb +9 -0
- data/lib/twirly/commands.rb +6 -0
- data/lib/twirly/compiler.rb +26 -0
- data/lib/twirly/helpers/youtube.rb +37 -0
- data/lib/twirly/helpers.rb +3 -0
- data/lib/twirly/post.rb +81 -0
- data/lib/twirly/serializers/post.rb +21 -0
- data/lib/twirly/serializers/user.rb +20 -0
- data/lib/twirly/serializers.rb +6 -0
- data/lib/twirly/user.rb +31 -0
- data/lib/twirly/version.rb +3 -0
- data/lib/twirly.rb +45 -0
- data/spec/cli_spec.rb +24 -0
- data/spec/commands/fetch_user_spec.rb +16 -0
- data/spec/commands/pick_spec.rb +16 -0
- data/spec/commands/pull_spec.rb +10 -0
- data/spec/dummy/.bowerrc +3 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/Gemfile +12 -0
- data/spec/dummy/Gemfile.lock +116 -0
- data/spec/dummy/Guardfile +10 -0
- data/spec/dummy/assets/javascripts/app.coffee +3 -0
- data/spec/dummy/assets/javascripts/router.coffee +27 -0
- data/spec/dummy/assets/stylesheets/index.css.scss +17 -0
- data/spec/dummy/assets/stylesheets/partials/_header.css.scss +20 -0
- data/spec/dummy/assets/stylesheets/partials/_post.css.scss +19 -0
- data/spec/dummy/assets/stylesheets/partials/_reset.css.scss +425 -0
- data/spec/dummy/source/.gitkeep +0 -0
- data/spec/dummy/vendor/assets/bower_components/backbone/backbone.js +1608 -0
- data/spec/dummy/vendor/assets/bower_components/backbone/bower.json +9 -0
- data/spec/dummy/vendor/assets/bower_components/backbone/index.js +1 -0
- data/spec/dummy/vendor/assets/bower_components/jquery/bower.json +27 -0
- data/spec/dummy/vendor/assets/bower_components/jquery/dist/jquery.min.js +5 -0
- data/spec/dummy/vendor/assets/bower_components/underscore/bower.json +8 -0
- data/spec/dummy/vendor/assets/bower_components/underscore/underscore.js +1343 -0
- data/spec/factories/post.rb +9 -0
- data/spec/factories/trello/attachment.rb +17 -0
- data/spec/factories/trello/board.rb +20 -0
- data/spec/factories/trello/card.rb +56 -0
- data/spec/factories/trello/label.rb +19 -0
- data/spec/factories/trello/member.rb +16 -0
- data/spec/factories/user.rb +9 -0
- data/spec/post_spec.rb +155 -0
- data/spec/serializers/post_spec.rb +41 -0
- data/spec/serializers/user_spec.rb +34 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/user_spec.rb +43 -0
- data/twirly.gemspec +38 -0
- data/twirly.yml.sample +4 -0
- metadata +324 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b86de10909408a53057c24b43e80e4aa4571210e
|
4
|
+
data.tar.gz: b0e2b8147f27984508f06004a5da88107974024b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f55d1970f03619c1f4acc5ca736fcc7624f5e2242894ac23aa870846f075a7d137699a1dd3396ec67d6caf40cb9eb2cebc31431025558d2cbb9b8a083da602a
|
7
|
+
data.tar.gz: 7da2d6f230b75976a1bf1d36fecc1510eeb8212b5065133bb39878a952fabceef03684da99a0dade4d7c925673ad87e89bf825f2290ae93c87f30ff2abfd3bcc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
twirly (0.0.1)
|
5
|
+
awesome_print
|
6
|
+
json (~> 1.8.1)
|
7
|
+
liquid
|
8
|
+
ruby-trello
|
9
|
+
thor
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activemodel (4.1.1)
|
15
|
+
activesupport (= 4.1.1)
|
16
|
+
builder (~> 3.1)
|
17
|
+
activesupport (4.1.1)
|
18
|
+
i18n (~> 0.6, >= 0.6.9)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
addressable (2.3.6)
|
24
|
+
ast (1.1.0)
|
25
|
+
awesome_print (1.2.0)
|
26
|
+
builder (3.2.2)
|
27
|
+
celluloid (0.15.2)
|
28
|
+
timers (~> 1.1.0)
|
29
|
+
coderay (1.1.0)
|
30
|
+
diff-lcs (1.2.5)
|
31
|
+
factory_girl (4.4.0)
|
32
|
+
activesupport (>= 3.0.0)
|
33
|
+
fakefs (0.5.1)
|
34
|
+
faker (1.3.0)
|
35
|
+
i18n (~> 0.5)
|
36
|
+
ffi (1.9.3)
|
37
|
+
formatador (0.2.4)
|
38
|
+
guard (2.6.1)
|
39
|
+
formatador (>= 0.2.4)
|
40
|
+
listen (~> 2.7)
|
41
|
+
lumberjack (~> 1.0)
|
42
|
+
pry (>= 0.9.12)
|
43
|
+
thor (>= 0.18.1)
|
44
|
+
guard-rspec (4.2.9)
|
45
|
+
guard (~> 2.1)
|
46
|
+
rspec (>= 2.14, < 4.0)
|
47
|
+
i18n (0.6.9)
|
48
|
+
json (1.8.1)
|
49
|
+
liquid (3.0.0)
|
50
|
+
listen (2.7.5)
|
51
|
+
celluloid (>= 0.15.2)
|
52
|
+
rb-fsevent (>= 0.9.3)
|
53
|
+
rb-inotify (>= 0.9)
|
54
|
+
lumberjack (1.0.5)
|
55
|
+
method_source (0.8.2)
|
56
|
+
mime-types (2.4.3)
|
57
|
+
minitest (5.3.4)
|
58
|
+
netrc (0.9.0)
|
59
|
+
oauth (0.4.7)
|
60
|
+
parser (2.1.7)
|
61
|
+
ast (~> 1.1)
|
62
|
+
slop (~> 3.4, >= 3.4.5)
|
63
|
+
powerpack (0.0.9)
|
64
|
+
pry (0.9.12.6)
|
65
|
+
coderay (~> 1.0)
|
66
|
+
method_source (~> 0.8)
|
67
|
+
slop (~> 3.4)
|
68
|
+
pry-nav (0.2.3)
|
69
|
+
pry (~> 0.9.10)
|
70
|
+
pry-remote (0.1.8)
|
71
|
+
pry (~> 0.9)
|
72
|
+
slop (~> 3.0)
|
73
|
+
rainbow (2.0.0)
|
74
|
+
rake (10.1.1)
|
75
|
+
rb-fsevent (0.9.4)
|
76
|
+
rb-inotify (0.9.4)
|
77
|
+
ffi (>= 0.5.0)
|
78
|
+
rest-client (1.7.2)
|
79
|
+
mime-types (>= 1.16, < 3.0)
|
80
|
+
netrc (~> 0.7)
|
81
|
+
rspec (2.14.1)
|
82
|
+
rspec-core (~> 2.14.0)
|
83
|
+
rspec-expectations (~> 2.14.0)
|
84
|
+
rspec-mocks (~> 2.14.0)
|
85
|
+
rspec-core (2.14.8)
|
86
|
+
rspec-expectations (2.14.5)
|
87
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
88
|
+
rspec-mocks (2.14.6)
|
89
|
+
rubocop (0.18.1)
|
90
|
+
json (>= 1.7.7, < 2)
|
91
|
+
parser (~> 2.1.3)
|
92
|
+
powerpack (~> 0.0.6)
|
93
|
+
rainbow (>= 1.99.1, < 3.0)
|
94
|
+
ruby-trello (1.1.2)
|
95
|
+
activemodel (>= 3.2.0)
|
96
|
+
addressable (~> 2.3)
|
97
|
+
json
|
98
|
+
oauth (~> 0.4.5)
|
99
|
+
rest-client (~> 1.7.2)
|
100
|
+
slop (3.4.7)
|
101
|
+
thor (0.19.1)
|
102
|
+
thread_safe (0.3.3)
|
103
|
+
timers (1.1.0)
|
104
|
+
tzinfo (1.1.0)
|
105
|
+
thread_safe (~> 0.1)
|
106
|
+
|
107
|
+
PLATFORMS
|
108
|
+
ruby
|
109
|
+
|
110
|
+
DEPENDENCIES
|
111
|
+
bundler (~> 1.3)
|
112
|
+
factory_girl
|
113
|
+
fakefs
|
114
|
+
faker
|
115
|
+
guard-rspec
|
116
|
+
pry
|
117
|
+
pry-nav
|
118
|
+
pry-remote
|
119
|
+
rake
|
120
|
+
rspec (~> 2.14.1)
|
121
|
+
rubocop
|
122
|
+
twirly!
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Dimitris Zorbas / zorbash
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
## Twirly
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/twirly)
|
4
|
+
|
5
|
+
Twirly is a cli tool which converts [Trello](http://trello.com) cards to
|
6
|
+
articles for use with ruby static site generators like
|
7
|
+
[middleman](http://middlemanapp.com/), [jekyll](http://jekyllrb.com/), [nanoc](http://nanoc.ws/)
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Add it to the `Gemfile` of the static site project.
|
12
|
+
|
13
|
+
`gem 'twirly'`
|
14
|
+
|
15
|
+
For a list of available commands run `twirly help`
|
16
|
+
For help on a command run `twirly help some_command`
|
17
|
+
|
18
|
+
## Setup
|
19
|
+
|
20
|
+
It requires a `twirly.yml` file to be present in the project root.
|
21
|
+
|
22
|
+
Example:
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
trello_key: 'deadc2592ce753b3bad'
|
26
|
+
trello_secret: 'deaddc5712771bad'
|
27
|
+
organization: 'some_organization'
|
28
|
+
publishing_board: 'iPAnh67A'
|
29
|
+
```
|
30
|
+
|
31
|
+
## Pull
|
32
|
+
|
33
|
+
Convert all cards having a 'published' label to articles
|
34
|
+
|
35
|
+
`twirly pull`
|
36
|
+
|
37
|
+
## Pick
|
38
|
+
|
39
|
+
Convert a specific card (identified by short_id) to article
|
40
|
+
|
41
|
+
`twirly pick`
|
42
|
+
|
43
|
+
## Fetch User
|
44
|
+
|
45
|
+
Create a page for a board user
|
46
|
+
|
47
|
+
`twirly fetch_user zorbash`
|
48
|
+
|
49
|
+
# Author
|
50
|
+
|
51
|
+
[zorbash](https://github.com/zorbash)
|
52
|
+
|
53
|
+
# Licence
|
54
|
+
Released under the MIT License. See the
|
55
|
+
[LICENSE](https://github.com/Zorbash/twirly/blob/master/LICENSE) file
|
56
|
+
for further details.
|
data/bin/twirly
ADDED
data/lib/twirly/cli.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Twirly
|
4
|
+
class CLI < ::Thor
|
5
|
+
package_name 'twirly'
|
6
|
+
|
7
|
+
desc 'pull', 'Fetch latest published posts'
|
8
|
+
def pull
|
9
|
+
Twirly::Commands::Pull.new(args, options).run
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'pick', 'Fetch post by short id'
|
13
|
+
def pick(id)
|
14
|
+
Twirly::Commands::Pick.new(args, options).run
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'fetch_user', 'Fetch user by username'
|
18
|
+
def fetch_user(username)
|
19
|
+
Twirly::Commands::FetchUser.new(args, options).run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Twirly
|
2
|
+
class Compiler
|
3
|
+
def pull
|
4
|
+
Twirly::Post.published.each do |post|
|
5
|
+
output_path = File.join Twirly.source_dir, "#{post.slug}.html.md.erb"
|
6
|
+
puts "Creating #{output_path}"
|
7
|
+
|
8
|
+
File.open(output_path, 'w') { |out| out << post.to_md }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def pick(post)
|
13
|
+
output_path = File.join Twirly.source_dir, "#{post.slug}.html.md.erb"
|
14
|
+
puts "Creating #{output_path}"
|
15
|
+
|
16
|
+
File.open(output_path, 'w') { |out| out << post.to_md }
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_user(user)
|
20
|
+
output_path = File.join Twirly.source_dir, 'users', "#{user.username}.html.md.erb"
|
21
|
+
puts "Creating #{output_path}"
|
22
|
+
|
23
|
+
File.open(output_path, 'w') { |out| out << user.to_md }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Twirly
|
2
|
+
module Helpers
|
3
|
+
# Exposes a tag for liquid templates with the
|
4
|
+
# following syntax
|
5
|
+
#
|
6
|
+
# {% youtube width height value %}
|
7
|
+
class Youtube < Liquid::Tag
|
8
|
+
def initialize(name, variables, tokens)
|
9
|
+
super
|
10
|
+
_parse_variables(variables)
|
11
|
+
end
|
12
|
+
|
13
|
+
def render(context)
|
14
|
+
<<-VIDEO.strip_heredoc.strip
|
15
|
+
<div class="embed-video-container">
|
16
|
+
<iframe width="#{@width}" height="#{@height}"
|
17
|
+
src="http://www.youtube.com/embed/#{@id}">
|
18
|
+
</iframe>
|
19
|
+
</div>
|
20
|
+
VIDEO
|
21
|
+
end
|
22
|
+
|
23
|
+
def _parse_variables(variables)
|
24
|
+
parsed_variables = variables.split(' ')
|
25
|
+
if parsed_variables.size == 3
|
26
|
+
@width = parsed_variables[0]
|
27
|
+
@height = parsed_variables[1]
|
28
|
+
@id = parsed_variables[2]
|
29
|
+
else
|
30
|
+
@id = parsed_variables.first
|
31
|
+
@width = 320
|
32
|
+
@height = 280
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/twirly/post.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
module Twirly
|
2
|
+
class Post < SimpleDelegator
|
3
|
+
include Twirly::Serializers::Post
|
4
|
+
|
5
|
+
define_method(:alias_attribute, &Trello::Card.method(:alias_attribute).to_proc)
|
6
|
+
|
7
|
+
alias :card :__getobj__
|
8
|
+
|
9
|
+
alias_attribute :title, :name
|
10
|
+
alias_attribute :updated_at, :last_activity_date
|
11
|
+
alias_attribute :created_at, :due
|
12
|
+
alias_attribute :published_at, :due
|
13
|
+
alias_attribute :card_id, :short_id
|
14
|
+
|
15
|
+
def category; card.list.name end
|
16
|
+
|
17
|
+
def tags
|
18
|
+
labels.map(&:name).reject { |label| label == 'published' }
|
19
|
+
end
|
20
|
+
|
21
|
+
def existing_front_matter
|
22
|
+
@existing_front_matter ||= card.desc.scan(/(---.*---)/mi).flatten.first
|
23
|
+
end
|
24
|
+
|
25
|
+
def processed_front_matter
|
26
|
+
@processed_front_matter =
|
27
|
+
begin
|
28
|
+
matter = YAML::load(existing_front_matter || '{}')
|
29
|
+
matter[:title] = title
|
30
|
+
matter[:slug] = slug
|
31
|
+
matter[:category] = category
|
32
|
+
matter[:date] = short_published_at
|
33
|
+
matter[:tags] = tags.join(', ')
|
34
|
+
matter[:authors] = authors.map(&:username).join(', ')
|
35
|
+
matter[:attachments] = attachments.map(&:url).join(', ') if card.attachments.any?
|
36
|
+
matter
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def body
|
41
|
+
@body ||= Liquid::Template.parse(card.desc.sub(/---.*---/mi, '').strip).render
|
42
|
+
end
|
43
|
+
|
44
|
+
def short_published_at
|
45
|
+
published_at.strftime('%Y-%m-%d')
|
46
|
+
end
|
47
|
+
|
48
|
+
def published?
|
49
|
+
published_at && card.labels.any? { |label| label.name == 'published' }
|
50
|
+
end
|
51
|
+
|
52
|
+
def slug
|
53
|
+
"#{short_published_at}-#{title.parameterize}-#{card_id}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def authors
|
57
|
+
members.map { |member| Twirly::User.new(member) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def front_matter
|
61
|
+
"#{processed_front_matter.to_yaml}\n---"
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_md
|
65
|
+
"#{front_matter}\n\n#{body}"
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def published
|
70
|
+
Twirly.board.cards.map { |card|
|
71
|
+
post = Post.new(card)
|
72
|
+
if post.published? then post else nil end
|
73
|
+
}.compact.sort { |p1, p2| p2.published_at <=> p1.published_at }
|
74
|
+
end
|
75
|
+
|
76
|
+
def find(id)
|
77
|
+
Post.new(Twirly.board.cards.find { |card| card.short_id == id })
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Twirly
|
2
|
+
module Serializers
|
3
|
+
module Post
|
4
|
+
def as_json
|
5
|
+
{ post: {
|
6
|
+
card_id: card_id,
|
7
|
+
title: title,
|
8
|
+
category: category,
|
9
|
+
tags: tags,
|
10
|
+
updated_at: updated_at,
|
11
|
+
published_at: published_at
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_json
|
17
|
+
as_json.to_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Twirly
|
2
|
+
module Serializers
|
3
|
+
module User
|
4
|
+
def as_json
|
5
|
+
{ user: {
|
6
|
+
id: id,
|
7
|
+
username: username,
|
8
|
+
full_name: full_name,
|
9
|
+
bio: bio,
|
10
|
+
avatar_url: avatar_url,
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_json
|
16
|
+
as_json.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/twirly/user.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Twirly
|
2
|
+
class User < SimpleDelegator
|
3
|
+
include Twirly::Serializers::User
|
4
|
+
|
5
|
+
alias :member :__getobj__
|
6
|
+
|
7
|
+
def front_matter
|
8
|
+
"#{attributes.to_yaml}\n---"
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_md
|
12
|
+
"#{front_matter}\n\n#{bio}"
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def all
|
17
|
+
Twirly.board.members.map do |member|
|
18
|
+
user = User.new(member)
|
19
|
+
user.refresh!
|
20
|
+
user
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_by_username(username)
|
25
|
+
user = User.new(Twirly.board.members.find { |member| member.username == username })
|
26
|
+
user.refresh!
|
27
|
+
user
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/twirly.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'delegate'
|
4
|
+
require 'yaml'
|
5
|
+
require 'thor'
|
6
|
+
require 'active_support/hash_with_indifferent_access'
|
7
|
+
require 'active_support/core_ext'
|
8
|
+
|
9
|
+
require 'twirly/version'
|
10
|
+
|
11
|
+
autoload :Trello, 'trello'
|
12
|
+
autoload :Liquid, 'liquid'
|
13
|
+
autoload :FileUtils, 'file_utils'
|
14
|
+
|
15
|
+
I18n.enforce_available_locales = false
|
16
|
+
|
17
|
+
module Twirly
|
18
|
+
begin
|
19
|
+
SETTINGS = YAML.load_file('twirly.yml').deep_symbolize_keys
|
20
|
+
rescue Errno::ENOENT
|
21
|
+
puts 'twirly.yml was not found, please add one'
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.board
|
25
|
+
@board ||= Trello::Board.find(SETTINGS[:publishing_board])
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.source_dir(dir = './')
|
29
|
+
@source ||= (SETTINGS[:source_dir] || File.expand_path(dir))
|
30
|
+
end
|
31
|
+
|
32
|
+
autoload :Post, 'twirly/post'
|
33
|
+
autoload :User, 'twirly/user'
|
34
|
+
autoload :Compiler, 'twirly/compiler'
|
35
|
+
autoload :CLI, 'twirly/cli'
|
36
|
+
autoload :Commands, 'twirly/commands'
|
37
|
+
autoload :Helpers, 'twirly/helpers'
|
38
|
+
autoload :Serializers, 'twirly/serializers'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Load all initializers
|
42
|
+
Dir[File.join(File.expand_path('../../', __FILE__),
|
43
|
+
'config/initializers/*')].sort.each(&method(:require))
|
44
|
+
|
45
|
+
Liquid::Template.register_tag('youtube', Twirly::Helpers::Youtube)
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twirly::CLI do
|
4
|
+
describe '#pull' do
|
5
|
+
it 'runs Twirly::Commands::Pull' do
|
6
|
+
Twirly::Commands::Pull.any_instance.should_receive(:run)
|
7
|
+
Twirly::CLI.start %w(pull)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#pick' do
|
12
|
+
it 'runs Twirly::Commands::Pick' do
|
13
|
+
Twirly::Commands::Pick.any_instance.should_receive(:run)
|
14
|
+
Twirly::CLI.start %w(pick 42)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#fetch_user' do
|
19
|
+
it 'runs Twirly::Commands::FetchUser' do
|
20
|
+
Twirly::Commands::FetchUser.any_instance.should_receive(:run)
|
21
|
+
Twirly::CLI.start %w(fetch_user zorbash)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twirly::Commands::FetchUser do
|
4
|
+
describe '#run' do
|
5
|
+
let(:args) { ['zorbash'] }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Twirly::User.stub(:find_by_username).and_return(create(:user))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'calls Twirly::Compiler#fetch_user' do
|
12
|
+
Twirly::Compiler.any_instance.should_receive :fetch_user
|
13
|
+
(Twirly::Commands::FetchUser.new(args, {})).run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twirly::Commands::Pull do
|
4
|
+
describe '#run' do
|
5
|
+
let(:args) { ['42'] }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Twirly::Post.stub(:find).and_return(create(:post))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'calls Twirly::Compiler#pick' do
|
12
|
+
Twirly::Compiler.any_instance.should_receive :pick
|
13
|
+
(Twirly::Commands::Pick.new(args, {})).run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/dummy/.bowerrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.sass-cache
|