styledown 1.0.2.pre.0 → 2.0.0.pre.1

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: 4eec94b0a4e0d5a730357f9fdc5c82401656d74c
4
- data.tar.gz: f55c31765bf24914dcdacb049de80394f5e058e8
3
+ metadata.gz: e42a396f82037aed88126bf20330f0bb452afdce
4
+ data.tar.gz: afe588018af86b3612eb3fef0ac60647281efcd9
5
5
  SHA512:
6
- metadata.gz: d66440860aa56893f6d41faa897ae788b56d7ced326d3d8e29f4a5a115b8b65de31e6d6117b9d4272ef0927089711e385d8eeb7976cf4a84194ec504ca2f2e7e
7
- data.tar.gz: 8d2363c1e1915e9927d7159fb1dc14fa0feb07c3efae32531ba9913c6ab20bfdbfb6305b42d1757a4435465b2ab456e176021765fc7cdb769a11cb8cc46ee82b
6
+ metadata.gz: fe33b286ca2127789c929b2ec4b6c1ebbe805d716ef8fc221ba384a2bef4a45285c49ed26b592cd899f5f947460a8e79bc4a8af4d75fa8d8b78df17a62ca9e17
7
+ data.tar.gz: 9d863cbaf3fc980ad3ee3fc6e2e69b4e065f95ec06d4844e4922d9fd3b58256108f907939045ab9f4bf93fb21fc5c966711695fdf646affb457edc9df3ecb7ad
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.gem
2
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,11 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
- - 1.9.3
5
-
6
- notifications:
7
- email:
8
- recipients:
9
- - dropbox+travis@ricostacruz.com
10
- on_success: change
11
- on_failure: change
4
+ - 2.3.0
data/History.md CHANGED
@@ -1,12 +1,24 @@
1
- ## v1.0.2.pre.0 - January 16, 2014
1
+ ## [v2.0.0-pre1]
2
+ > May 6, 2016
2
3
 
3
- * Update Styledown source to 1.0.2.
4
+ - **Completely new API.** Update to use Styledown v2.0.0-pre1.
4
5
 
5
- ## v1.0.1.pre.0 - September 5, 2014
6
+ [v2.0.0-pre1]: https://github.com/styledown/styledown-rails/compare/v0.0.0...v2.0.0-pre1
6
7
 
7
- * Update Styledown source to 1.0.1.
8
- * Add support for `Styledown.parse(array of files)`.
8
+ ## [v1.0.1]
9
+ > Apr 19, 2016
9
10
 
10
- ## v0.7.0.pre.0 - September 1, 2014
11
+ - Release as a non-prerelease-version. No functional changes.
12
+
13
+ [v1.0.1]: https://github.com/styledown/styledown-rails/compare/v1.0.1.pre.0...v1.0.1
14
+
15
+ ## v1.0.1.pre.0
16
+ > September 5, 2014
17
+
18
+ - Update Styledown source to 1.0.1.
19
+ - Add support for `Styledown.parse(array of files)`.
20
+
21
+ ## v0.7.0.pre.0
22
+ > September 1, 2014
11
23
 
12
24
  Initial pre-release. No Rails integration, but plain Ruby integration works.
data/Notes.md CHANGED
@@ -3,11 +3,8 @@ Developer notes
3
3
 
4
4
  ### Updating source
5
5
 
6
- Use `rake update`.
7
-
8
- This will update `vendor/dist/styledown.js`. Get it as `dist/styledown.js` from
9
- the [styledown/styledown] repo. This is built using the `npm run prepublish`
10
- hook.
6
+ Update `vendor/dist/styledown.js`. Get it as `dist/styledown.js` from the
7
+ [styledown/styledown] repo. This is built using the `npm run prepublish` hook.
11
8
 
12
9
  [styledown/styledown]: https://github.com/styledown/styledown
13
10
 
@@ -17,66 +14,3 @@ hook.
17
14
  bump lib/styledown/version.rb
18
15
  gem build *.gemspec
19
16
  rake && gem push *.gem && git release v1.0.0
20
-
21
- Planned API
22
- -----------
23
-
24
- ### Globbing
25
-
26
- Globbing should be supported to make things convenient.
27
-
28
- ```rb
29
- Styledown.parse([
30
- Rails.root.join('app/assets/stylesheets/*/*.less')
31
- ])
32
- ```
33
-
34
- ### Controller integration
35
-
36
- There should be better Rails integration later on. It'd be nice to be able to
37
- simplify controller integration like so. (This should take caching into
38
- consideration)
39
-
40
- ```rb
41
- module StyleguidesController
42
- layout 'styleguide'
43
-
44
- def show
45
- render styleguide: CSS_PATHS
46
- end
47
-
48
- CSS_PATHS = [
49
- 'app/assets/stylesheets/components/*',
50
- 'app/assets/stylesheets/overrides/*',
51
- 'app/assets/stylesheets/foobar/*',
52
- ]
53
- end
54
- ```
55
-
56
- ### Generator
57
-
58
- It'd be nice to do `rails g styledown:install` and have these things in place:
59
-
60
- ```rb
61
- # config/routes.rb
62
- get '/styleguides' => 'styleguides#show'
63
- ```
64
-
65
- ```rb
66
- # app/controllers/styleguides_controller.rb
67
- module StyleguidesController
68
- # ... see above
69
- end
70
- ```
71
-
72
- ```html
73
- <!-- app/views/layouts/styleguide.html.erb -->
74
- <html>
75
- <head>
76
- <meta charset='utf-8'>
77
- </head>
78
- <body>
79
- <%= yield %>
80
- </body>
81
- </html>
82
- ```
data/Rakefile CHANGED
@@ -1,13 +1,8 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
-
3
+
4
4
  Rake::TestTask.new do |t|
5
5
  t.test_files = Dir.glob('test/**/*test.rb')
6
6
  end
7
-
8
- task :default => :test
9
7
 
10
- desc "Updates styledown.js"
11
- task :update do
12
- system "wget https://github.com/styledown/styledown/raw/master/dist/styledown.js -O vendor/dist/styledown.js"
13
- end
8
+ task default: :test
data/Readme.md CHANGED
@@ -10,41 +10,47 @@ Ruby integration of [Styledown].
10
10
 
11
11
  ```rb
12
12
  # Gemfile
13
- gem 'styledown'
13
+ gem 'styledown', '~> 2.0.0'
14
14
  ```
15
15
 
16
16
  [![Gem](https://img.shields.io/gem/v/styledown.svg?style=flat)](http://rubygems.org/gems/styledown "View this project in Rubygems")
17
17
 
18
18
  ## Plain Ruby integration
19
19
 
20
- API for `Styledown.parse` is exactly the same as the JS version ([docs]).
20
+ These are provided:
21
+
22
+ * `Styledown.parse`
23
+ * `Styledown.parse_files`
24
+ * `Styledown.render`
25
+
26
+ API them is exactly the same as the JS version ([docs]).
21
27
 
22
28
  ```rb
23
29
  require 'styledown'
24
30
 
25
- # Passing a Styledown sting:
26
- Styledown.parse('### hello', bare: true)
27
-
28
31
  # Parsing files from disk:
29
- Styledown.parse([
30
- '/path/to/input.css',
31
- '/path/to/input.md',
32
- '...'
32
+ data = Styledown.parse_files([
33
+ '/path/to/buttons.md',
34
+ '/path/to/forms.md',
35
+ '...'
33
36
  ])
34
37
 
35
38
  # Parsing files from elsewhere:
36
- Styledown.parse([
37
- { name: "input.md", data: "### hi from md" },
38
- { name: "input.css", data: "/**\n * hi from css:\n * world\n */" }
39
+ data = Styledown.parse([
40
+ { name: 'buttons.md', contents: '### hi from buttons' },
41
+ { name: 'forms.md', contents: '### hi from forms' },
39
42
  ])
43
+
44
+ # Rendering a page:
45
+ html = Styledown.render(data, 'buttons.md')
46
+ html = Styledown.render(data, 'forms.md')
40
47
  ```
41
48
 
42
-
43
- [docs]: https://github.com/styledown/styledown/blob/master/docs/API.md#styledownparse
49
+ [docs]: https://github.com/styledown/styledown/blob/v2/docs/api.md#styledownparse
44
50
 
45
51
  ## :copyright:
46
52
 
47
- **styledown** © 2014+, Rico Sta. Cruz. Released under the [MIT License].<br>
53
+ **styledown** © 2014-2016, Rico Sta. Cruz. Released under the [MIT License].<br>
48
54
  Authored and maintained by Rico Sta. Cruz with help from [contributors].
49
55
 
50
56
  > [ricostacruz.com](http://ricostacruz.com) &nbsp;&middot;&nbsp;
@@ -1,5 +1,5 @@
1
1
  module Styledown
2
2
  def self.version
3
- version = "1.0.2-0"
3
+ '2.0.0-1'
4
4
  end
5
5
  end
data/lib/styledown.rb CHANGED
@@ -12,22 +12,26 @@ module Styledown
12
12
  end
13
13
  end
14
14
 
15
- def parse(source, options={})
16
- if array_of_filenames?(source)
17
- source = unpack_files(source)
18
- end
19
-
15
+ def parse(source, options = {})
20
16
  context.call('Styledown.parse', source, options)
21
17
  end
22
18
 
19
+ def parse_files(source, options = {})
20
+ parse unpack_files(source), options
21
+ end
22
+
23
+ def render(data, file, options = {})
24
+ context.call('Styledown.render', data, file, options)
25
+ end
26
+
23
27
  def js_version
24
28
  context.eval('Styledown.version')
25
29
  end
26
30
 
27
- private
31
+ private
28
32
 
29
33
  def unpack_files(source)
30
- source.map { |file| { name: file, data: File.read(file) } }
34
+ source.map { |file| { name: file, contents: File.read(file) } }
31
35
  end
32
36
 
33
37
  def array_of_filenames?(source)
data/styledown.gemspec CHANGED
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.author = 'Rico Sta. Cruz'
16
16
  s.email = 'hi@ricostacruz.com'
17
- s.homepage = 'http://github.com/styledown/styledown-ruby'
17
+ s.homepage = 'http://github.com/styledown/styledown-rails'
18
18
  s.license = 'MIT'
19
19
 
20
- s.add_dependency 'execjs', '>= 0'
21
- s.add_development_dependency 'rake', '>= 0'
20
+ s.add_dependency 'execjs', '>= 0', '< 3'
21
+ s.add_development_dependency 'rake', '>= 0', '< 12'
22
22
  end
@@ -0,0 +1,3 @@
1
+ ### Sample md block
2
+
3
+ Hello world.
data/test/test.rb CHANGED
@@ -1,69 +1,65 @@
1
1
  require File.expand_path('../test_helper', __FILE__)
2
2
 
3
- describe "Styledown.js_version" do
4
- it "produces a string" do
3
+ describe 'Styledown.js_version' do
4
+ it 'produces a string' do
5
5
  Styledown.js_version.must_match /^\d+\.\d+\.\d+/
6
6
  end
7
7
  end
8
8
 
9
- describe "Basic parsing" do
9
+ describe 'Basic parsing' do
10
10
  before do
11
- @output = Styledown.parse('### hi')
11
+ @data = Styledown.parse([{
12
+ name: 'buttons.md',
13
+ contents: '### hi'
14
+ }])
12
15
  end
13
16
 
14
- it "produces an HTML fragment" do
15
- @output.must_match /<h3[^>]+>hi<\/h3>/
17
+ it 'works' do
18
+ @data['files'].must_be_kind_of Hash
19
+ @data['files']['buttons.md'].must_be_kind_of Hash
20
+ @data['files']['buttons.md']['sections'].must_be_kind_of Hash
16
21
  end
17
22
 
18
- it "doesn't produce an HTML document" do
19
- @output.wont_match /^<!doctype html>/
20
- end
21
- end
23
+ describe 'with rendering' do
24
+ before do
25
+ @output = Styledown.render(@data, 'buttons.md')
26
+ end
22
27
 
23
- describe "Working with many files" do
24
- before do
25
- @output = Styledown.parse([
26
- { :name => "input.md", :data => "### hi from md" },
27
- { :name => "input.css", :data => "/**\n * hi from css:\n * world\n */" }
28
- ])
29
- end
28
+ it 'produces an HTML fragment' do
29
+ @output.must_match /<h3[^>]+>hi<\/h3>/
30
+ end
30
31
 
31
- it "parses the Markdown file" do
32
- @output.must_match /<h3[^>]+>hi from md<\/h3>/
32
+ it "doesn't produce an HTML document" do
33
+ @output.wont_match /^<!doctype html>/
34
+ end
33
35
  end
34
36
 
35
- it "parses the CSS file" do
36
- @output.must_match /<h3[^>]+>hi from css<\/h3>/
37
- end
38
- end
37
+ describe 'with rendering with layouts' do
38
+ before do
39
+ @output = Styledown.render(@data, 'buttons.md', layout: '<!doctype html><%- body %>')
40
+ end
39
41
 
40
- describe 'head options' do
41
- before do
42
- @output = Styledown.parse('### hi', head: '<meta>')
43
- end
44
-
45
- it "includes the head text" do
46
- @output.must_match /<meta>/
47
- end
42
+ it 'produces HTML' do
43
+ @output.must_match /<h3[^>]+>hi<\/h3>/
44
+ end
48
45
 
49
- it "produces an HTML document" do
50
- @output.must_match /^<!doctype html>/
46
+ it "uses the layout" do
47
+ @output.must_match /^<!doctype html>/
48
+ end
51
49
  end
52
50
  end
53
51
 
54
52
  describe 'Working with arrays of strings' do
55
53
  before do
56
- @output = Styledown.parse([
57
- fixture_path('simple/sample.css'),
58
- fixture_path('simple/sample.md')
54
+ @output = Styledown.parse_files([
55
+ fixture_path('simple/sample.md'),
56
+ fixture_path('simple/other_sample.md')
59
57
  ])
60
58
  end
61
59
 
62
- it 'renders from .md' do
63
- @output.must_match /Sample md block<\/h3>/
64
- end
65
-
66
- it 'renders from .css' do
67
- @output.must_match /Sample CSS block<\/h3>/
60
+ it 'parses' do
61
+ @output['files'].must_be_kind_of Hash
62
+ @output['files'][fixture_path('simple/sample.md')].must_be_kind_of Hash
63
+ @output['files'][fixture_path('simple/other_sample.md')].must_be_kind_of Hash
68
64
  end
69
65
  end
data/test/test_helper.rb CHANGED
@@ -4,17 +4,17 @@ require './lib/styledown'
4
4
  begin
5
5
  require 'minitest/reporters'
6
6
  if ENV['reporter'] == 'spec'
7
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new(:color => true)
7
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new(color: true)
8
8
  else
9
9
  Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
10
10
  end
11
11
  rescue LoadError => e
12
12
  end
13
13
 
14
- def test_path(path='')
14
+ def test_path(path = '')
15
15
  File.expand_path("../#{path}", __FILE__)
16
16
  end
17
17
 
18
- def fixture_path(path='')
18
+ def fixture_path(path = '')
19
19
  test_path "fixtures/#{path}"
20
20
  end