mumukit-content-type 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2Y2OGZkMzkzYjA5MmFiYThjY2ZiNTBjYmU5NjFjMDg4MjQ3MzdmYQ==
5
+ data.tar.gz: !binary |-
6
+ NDc3OTg3YzFhNzk3ZDE5Mzk5NWM2NmIzMjI4YTgzM2VkZWVmN2I3MA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTljZDJiNGFiODZmZDQ2MGQzY2VjY2I1MTAxY2FhM2ZhOWE2MmZmMDEzNTlk
10
+ MWE1N2YxMTM5ZmZmNWVkM2NiYWM0M2E0ZmU1OTk3ZTVkYmU3ZWQ1Y2QxOGU0
11
+ YjkzOTc4OTIzZDUwYjRmMWI5MmRkMTVlM2FiNmZiZmU3OTU5OTI=
12
+ data.tar.gz: !binary |-
13
+ Nzk5ZTBjNDdjNWRmZTI2M2JlOWY4NmNmNGJiNGNiNzdmNzY5MGU1NDVkMTZl
14
+ NGI1M2Y0ZmZjZjFhMGI0ODlkZjkyNzZhN2FmNGQ1ZTFjMmIyOTBmMjU3MDYx
15
+ OWI3MjUwOTJhYzljMGI0OTg2M2E1NjQxNTdkZDVmMDc4M2Y4NzU=
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ deploy:
5
+ provider: rubygems
6
+ api_key:
7
+ secure: eqoGYHR8QtBSw7Kqn0uabhP7rEUTBsQbLE47YIQZSxtCT4NJdmh9HcevX4e3kEJpcZV8xRuPXltG4bWcfWjURiUb2GAJSTHB2BQx7fVS2DS+gOH80TFEuEgoTavQDZgGBkXo/Ct6aDjTGgQzNtq82U4AOrEDaXiyjHzb+CZCYUv8ozQpWlslj1tmbI8im/wvpqC6iLZdDF5ESItduYeh6b7O3v88OYLkW9qJse62gq5s24fwCazeBS0LhQ/wIqHyhHKZOaPXpBP3jWCcijVJgamn13jjNjekYI7aRwZsyJrj738REOeLRQ4zvljLs9Ttx0cBtubY3odvsX8FQUUorACnhHOVRz83qQWbb8ySDhRoJJfHUqkc6euWYGuCPXvl/1KrEUzEQ405C0uaphzwLUaNBw+1z/MUzkBIVSThUoJtSs4Xm5iXCc5fAoeKNLWt8KTy3TBeFH1UAHX/n6Ub/fxVtK5w10aKf2HVZ4r2NzT9U145Ivr+okl3/YvLLqkZj5J3vid/WPgyoMAi/P88aXr3zW5BiUQfGGPN54UgNrEJNO3v+YjZ/uB0quRtEC3UEb2UbiNBsbFJffwlxnZpsfdJUdZm/H6wbkAOCFpnJy9NvLSZTpVxjkoTTa9rvGtDSSRgPJBS5BB6aaP34PIJFCKrkCcTyRuMbSEEP9vY9yM=
8
+ gem: mumukit-content-type
9
+ on:
10
+ tags: true
11
+ repo: mumuki/mumukit-content-type
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Franco Leonardo Bulgarelli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ [![Build Status](https://travis-ci.org/mumuki/mumukit-content-type.svg)](https://travis-ci.org/mumuki/mumukit-content-type)
2
+ [![Code Climate](https://codeclimate.com/github/mumuki/mumukit-content-type/badges/gpa.svg)](https://codeclimate.com/github/mumuki/mumukit-content-type)
3
+ [![Test Coverage](https://codeclimate.com/github/mumuki/mumukit-content-type/badges/coverage.svg)](https://codeclimate.com/github/mumuki/mumukit-content-type)
4
+
5
+ # Mumukit::ContentType
6
+
7
+ Classes for handling different rendering formats within Mumuki:
8
+
9
+ * HTML
10
+ * Plain
11
+ * Markdown
12
+
13
+ Those classes allow to both render code and arbitrary text
14
+
15
+ ## Contributing
16
+
17
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mumukit-content-type/mumukit-content-type-content-type. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
18
+
19
+
20
+ ## License
21
+
22
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
23
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mumukit/content/type"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ require 'mumukit/core'
2
+
3
+ module Mumukit
4
+ module ContentType
5
+ module BaseContentType
6
+ def format_exception(e)
7
+ "#{title e.message}\n#{code e.backtrace.join("\n")}"
8
+ end
9
+ end
10
+
11
+ def self.parse(s)
12
+ Kernel.const_get "Mumukit::ContentType::#{s.to_s.titlecase}"
13
+ rescue
14
+ raise "unknown content_type #{s}"
15
+ end
16
+
17
+ def self.for(type)
18
+ parse(type)
19
+ end
20
+ end
21
+ end
22
+
23
+ require_relative './content_type/markdown'
24
+ require_relative './content_type/with_markdown'
25
+ require_relative './content_type/plain'
26
+ require_relative './content_type/html'
@@ -0,0 +1,19 @@
1
+ module Mumukit::ContentType::Html
2
+ extend Mumukit::ContentType::BaseContentType
3
+
4
+ def self.title(title)
5
+ "<strong>#{title}</strong>"
6
+ end
7
+
8
+ def self.code(code)
9
+ "<pre>#{code}</pre>"
10
+ end
11
+
12
+ def self.to_html(content)
13
+ content.html_safe if content
14
+ end
15
+
16
+ def self.name
17
+ 'html'
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ require 'md_emoji'
2
+ require 'rouge'
3
+ require 'redcarpet'
4
+ require 'rouge/plugins/redcarpet'
5
+
6
+ module Mumukit::ContentType::Markdown
7
+ extend Mumukit::ContentType::BaseContentType
8
+
9
+ def self.title(title)
10
+ "**#{title}**"
11
+ end
12
+
13
+ def self.code(code)
14
+ "\n```\n#{code}\n```\n\n"
15
+ end
16
+
17
+ class HTML < MdEmoji::Render
18
+ include Rouge::Plugins::Redcarpet
19
+
20
+ def table(header, body)
21
+ "<table class=\"table\"><thead>\n#{header}</thead><tbody>\n#{body}</tbody></table>\n"
22
+ end
23
+ end
24
+
25
+ @@markdown = Redcarpet::Markdown.new(HTML, autolink: true, fenced_code_blocks: true, no_intra_emphasis: true, tables: true)
26
+
27
+ def self.to_html(content)
28
+ @@markdown.render(content).html_safe if content
29
+ end
30
+
31
+ def self.name
32
+ 'markdown'
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ module Mumukit::ContentType::Plain
2
+ extend Mumukit::ContentType::BaseContentType
3
+
4
+ def self.title(title)
5
+ "#{title}:"
6
+ end
7
+
8
+ def self.code(code)
9
+ "\n-----\n#{code}\n-----\n\n"
10
+ end
11
+
12
+ def self.to_html(content)
13
+ "<pre>#{ERB::Util.html_escape content}</pre>".html_safe
14
+ end
15
+
16
+ def self.name
17
+ 'plain'
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Mumukit
2
+ module ContentType
3
+ VERSION = '0.2.1'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class Module
2
+ def markdown_on(*selectors)
3
+ selectors.each { |selector| _define_markdown_on(selector) }
4
+ end
5
+
6
+ private
7
+
8
+ def _define_markdown_on(selector)
9
+ define_method("#{selector}_html".to_sym) do |*args|
10
+ Mumukit::ContentType::Markdown.to_html self.send(selector, *args)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mumukit/content_type/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'mumukit-content-type'
8
+ spec.version = Mumukit::ContentType::VERSION
9
+ spec.authors = ['Franco Leonardo Bulgarelli']
10
+ spec.email = ['franco@mumuki.org']
11
+
12
+ spec.summary = 'Content Type handling for Mumuki'
13
+ spec.homepage = 'http://mumuki.io'
14
+ spec.license = 'MIT'
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
18
+ else
19
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.7'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~>2.9'
30
+
31
+ spec.add_dependency 'rouge'
32
+ spec.add_dependency 'redcarpet', '~> 3.3.2'
33
+ spec.add_dependency 'md_emoji'
34
+ spec.add_dependency 'mumukit-core', '~> 0.1'
35
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumukit-content-type
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-08 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rouge
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redcarpet
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.3.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.3.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: md_emoji
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mumukit-core
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.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.1'
111
+ description:
112
+ email:
113
+ - franco@mumuki.org
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - .travis.yml
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/mumukit/content_type.rb
129
+ - lib/mumukit/content_type/html.rb
130
+ - lib/mumukit/content_type/markdown.rb
131
+ - lib/mumukit/content_type/plain.rb
132
+ - lib/mumukit/content_type/version.rb
133
+ - lib/mumukit/content_type/with_markdown.rb
134
+ - mumukit-content-type.gemspec
135
+ homepage: http://mumuki.io
136
+ licenses:
137
+ - MIT
138
+ metadata:
139
+ allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'''
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Content Type handling for Mumuki
160
+ test_files: []