monad 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -4
- data/lib/monad.rb +1 -1
- data/lib/monad/filters.rb +9 -0
- data/monad.gemspec +3 -3
- data/test/helper.rb +4 -1
- data/test/test_filters.rb +4 -0
- data/test/test_json_driver.rb +10 -7
- metadata +19 -7
- data/CONTRIBUTING.md +0 -68
data/README.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
## Monad
|
2
2
|
|
3
|
-
Monad is a simple, blog aware, static site generator based on
|
3
|
+
Monad is a simple, blog aware, static site generator based on [Jekyll](https://github.com/mojombo/jekyll).
|
4
4
|
|
5
5
|
The main feature it adds is as follows:
|
6
6
|
|
7
7
|
- Support data sources
|
8
|
-
- Support
|
8
|
+
- Support posts from external sources(TBD)
|
9
9
|
|
10
10
|
## Data Sources
|
11
11
|
|
12
12
|
Data Source enables you to load data from external sources, such as web, file system,
|
13
13
|
databases and then use them inside views.
|
14
14
|
|
15
|
-
|
15
|
+
Monad supports two built-in data sources:
|
16
16
|
|
17
17
|
- `YAML` from local file system
|
18
18
|
- `JSON` from web
|
@@ -83,6 +83,6 @@ data_sources:
|
|
83
83
|
type: xxx
|
84
84
|
```
|
85
85
|
|
86
|
-
If the type is `xxx`,
|
86
|
+
If the type is `xxx`, Monad assumes the corresponding driver is `Monad::Drivers::XxxDriver`. If the type is `xxx_yyy`, the driver should be `Monad::Drivers::XxxYyyDriver`, and so on.
|
87
87
|
|
88
88
|
Beside the obligatory `name` and `type` options, you can define any more options to be used inside the driver.
|
data/lib/monad.rb
CHANGED
@@ -57,7 +57,7 @@ require_all 'monad/drivers'
|
|
57
57
|
SafeYAML::OPTIONS[:suppress_warnings] = true
|
58
58
|
|
59
59
|
module Monad
|
60
|
-
VERSION = '0.0.
|
60
|
+
VERSION = '0.0.2'
|
61
61
|
|
62
62
|
# Public: Generate a Monad configuration Hash by merging the default
|
63
63
|
# options with anything in _config.yml, and adding the given options on top.
|
data/lib/monad/filters.rb
CHANGED
@@ -138,6 +138,15 @@ module Monad
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
# Convert the input into json string
|
142
|
+
#
|
143
|
+
# input - The Array of Hash to be converted
|
144
|
+
#
|
145
|
+
# Returns the converted json string
|
146
|
+
def json(input)
|
147
|
+
input.to_json
|
148
|
+
end
|
149
|
+
|
141
150
|
private
|
142
151
|
def time(input)
|
143
152
|
case input
|
data/monad.gemspec
CHANGED
@@ -4,9 +4,9 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'monad'
|
7
|
-
s.version = '0.0.
|
7
|
+
s.version = '0.0.2'
|
8
8
|
s.license = 'MIT'
|
9
|
-
s.date = '2013-
|
9
|
+
s.date = '2013-07-02'
|
10
10
|
|
11
11
|
s.summary = "A simple, blog aware, static site generator based on jekyll."
|
12
12
|
s.description = "Monad is a simple, blog aware, static site generator based on jekyll."
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.add_development_dependency('rake', "~> 10.0.3")
|
36
36
|
s.add_development_dependency('rdoc', "~> 3.11")
|
37
37
|
s.add_development_dependency('redgreen', "~> 1.2")
|
38
|
+
s.add_development_dependency('webmock', "~> 1.9.3")
|
38
39
|
s.add_development_dependency('shoulda', "~> 3.3.2")
|
39
40
|
s.add_development_dependency('rr', "~> 1.0")
|
40
41
|
s.add_development_dependency('cucumber', "~> 1.2.1", '!= 1.2.4')
|
@@ -47,7 +48,6 @@ Gem::Specification.new do |s|
|
|
47
48
|
|
48
49
|
# = MANIFEST =
|
49
50
|
s.files = %w[
|
50
|
-
CONTRIBUTING.md
|
51
51
|
Gemfile
|
52
52
|
LICENSE
|
53
53
|
README.md
|
data/test/helper.rb
CHANGED
@@ -7,7 +7,6 @@ end
|
|
7
7
|
require 'rubygems'
|
8
8
|
require 'test/unit'
|
9
9
|
require 'ostruct'
|
10
|
-
gem 'RedCloth', '>= 4.2.1'
|
11
10
|
|
12
11
|
require 'monad'
|
13
12
|
|
@@ -20,6 +19,10 @@ require 'redgreen' if RUBY_VERSION < '1.9'
|
|
20
19
|
require 'shoulda'
|
21
20
|
require 'rr'
|
22
21
|
|
22
|
+
require 'webmock'
|
23
|
+
include WebMock::API
|
24
|
+
WebMock.allow_net_connect!
|
25
|
+
|
23
26
|
include Monad
|
24
27
|
|
25
28
|
# Send STDERR into the void to suppress program output messages
|
data/test/test_filters.rb
CHANGED
@@ -98,5 +98,9 @@ class TestFilters < Test::Unit::TestCase
|
|
98
98
|
should "escape space as %20" do
|
99
99
|
assert_equal "my%20things", @filter.uri_escape("my things")
|
100
100
|
end
|
101
|
+
|
102
|
+
should "convert object to json" do
|
103
|
+
assert_equal "{\"name\":\"test\"}", @filter.json({name: "test"})
|
104
|
+
end
|
101
105
|
end
|
102
106
|
end
|
data/test/test_json_driver.rb
CHANGED
@@ -37,7 +37,8 @@ class TestJsonDriver < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
should 'throw exception if server returns non-json content' do
|
39
39
|
assert_raise JSON::ParserError do
|
40
|
-
|
40
|
+
stub_http_request(:get, 'http://test.com/').to_return(body: 'hello, world')
|
41
|
+
Monad::Drivers::JsonDriver.new('url' => 'http://test.com/').load
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
@@ -45,17 +46,19 @@ class TestJsonDriver < Test::Unit::TestCase
|
|
45
46
|
context 'correct input and correct environment' do
|
46
47
|
should 'handle http request correctly' do
|
47
48
|
assert_nothing_raised do
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
stub_http_request(:get, 'http://test.com/').to_return(body: '{"ip": "127.0.0.1"}')
|
50
|
+
|
51
|
+
data = Monad::Drivers::JsonDriver.new('url' => 'http://test.com/').load
|
52
|
+
assert_equal data['ip'], '127.0.0.1'
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
should 'handle https request correctly' do
|
55
57
|
assert_nothing_raised do
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
stub_http_request(:get, 'https://test.com/').to_return(body: '{"city": "Nanjing"}')
|
59
|
+
|
60
|
+
data = Monad::Drivers::JsonDriver.new('url' => 'https://test.com/').load
|
61
|
+
assert_equal data['city'], 'Nanjing'
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: liquid
|
@@ -203,6 +203,22 @@ dependencies:
|
|
203
203
|
- - ~>
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '1.2'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: webmock
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ~>
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 1.9.3
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ~>
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 1.9.3
|
206
222
|
- !ruby/object:Gem::Dependency
|
207
223
|
name: shoulda
|
208
224
|
requirement: !ruby/object:Gem::Requirement
|
@@ -362,7 +378,6 @@ extra_rdoc_files:
|
|
362
378
|
- README.md
|
363
379
|
- LICENSE
|
364
380
|
files:
|
365
|
-
- CONTRIBUTING.md
|
366
381
|
- Gemfile
|
367
382
|
- LICENSE
|
368
383
|
- README.md
|
@@ -518,9 +533,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
518
533
|
- - ! '>='
|
519
534
|
- !ruby/object:Gem::Version
|
520
535
|
version: '0'
|
521
|
-
segments:
|
522
|
-
- 0
|
523
|
-
hash: -435190587127129160
|
524
536
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
525
537
|
none: false
|
526
538
|
requirements:
|
@@ -529,7 +541,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
529
541
|
version: '0'
|
530
542
|
requirements: []
|
531
543
|
rubyforge_project:
|
532
|
-
rubygems_version: 1.8.
|
544
|
+
rubygems_version: 1.8.25
|
533
545
|
signing_key:
|
534
546
|
specification_version: 2
|
535
547
|
summary: A simple, blog aware, static site generator based on jekyll.
|
data/CONTRIBUTING.md
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
Contribute
|
2
|
-
==========
|
3
|
-
|
4
|
-
So you've got an awesome idea to throw into Jekyll. Great! Please keep the
|
5
|
-
following in mind:
|
6
|
-
|
7
|
-
* **Contributions will not be accepted without tests.**
|
8
|
-
* If you're creating a small fix or patch to an existing feature, just a simple
|
9
|
-
test will do. Please stay in the confines of the current test suite and use
|
10
|
-
[Shoulda](http://github.com/thoughtbot/shoulda/tree/master) and
|
11
|
-
[RR](http://github.com/btakita/rr/tree/master).
|
12
|
-
* If it's a brand new feature, make sure to create a new
|
13
|
-
[Cucumber](https://github.com/cucumber/cucumber/) feature and reuse steps
|
14
|
-
where appropriate. Also, whipping up some documentation in your fork's wiki
|
15
|
-
would be appreciated, and once merged it will be transferred over to the main
|
16
|
-
wiki.
|
17
|
-
* If your contribution changes any Jekyll behavior, make sure to update the
|
18
|
-
documentation. It lives in `site/_posts`. If the docs are missing information,
|
19
|
-
please feel free to add it in. Great docs make a great project!
|
20
|
-
* Please follow the [GitHub Ruby Styleguide](https://github.com/styleguide/ruby)
|
21
|
-
when modifying Ruby code.
|
22
|
-
|
23
|
-
Test Dependencies
|
24
|
-
-----------------
|
25
|
-
|
26
|
-
To run the test suite and build the gem you'll need to install Jekyll's
|
27
|
-
dependencies. Jekyll uses Bundler, so a quick run of the bundle command and
|
28
|
-
you're all set!
|
29
|
-
|
30
|
-
$ bundle
|
31
|
-
|
32
|
-
Before you start, run the tests and make sure that they pass (to confirm your
|
33
|
-
environment is configured properly):
|
34
|
-
|
35
|
-
$ rake test
|
36
|
-
$ rake features
|
37
|
-
|
38
|
-
Workflow
|
39
|
-
--------
|
40
|
-
|
41
|
-
Here's the most direct way to get your work merged into the project:
|
42
|
-
|
43
|
-
* Fork the project.
|
44
|
-
* Clone down your fork ( `git clone git@github.com:<username>/jekyll.git` ).
|
45
|
-
* Create a topic branch to contain your change ( `git checkout -b my_awesome_feature` ).
|
46
|
-
* Hack away, add tests. Not necessarily in that order.
|
47
|
-
* Make sure everything still passes by running `rake`.
|
48
|
-
* If necessary, rebase your commits into logical chunks, without errors.
|
49
|
-
* Push the branch up ( `git push origin my_awesome_feature` ).
|
50
|
-
* Create a pull request against mojombo/jekyll and describe what your change
|
51
|
-
does and the why you think it should be merged.
|
52
|
-
|
53
|
-
Gotchas
|
54
|
-
-------
|
55
|
-
|
56
|
-
* If you want to bump the gem version, please put that in a separate commit.
|
57
|
-
This way, the maintainers can control when the gem gets released.
|
58
|
-
* Try to keep your patch(es) based from the latest commit on mojombo/jekyll.
|
59
|
-
The easier it is to apply your work, the less work the maintainers have to do,
|
60
|
-
which is always a good thing.
|
61
|
-
* Please don't tag your GitHub issue with [fix], [feature], etc. The maintainers
|
62
|
-
actively read the issues and will label it once they come across it.
|
63
|
-
|
64
|
-
Finally...
|
65
|
-
----------
|
66
|
-
|
67
|
-
Thanks! Hacking on Jekyll should be fun. If you find any of this hard to figure
|
68
|
-
out, let us know so we can improve our process or documentation!
|