blogdown 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 20fd8fadd528928e0df6b1dd096f5e9f3a3f9a0b
4
+ data.tar.gz: bc1def2d29e73f06b59963e5044749fa4432a763
5
+ SHA512:
6
+ metadata.gz: 7dda4a325b28075348c4c993138fe164a5d82a8a856407026c2c8560c7ec06abfa626ee260ae48425519bac61ae6c207a95a6c2ba737ec7c6dd6af2220e4ba58
7
+ data.tar.gz: d5b591481d45ff8d4a0dfeb5cbe92dbd5500e3a9666047634cbb94be0e24310ffbc566576bcbf664f90181a17468f0a4680c032ba14f799ce614460a0bab6178
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blogdown.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 gernest
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Blogdown
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'blogdown'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install blogdown
18
+
19
+ ## Usage
20
+
21
+ Create a directory for your project
22
+ mkdir blogdown
23
+
24
+ Inside your freshly creted folder create another folder "posts"
25
+ cd blogdown
26
+ mkdir posts
27
+
28
+ Now, put all your markdown folders inside this "posts" folder, remeber to use the `.md` extendion
29
+ eg. `hello.md`
30
+
31
+ If you are done, and wish to build your html, for your richtext editor
32
+ Inside your project folder (our case 1blogdown`), Run
33
+ blogdown build
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/[my-github-username]/blogdown/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/blogdown ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "blogdown"
3
+
4
+ Blogdown::Cli::CommandLine.start
data/blogdown.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blogdown/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blogdown"
8
+ spec.version = Blogdown::VERSION
9
+ spec.authors = ["gernest"]
10
+ spec.email = ["geofreyernest@live.com"]
11
+ spec.summary = %q{Write in markdown for your web based rich text editor}
12
+ spec.description = %q{ another markdown fanatic}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake","~> 10.3.2"
23
+ spec.add_development_dependency "rspec","~>3.0.0"
24
+ spec.add_development_dependency "cucumber","~> 1.3.15"
25
+
26
+ spec.add_dependency "kramdown", "~> 1.4.0"
27
+ spec.add_dependency "coderay", "~> 1.1.0"
28
+ spec.add_dependency "thor", "~> 0.19.1"
29
+
30
+ end
@@ -0,0 +1,10 @@
1
+ Feature: File Pipeline
2
+ As a developer, I want to have a full access of the files managed, and processed by the app
3
+ during runtime.
4
+ This is to offer a simple API for parts of the programs which needs access to the files processed
5
+
6
+ Scenario: Loading Input files
7
+ Given I have a root directory
8
+ And There is a posts directory in the root directory
9
+ When I initialize initialize the file pipeline
10
+ Then I should have a stack of input files
@@ -0,0 +1,18 @@
1
+ Given(/^I have a root directory$/) do
2
+ pending # express the regexp above with the code you wish you had
3
+ end
4
+
5
+
6
+ And(/^There is a posts directory in the root directory$/) do
7
+ pending # express the regexp above with the code you wish you had
8
+ end
9
+
10
+
11
+ When(/^I initialize initialize the file pipeline$/) do
12
+ pending # express the regexp above with the code you wish you had
13
+ end
14
+
15
+
16
+ Then(/^I should have a stack of input files$/) do
17
+ pending # express the regexp above with the code you wish you had
18
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH<<File.expand_path('../../../lib',__FILE__)
2
+ require 'blogdown'
@@ -0,0 +1,19 @@
1
+ require 'thor'
2
+
3
+
4
+ module Blogdown
5
+ module Cli
6
+ class CommandLine<Thor
7
+
8
+ desc "build", "builds the html files"
9
+ def build
10
+ begin
11
+ publisher=Blogdown::Publisher.new(Dir.pwd)
12
+ publisher.compose
13
+ rescue Exception=>e
14
+ puts e.message
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module Blogdown
2
+ module Exceptions
3
+ class DirectoryNotFound<Exception
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ module Blogdown
2
+ class FilePipeline
3
+ attr_accessor :stack
4
+ def initialize(root)
5
+ @root=root
6
+ @base=Pathname(@root)
7
+ @stack=[]
8
+ load_files
9
+ end
10
+
11
+ def load_files
12
+ base_input=@root+'/posts'
13
+
14
+ base=Pathname.new(base_input)
15
+ unless base.exist?
16
+ raise Blogdown::Exceptions::DirectoryNotFound, "please make sure the posts folder is present"
17
+ end
18
+ if base.exist?
19
+ base.each_child do|child|
20
+ if child.basename.to_s=~/^*.md$/
21
+ self.stack<<child
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def writer(name,contents)
28
+ file=@base.to_s+"/output/#{name}.html"
29
+ file=File.new(file.to_s,"w")
30
+ file.write(contents)
31
+ file.close
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,47 @@
1
+ require 'coderay'
2
+ require 'kramdown'
3
+
4
+ module Blogdown
5
+ class Publisher
6
+ def initialize root
7
+ @pipeline=Blogdown::FilePipeline.new root
8
+ @base=root
9
+ end
10
+
11
+ def compose
12
+ clean_output
13
+ if @pipeline.stack.empty?
14
+ raise IOError, "No file to compose"
15
+ else
16
+ @pipeline.stack.each do |file|
17
+ htm=transform(file.read)
18
+ @pipeline.writer(file.basename,htm)
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ def transform(txt)
25
+ Kramdown::Document.new(txt,kramdown_options).to_html
26
+ end
27
+
28
+ def file_stack
29
+ @pipeline.stack
30
+ end
31
+
32
+ def clean_output
33
+ base_root=@base+'/output'
34
+ base_root=Pathname base_root
35
+ if base_root.exist?
36
+ base_root.rmtree
37
+ base_root.mkpath
38
+ else
39
+ base_root.mkpath
40
+ end
41
+ end
42
+
43
+ def kramdown_options
44
+ {coderay_css: "style", coderay_line_numbers: nil}
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Blogdown
2
+ VERSION = "0.0.1"
3
+ end
data/lib/blogdown.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'pathname'
2
+ require "blogdown/version"
3
+ require 'blogdown/exceptions'
4
+ require 'blogdown/file_pipeline'
5
+ require 'blogdown/publisher'
6
+ require 'blogdown/cli'
7
+
8
+ module Blogdown
9
+ end
@@ -0,0 +1,23 @@
1
+ # This is just a funny looking spec, a lot of work is needed to improve it
2
+
3
+
4
+ def clean_output
5
+ root=$root_fixture_path+'/output'
6
+ root=Pathname root
7
+ if root.exist?
8
+ root.rmtree
9
+ root.mkpath
10
+ else
11
+ root.mkpath
12
+ end
13
+ end
14
+
15
+ describe "A simple markdown blogger" do
16
+ before(:each) do
17
+ clean_output
18
+ end
19
+
20
+ let(:publisher){ Blogdown::Publisher.new($root_fixture_path) }
21
+
22
+ it{ expect{publisher.compose}.to_not raise_error}
23
+ end
File without changes
@@ -0,0 +1,12 @@
1
+ ~~~ruby
2
+ def clean_output
3
+ root=$root_fixture_path+'/output'
4
+ root=Pathname root
5
+ if root.exist?
6
+ root.rmtree
7
+ root.mkpath
8
+ else
9
+ root.mkpath
10
+ end
11
+ end
12
+ ~~~
@@ -0,0 +1,82 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ $LOAD_PATH<<File.expand_path('../../../lib',__FILE__)
18
+ $root_fixture_path=File.expand_path('../fixtures',__FILE__)
19
+
20
+ require 'blogdown'
21
+ RSpec.configure do |config|
22
+ # The settings below are suggested to provide a good initial experience
23
+ # with RSpec, but feel free to customize to your heart's content.
24
+ =begin
25
+ # These two settings work together to allow you to limit a spec run
26
+ # to individual examples or groups you care about by tagging them with
27
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
28
+ # get run.
29
+ config.filter_run :focus
30
+ config.run_all_when_everything_filtered = true
31
+
32
+ # Many RSpec users commonly either run the entire suite or an individual
33
+ # file, and it's useful to allow more verbose output when running an
34
+ # individual spec file.
35
+ if config.files_to_run.one?
36
+ # Use the documentation formatter for detailed output,
37
+ # unless a formatter has already been configured
38
+ # (e.g. via a command-line flag).
39
+ config.default_formatter = 'doc'
40
+ end
41
+
42
+ # Print the 10 slowest examples and example groups at the
43
+ # end of the spec run, to help surface which specs are running
44
+ # particularly slow.
45
+ config.profile_examples = 10
46
+
47
+ # Run specs in random order to surface order dependencies. If you find an
48
+ # order dependency and want to debug it, you can fix the order by providing
49
+ # the seed, which is printed after each run.
50
+ # --seed 1234
51
+ config.order = :random
52
+
53
+ # Seed global randomization in this process using the `--seed` CLI option.
54
+ # Setting this allows you to use `--seed` to deterministically reproduce
55
+ # test failures related to randomization by passing the same `--seed` value
56
+ # as the one that triggered the failure.
57
+ Kernel.srand config.seed
58
+
59
+ # rspec-expectations config goes here. You can use an alternate
60
+ # assertion/expectation library such as wrong or the stdlib/minitest
61
+ # assertions if you prefer.
62
+ config.expect_with :rspec do |expectations|
63
+ # Enable only the newer, non-monkey-patching expect syntax.
64
+ # For more details, see:
65
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
66
+ expectations.syntax = :expect
67
+ end
68
+
69
+ # rspec-mocks config goes here. You can use an alternate test double
70
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
71
+ config.mock_with :rspec do |mocks|
72
+ # Enable only the newer, non-monkey-patching expect syntax.
73
+ # For more details, see:
74
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
75
+ mocks.syntax = :expect
76
+
77
+ # Prevents you from mocking or stubbing a method that does not exist on
78
+ # a real object. This is generally recommended.
79
+ mocks.verify_partial_doubles = true
80
+ end
81
+ =end
82
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blogdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - gernest
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-30 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: 10.3.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 10.3.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: cucumber
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.15
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.15
69
+ - !ruby/object:Gem::Dependency
70
+ name: kramdown
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: coderay
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 0.19.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.19.1
111
+ description: ' another markdown fanatic'
112
+ email:
113
+ - geofreyernest@live.com
114
+ executables:
115
+ - blogdown
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .rspec
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/blogdown
126
+ - blogdown.gemspec
127
+ - features/file_pipeline.feature
128
+ - features/step_definitions/file_pipeline_steps.rb
129
+ - features/support/env.rb
130
+ - lib/blogdown.rb
131
+ - lib/blogdown/cli.rb
132
+ - lib/blogdown/exceptions.rb
133
+ - lib/blogdown/file_pipeline.rb
134
+ - lib/blogdown/publisher.rb
135
+ - lib/blogdown/version.rb
136
+ - spec/blogdown/blogdown_spec.rb
137
+ - spec/fixtures/output/hello.html
138
+ - spec/fixtures/posts/hello.md
139
+ - spec/spec_helper.rb
140
+ homepage: ''
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.3.0
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Write in markdown for your web based rich text editor
164
+ test_files:
165
+ - features/file_pipeline.feature
166
+ - features/step_definitions/file_pipeline_steps.rb
167
+ - features/support/env.rb
168
+ - spec/blogdown/blogdown_spec.rb
169
+ - spec/fixtures/output/hello.html
170
+ - spec/fixtures/posts/hello.md
171
+ - spec/spec_helper.rb
172
+ has_rdoc: