madan 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: '04970f903cf1f4399d833535296a1dfb47aaf7c7'
4
+ data.tar.gz: d0c94c37ab99d3fe353235e68e88085373cc1d04
5
+ SHA512:
6
+ metadata.gz: b30d787b0d25654897f5296b727ef7486d9b6ae1ffc0838e07ae1d37e5d6af847f405d778b55412bffaeb98a01ba45c0a17f97710591a6fd5b915868a0b131d1
7
+ data.tar.gz: 9d3ae5c4fc762b79cdb2dcaaeab1af90fa84bfee6224d353d9cdb4de0fd3b19c4a7243da03e6507e8d5ba43533b3202bb2b7e56bf741604530be93fbfb78eda5
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .idea/
10
+ *.swp
11
+ *.swo
12
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in madan.gemspec
6
+ gemspec
7
+ gem 'tty-markdown', :git => 'git@github.com:piotrmurach/tty-markdown.git', :branch => 'master'
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Madan
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/madan`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'madan'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install madan
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/madan.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "madan"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/madan ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'madan'
4
+
5
+ Madan.application.run
@@ -0,0 +1,35 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'commander'
4
+ require 'madan/file_parser'
5
+ require 'tty-markdown'
6
+ require 'tty-pager'
7
+
8
+ module Madan
9
+ class Application
10
+ include Commander::Methods
11
+
12
+ def run
13
+ program :name, "Madan"
14
+ program :version, Madan::VERSION
15
+ program :description, "Preview Markdown File In Terminal"
16
+
17
+ command :present do |c|
18
+ c.syntax = 'madan present FILE'
19
+ c.description = 'present markdown file'
20
+ c.action do |args, options|
21
+ file_arg = args.first
22
+ if File.directory?(file_arg) || File.file?(file_arg)
23
+ file_parser = Madan::FileParser.new(file_arg)
24
+ str = file_parser.parse
25
+ parsed = TTY::Markdown.parse(str)
26
+ pager = TTY::Pager.new
27
+ pager.page(parsed)
28
+ end
29
+ end
30
+ end
31
+ alias_command :p, :present
32
+ run!
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ require 'pry'
2
+ module Madan
3
+ class FileParser
4
+ ALLOWED_EXTENSIONS = %w(.md .markdown)
5
+
6
+ def initialize(path)
7
+ @path = path
8
+ @md = Madan::MdUtils.new
9
+ end
10
+
11
+ def parse
12
+ contents = ""
13
+ if File.file?(@path)
14
+ contents = File.read(@path)
15
+ end
16
+ contents
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ require 'madan/application'
2
+
3
+ module Madan
4
+ class << self
5
+ def application
6
+ @application = Madan::Application.new
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ module Madan
2
+ class MdUtils
3
+ def h1(title)
4
+ "# #{title}\n"
5
+ end
6
+
7
+ def h2(title)
8
+ "## #{title}"
9
+ end
10
+
11
+ def h3(title)
12
+ "### #{title}"
13
+ end
14
+
15
+ def h4(title)
16
+ "#### #{title}"
17
+ end
18
+
19
+ def h5(title)
20
+ "##### #{title}"
21
+ end
22
+
23
+ def hr
24
+ "*** \n"
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Madan
2
+ VERSION = "0.1.0"
3
+ end
data/lib/madan.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "madan/version"
2
+ require "madan/madan_module"
3
+ require "madan/application"
4
+ require "madan/file_parser"
5
+ require "madan/md_utils"
6
+
7
+ module Madan
8
+ end
data/madan.gemspec ADDED
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "madan/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "madan"
8
+ spec.version = Madan::VERSION
9
+ spec.authors = ["Taff Gao"]
10
+ spec.email = ["gaotongfei1995@gmail.com"]
11
+
12
+ spec.summary = %q{Preview markdown file in terminal.}
13
+ spec.description = %q{Thanks to @piotrmurach's great work, you can preview markdown file in terminal with a friendly output now.}
14
+ spec.homepage = "https://github.com/gaotongfei/madan"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "minitest", "~> 5.0"
34
+ spec.add_development_dependency "pry"
35
+ spec.add_development_dependency "pry-byebug"
36
+
37
+ #spec.add_dependency "tty-markdown"
38
+ spec.add_dependency "tty-pager"
39
+ spec.add_dependency "commander"
40
+ end
data/sample.md ADDED
@@ -0,0 +1,88 @@
1
+ # Project Title
2
+
3
+ One Paragraph of project description goes here
4
+
5
+ ## Getting Started
6
+
7
+ These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
8
+
9
+ ### Prerequisites
10
+
11
+ What things you need to install the software and how to install them
12
+
13
+ ```
14
+ Give examples
15
+ ```
16
+
17
+ ### Installing
18
+
19
+ A step by step series of examples that tell you have to get a development env running
20
+
21
+ Say what the step will be
22
+
23
+ ```
24
+ Give the example
25
+ ```
26
+
27
+ And repeat
28
+
29
+ ```
30
+ until finished
31
+ ```
32
+
33
+ End with an example of getting some data out of the system or using it for a little demo
34
+
35
+ ## Running the tests
36
+
37
+ Explain how to run the automated tests for this system
38
+
39
+ ### Break down into end to end tests
40
+
41
+ Explain what these tests test and why
42
+
43
+ ```
44
+ Give an example
45
+ ```
46
+
47
+ ### And coding style tests
48
+
49
+ Explain what these tests test and why
50
+
51
+ ```
52
+ Give an example
53
+ ```
54
+
55
+ ## Deployment
56
+
57
+ Add additional notes about how to deploy this on a live system
58
+
59
+ ## Built With
60
+
61
+ * [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
62
+ * [Maven](https://maven.apache.org/) - Dependency Management
63
+ * [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds
64
+
65
+ ## Contributing
66
+
67
+ Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.
68
+
69
+ ## Versioning
70
+
71
+ We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
72
+
73
+ ## Authors
74
+
75
+ * **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)
76
+
77
+ See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
78
+
79
+ ## License
80
+
81
+ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
82
+
83
+ ## Acknowledgments
84
+
85
+ * Hat tip to anyone who's code was used
86
+ * Inspiration
87
+ * etc
88
+
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: madan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Taff Gao
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-27 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-pager
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: commander
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Thanks to @piotrmurach's great work, you can preview markdown file in
112
+ terminal with a friendly output now.
113
+ email:
114
+ - gaotongfei1995@gmail.com
115
+ executables:
116
+ - madan
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - exe/madan
128
+ - lib/madan.rb
129
+ - lib/madan/application.rb
130
+ - lib/madan/file_parser.rb
131
+ - lib/madan/madan_module.rb
132
+ - lib/madan/md_utils.rb
133
+ - lib/madan/version.rb
134
+ - madan.gemspec
135
+ - sample.md
136
+ homepage: https://github.com/gaotongfei/madan
137
+ licenses: []
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.6.14
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Preview markdown file in terminal.
159
+ test_files: []