mkmatter 3.0.43 → 3.0.44

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
- SHA256:
3
- metadata.gz: a405b6be42a7e8fb19622603bed96dd889bb715cfde97b0c01a65057ddd71f12
4
- data.tar.gz: c5b9d9ce0af43a758e07f123299d0e88b291f734dfa7f5cd4c90a5e5b72216bc
2
+ SHA1:
3
+ metadata.gz: b8a12df223dfadcea474ccdd0ad3889bdb8ad424
4
+ data.tar.gz: 7f7ac303bf1ba4b42d2bdfe2e995893c325455e8
5
5
  SHA512:
6
- metadata.gz: 7e2a2f63485a52adb8251f416fb110342744e2c3416d76ffe88ae30b1eb5891fd1d91ad9cb7441edf1de1facf4bc50eaab6cf51bddf85489f6ce55efc263efab
7
- data.tar.gz: 3d2192267a88ac7e280ba1db8c1f6d02568e582a510936f50a854854121acf78c1db2dfa9fc1d676510907d6fd8ca7c96a7a9a698d2f59ed99c5746790c2b9a5
6
+ metadata.gz: 5b728c67461d41a80c6b54542758143a1295e3a008407ae478abdc1e0075367dd0afb6d9be2374cdda58f8710128ffba61b06c49da97c9e5f926b5bfbfb71de6
7
+ data.tar.gz: 0472a4a353cdb5c2b07a2cf4dcd9d3580bb23c38510ca47b260e2987aab2748fd4a4a658aee0144c81e33743c5513498f2b63451846199394aa70e11f9ad105e
data/.gitignore CHANGED
@@ -9,6 +9,5 @@
9
9
  /.idea/
10
10
  /.vscode/
11
11
  /vendor/
12
- Gemfile.lock
13
12
  *.gem
14
13
  pkg/
data/.gitlab-ci.yml CHANGED
@@ -21,4 +21,4 @@ test:
21
21
  stage: test
22
22
  script:
23
23
  - bundle install --path vendor/bundle
24
- - rake spec
24
+ - bundle exec rake
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  script: echo "Running tests against $(ruby -v) ..."
3
- cache: bundler
4
- bundler_args: --jobs=3 --retry=3 --standalone
3
+ bundler_args: --jobs=6 --retry=3 --standalone --deployment
5
4
  notifications:
6
5
  irc:
7
6
  channels:
@@ -14,17 +13,17 @@ notifications:
14
13
  jobs:
15
14
  include:
16
15
  - stage: test Ruby2.2
17
- rvm: 2.2.2
16
+ rvm: 2.2.7
18
17
  script:
19
18
  - echo "Running tests against $(ruby -v) ..."
20
19
  - bundle exec rake -t
21
20
  - stage: test Ruby2.3
22
- rvm: 2.3.0
21
+ rvm: 2.3.4
23
22
  script:
24
23
  - echo "Running tests against $(ruby -v) ..."
25
24
  - bundle exec rake -t
26
25
  - stage: test Ruby2.4
27
- rvm: 2.4.0
26
+ rvm: 2.4.1
28
27
  script:
29
28
  - echo "Running tests against $(ruby -v) ..."
30
29
  - bundle exec rake -t
@@ -35,7 +34,6 @@ jobs:
35
34
  - bundle exec rake -t
36
35
  - stage: test Ruby Head
37
36
  rvm: ruby-head
38
-
39
37
  script:
40
38
  - echo "Running tests against $(ruby -v) ..."
41
39
  - bundle exec rake -t
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  # Specify your gem's dependencies in mkmatter.gemspec
4
3
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mkmatter (3.0.44)
5
+ activesupport (~> 5.1)
6
+ front_matter_parser (~> 0.1)
7
+ git (~> 1.3)
8
+ highline (~> 1.7)
9
+ micro_install (~> 0.1.0)
10
+ os (~> 1.0)
11
+ rake (~> 10.0)
12
+ slugity (~> 1.1)
13
+ terminal-table (~> 1.8)
14
+ thor (~> 0.20)
15
+
16
+ GEM
17
+ remote: https://rubygems.org/
18
+ specs:
19
+ activesupport (5.1.5)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (~> 0.7)
22
+ minitest (~> 5.1)
23
+ tzinfo (~> 1.1)
24
+ addressable (2.3.8)
25
+ ansi (1.5.0)
26
+ builder (3.2.3)
27
+ concurrent-ruby (1.0.5)
28
+ front_matter_parser (0.1.1)
29
+ git (1.3.0)
30
+ highline (1.7.10)
31
+ i18n (0.9.5)
32
+ concurrent-ruby (~> 1.0)
33
+ json (1.8.6)
34
+ micro_install (0.1.0)
35
+ highline (~> 1.7)
36
+ os (~> 1.0)
37
+ paint (~> 2.0.1)
38
+ thor (~> 0.20)
39
+ unirest (~> 1.1)
40
+ mime-types (1.25.1)
41
+ minitest (5.11.3)
42
+ minitest-reporters (1.1.19)
43
+ ansi
44
+ builder
45
+ minitest (>= 5.0)
46
+ ruby-progressbar
47
+ os (1.0.0)
48
+ paint (2.0.1)
49
+ rake (10.5.0)
50
+ rest-client (1.6.9)
51
+ mime-types (~> 1.16)
52
+ ruby-progressbar (1.9.0)
53
+ slugity (1.1.0)
54
+ terminal-table (1.8.0)
55
+ unicode-display_width (~> 1.1, >= 1.1.1)
56
+ thor (0.20.0)
57
+ thread_safe (0.3.6)
58
+ tzinfo (1.2.5)
59
+ thread_safe (~> 0.1)
60
+ unicode-display_width (1.3.0)
61
+ unirest (1.1.2)
62
+ addressable (~> 2.3.5)
63
+ json (~> 1.8.1)
64
+ rest-client (~> 1.6.7)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ bundler (~> 1.16)
71
+ minitest (~> 5)
72
+ minitest-reporters (~> 1.1)
73
+ mkmatter!
74
+
75
+ BUNDLED WITH
76
+ 1.16.1
data/README.md CHANGED
@@ -1,31 +1,20 @@
1
1
  # mkmatter
2
2
 
3
- Builds & Links
4
-
5
- <div>
6
3
 
7
4
  [![Travis branch](https://img.shields.io/travis/IotaSpencer/mkmatter/dev.svg?style=for-the-badge)](https://travis-ci.org/IotaSpencer/mkmatter)
8
5
  [![Travis branch](https://img.shields.io/travis/IotaSpencer/mkmatter/master.svg?style=for-the-badge)](https://travis-ci.org/IotaSpencer/mkmatter)
9
- </div>
10
- <div class="m-0 p-0">
11
6
 
12
7
  [![Github commits (since latest release)](https://img.shields.io/github/commits-since/IotaSpencer/mkmatter/latest.svg?style=for-the-badge)]()
13
8
  [![GitHub commits](https://img.shields.io/github/commits-since/IotaSpencer/mkmatter/3.0.38.svg?style=for-the-badge)]()
14
- </div>
15
9
 
16
- ###### Gem
17
10
  [![Gem](https://img.shields.io/gem/v/mkmatter.svg?style=for-the-badge)](https://rubygems.org/gems/mkmatter)
18
11
  [![GitHub tag](https://img.shields.io/github/tag/IotaSpencer/mkmatter.svg?style=for-the-badge)](https://github.com/IotaSpencer/mkmatter/tree/v3.0.27)
19
12
 
20
-
21
13
  [![Gem](https://img.shields.io/gem/dt/mkmatter.svg?style=for-the-badge)](https://rubygems.org/gems/mkmatter)
22
14
  [![Gem](https://img.shields.io/gem/dtv/mkmatter.svg?style=for-the-badge)](https://rubygems.org/gems/mkmatter)
23
-
24
- ###### Badges
25
-
26
15
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
27
- [![forthebadge](https://forthebadge.com/images/badges/uses-badges.svg)](https://forthebadge.com)
28
16
 
17
+ [![forthebadge](https://forthebadge.com/images/badges/uses-badges.svg)](https://forthebadge.com)
29
18
  [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
30
19
  [![forthebadge](https://forthebadge.com/images/badges/uses-git.svg)](https://forthebadge.com)
31
20
 
@@ -78,7 +67,7 @@ or
78
67
 
79
68
  ## Usage
80
69
 
81
- **See [Wiki](https://github.com/IotaSpencer/mkmatter/wiki)
70
+ **See [Wiki](https://github.com/IotaSpencer/mkmatter/wiki)**
82
71
 
83
72
  ## Contributing
84
73
 
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new('spec')
5
-
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList['test/**/*_test.rb']
5
+ t.libs = ['../lib/mkmatter.rb']
6
+ t.warning = false
7
+ end
6
8
 
7
9
  desc 'Run tests'
8
- task :default => :spec
10
+ task default: :test
data/bin/mkmatter CHANGED
@@ -5,4 +5,4 @@ Signal.trap('INT') do
5
5
  $stderr.puts 'Got INT.. Exiting'
6
6
  exit 0
7
7
  end
8
- Mkmatter::App::Runner.new(ARGV.dup).execute!
8
+ Mkmatter::App::Runner.new(ARGV).execute!
data/bin/setup CHANGED
@@ -1,8 +1,7 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
1
+ #!/bin/sh
2
+ #
5
3
 
6
4
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
5
+ if [ $1 = "micro" ]; then
6
+ bundle exec micro-install
7
+ fi
@@ -0,0 +1,206 @@
1
+ require 'minitest'
2
+ require 'minitest/reporters/base_reporter'
3
+ module Minitest
4
+ module Reporters
5
+ def plugin_xs_and_os_init
6
+ Minitest.reporter.reporters.clear
7
+ Minitest.reporter << TravisReporter.new(options[:io], options)
8
+
9
+ end
10
+
11
+ class TravisReporter < Minitest::Reporters::BaseReporter
12
+
13
+
14
+ def initialize(*)
15
+ super
16
+ @color_enabled = io.respond_to?(:tty?) && io.tty?
17
+ @color_for_result_code = {
18
+ '.' => :green,
19
+ 'E' => :red,
20
+ 'F' => :red,
21
+ '$' => :yellow
22
+ }
23
+ @result_code_to_unicode = {
24
+ '.' => "\u{2714}",
25
+ 'F' => "\u{2718}",
26
+ 'E' => "\u{203C}",
27
+ '$' => "\u{26A1}"
28
+ }
29
+ @color = {
30
+ red: 31,
31
+ green: 32,
32
+ yellow: 33,
33
+ blue: 34
34
+ }
35
+ end
36
+
37
+ def record(result)
38
+ super
39
+ puts
40
+ print result.class_name
41
+ print ' '
42
+ print self.result_name result.name
43
+ print ' ['
44
+ print_result_code(result.result_code)
45
+ print ']'
46
+ end
47
+
48
+ def start
49
+ super
50
+ io.print "Run options: #{options[:args]} / "
51
+ io.print 'Running:'
52
+ end
53
+
54
+ def report
55
+ super
56
+ io.sync = true
57
+
58
+ failing_results = results.reject(&:skipped?)
59
+ skipped_results = results.select(&:skipped?)
60
+
61
+ color = :green
62
+ color = :yellow if skipped_results.any?
63
+ color = :red if failing_results.any?
64
+
65
+ if failing_results.any? || skipped_results.any?
66
+ failing_results.each.with_index(1) { |result, index| display_failing(result, index) }
67
+ skipped_results.each.with_index(failing_results.size + 1) { |result, index| display_skipped(result, index) }
68
+ end
69
+
70
+ io.print "\n\n"
71
+ io.puts statistics
72
+ io.puts color(summary, color)
73
+
74
+ if failing_results.any?
75
+ io.puts "\nFailed Tests:\n"
76
+ failing_results.each { |result| display_replay_command(result) }
77
+ io.puts "\n\n"
78
+ end
79
+ end
80
+
81
+
82
+ def statistics
83
+ 'Finished in %.6fs, %.4f runs/s, %.4f assertions/s.' %
84
+ [total_time, count / total_time, assertions / total_time]
85
+ end
86
+
87
+ def summary # :nodoc:
88
+ [
89
+ pluralize('run', count),
90
+ pluralize('assertion', assertions),
91
+ pluralize('failure', failures),
92
+ pluralize('error', errors),
93
+ pluralize('skip', skips)
94
+ ].join(', ')
95
+ end
96
+
97
+ def indent(text)
98
+ text.gsub(/^/, ' ')
99
+ end
100
+
101
+ def display_failing(result, index)
102
+ backtrace = backtrace(result.failure.backtrace)
103
+ message = result.failure.message
104
+ message = message.lines.tap(&:pop).join.chomp if result.error?
105
+
106
+ str = "\n\n"
107
+ str << color('%4d) %s' % [index, result_name(result.name)])
108
+ str << "\n" << color(indent(message), :red)
109
+ str << "\n" << color(backtrace, :blue)
110
+ io.print str
111
+ end
112
+
113
+ def display_skipped(result, index)
114
+ location = location(result.failure.location)
115
+ str = "\n\n"
116
+ str << color('%4d) %s [SKIPPED]' % [index, result_name(result.name)], :yellow)
117
+ str << "\n" << indent(color(location, :yellow))
118
+ io.print str
119
+ end
120
+
121
+ def display_replay_command(result)
122
+ location, line = find_test_file(result)
123
+ return if location.empty?
124
+
125
+ command = if defined?(Rails) && Rails.version >= '5.0.0'
126
+ %[bin/rails test #{location}:#{line}]
127
+ else
128
+ %[rake TEST=#{location} TESTOPTS="--name=#{result.name}"]
129
+ end
130
+
131
+ str = "\n"
132
+ str << color(command, :red)
133
+
134
+ io.print str
135
+ end
136
+
137
+ def find_test_file(result)
138
+ location, line = result.method(result.name).source_location
139
+ location = location.gsub(%r[^.*?/((?:test|spec)/.*?)$], "\\1")
140
+
141
+ [location, line]
142
+ end
143
+
144
+ def backtrace(backtrace)
145
+ backtrace = filter_backtrace(backtrace).map { |line| location(line, true) }
146
+ return if backtrace.empty?
147
+ indent(backtrace.join("\n")).gsub(/^(\s+)/, "\\1# ")
148
+ end
149
+
150
+ def location(location, include_line_number = false)
151
+ regex = include_line_number ? /^([^:]+:\d+)/ : /^([^:]+)/
152
+ location = File.expand_path(location[regex, 1])
153
+
154
+ return location unless location.start_with?(Dir.pwd)
155
+
156
+ location.gsub(%r[^#{Regexp.escape(Dir.pwd)}/], '')
157
+ end
158
+
159
+ def filter_backtrace(backtrace)
160
+ Minitest.backtrace_filter.filter(backtrace)
161
+ end
162
+
163
+ def result_name(name)
164
+ name
165
+ .gsub(/^test(_\d+)?_/, '')
166
+ .gsub(/_/, ' ')
167
+ end
168
+
169
+ def print_result_code(result_code)
170
+ result = @result_code_to_unicode[result_code]
171
+ colors = {
172
+ "\u{2714}" => :green,
173
+ "\u{2718}" => :red,
174
+ "\u{203C}" => :red,
175
+ "\u{26A1}" => :yellow
176
+ }
177
+ io.print color(result_code, colors[result])
178
+ end
179
+
180
+ def color(string, color = :default)
181
+ if color_enabled?
182
+ color = @color.fetch(color, 0)
183
+ "\e[#{color}m#{string}\e[0m"
184
+ else
185
+ string
186
+ end
187
+ end
188
+
189
+ def color_enabled?
190
+ @color_enabled
191
+ end
192
+
193
+ def pluralize(word, count)
194
+ case count
195
+ when 0
196
+ "no #{word}s"
197
+ when 1
198
+ "1 #{word}"
199
+ else
200
+ "#{count} #{word}s"
201
+ end
202
+ end
203
+ end
204
+ end
205
+
206
+ end
@@ -21,8 +21,6 @@ module Mkmatter
21
21
  @slug_date = now.strftime('%Y-%m-%d')
22
22
  @published = publish
23
23
  @file_format = question_hash[:file_format]
24
- @keywords = question_hash[:keywords]
25
- @description = question_hash[:description]
26
24
  @matter = {
27
25
  layout: @layout,
28
26
  title: @title,
@@ -7,20 +7,19 @@ require 'terminal-table'
7
7
  require 'os'
8
8
  require 'rbconfig'
9
9
 
10
- require 'mkmatter'
11
10
  require 'mkmatter/cli/subs'
12
11
  require 'mkmatter/gem_info'
12
+
13
13
  module Mkmatter
14
14
  module App
15
15
  class CLI < Thor
16
- include Thor::Actions
17
-
18
16
  # \(see {http://www.rubydoc.info/gems/highline/HighLine#initialize-instance_method HighLine#new}\)
19
17
  HILINE = HighLine.new($stdin, $stderr, 80)
20
18
  map %w[--version -v] => :__print_version
21
19
  desc '--version, -v', 'Print the version'
22
20
 
23
21
  # Prints version string
22
+ # @return [NilClass] nil
24
23
  def __print_version
25
24
  puts Mkmatter::VERSION
26
25
  end
@@ -28,12 +27,12 @@ module Mkmatter
28
27
  map %w[--debug -d] => :__debug
29
28
  desc '--debug, -d', 'Prints debug info about the script/gem'
30
29
  # Prints debug info
30
+ # @return [NilClass] returns nil
31
31
  def __debug
32
- info = Mkmatter::GemInfo.new
33
32
  report = YAML.safe_load(OS.report)
34
33
  rows = {
35
34
  'mkmatter_version' => Mkmatter::VERSION,
36
- 'ruby_version' => RbConfig::CONFIG['RUBY_PROGRAM_VERSION'],
35
+ 'ruby_version' => RbConfig::CONFIG['RUBY_PROGRAM_VERSION'],
37
36
  }
38
37
  rows.merge! report
39
38
  rows.merge!({
@@ -42,15 +41,14 @@ module Mkmatter
42
41
  'posix' => OS.posix?,
43
42
  'mac' => OS.mac?,
44
43
  'under windows' => OS::Underlying.windows?,
45
- 'under bsd' => OS::Underlying.bsd?
44
+ 'under bsd' => OS::Underlying.bsd?,
46
45
  })
47
- table = Terminal::Table.new
48
- table.title = 'mkmatter Debug Info'
49
- table.rows = rows.to_a
46
+ table = Terminal::Table.new
47
+ table.title = 'mkmatter Debug Info'
48
+ table.rows = rows.to_a
50
49
  table.align_column(0, :left)
51
-
50
+
52
51
  puts table
53
-
54
52
  end
55
53
 
56
54
  map %w[--info -i] => :__print_info
@@ -63,22 +61,20 @@ module Mkmatter
63
61
  'author(s)': Mkmatter::GemInfo.authors.join(', '),
64
62
  'e-mail': Mkmatter::GemInfo.email.join(', '),
65
63
  'mkmatter version': Mkmatter::VERSION,
66
- 'Ruby version': RbConfig::CONFIG['RUBY_PROGRAM_VERSION'],
67
- 'Platform': RbConfig::CONFIG['build_os']
64
+ 'Ruby version': RbConfig::CONFIG['RUBY_PROGRAM_VERSION'],
65
+ 'Platform': RbConfig::CONFIG['build_os'],
68
66
  }
69
67
  case format
70
68
  when 'table'
71
- table = Terminal::Table.new
72
- table.style.alignment = :center
73
- table.title = 'mkmatter Info'
74
- table.rows = rows.to_a
69
+ table = Terminal::Table.new
70
+ table.style.alignment = :center
71
+ table.title = 'mkmatter Info'
72
+ table.rows = rows.to_a
75
73
  table.align_column(0, :left)
76
-
74
+
77
75
  puts table
78
-
79
76
  when 'yaml'
80
77
  puts rows.stringify_keys.to_yaml
81
-
82
78
  else
83
79
  # noop
84
80
  # this doesn't get run because of
@@ -87,12 +83,15 @@ module Mkmatter
87
83
  end
88
84
  end
89
85
 
86
+ if Pathname(Dir.home).join('.local/bin/micro').exist?
87
+ class_option(:editor, type: :string, default: "#{Dir.home}/.local/bin")
88
+ else
89
+ class_option(:editor, type: :string, default: 'nano')
90
+ end
90
91
  desc 'new SUBCOMMAND [options]', 'Make new content'
91
92
  subcommand 'new', Mkmatter::App::Classes::NewContent
92
93
  desc 'tags SUBCOMMAND [options]', 'Generate or Create tags'
93
94
  subcommand 'tags', Mkmatter::App::Classes::Tags
94
95
  end
95
-
96
-
97
96
  end
98
- end
97
+ end
@@ -5,16 +5,17 @@ module Mkmatter
5
5
  module App
6
6
  module Descriptions
7
7
  module New
8
- PAGE = <<-PAGEDOC
8
+ PAGE = ERB.new(<<-PAGEDOC.strip_heredoc
9
9
  `mkmatter new page` will run you through making a jekyll page.
10
10
 
11
11
  Given the above options/flags you can modify how the script
12
12
 
13
13
  outputs your front matter, or whether to mark it as published.
14
-
14
+
15
15
  PAGEDOC
16
-
17
- POST = <<-POSTDOC
16
+ ).result
17
+
18
+ POST = ERB.new(<<-POSTDOC.strip_heredoc
18
19
  `mkmatter new post` will run you through making a jekyll post.
19
20
 
20
21
  Given the above options/flags you can modify how the script
@@ -30,14 +31,18 @@ module Mkmatter
30
31
 
31
32
  the front matter. So if you omit `--publish` you will publish,
32
33
 
33
- so you have to explicitly use --no-publish to set `#{HighLine.color('published', :yellow)}: #{HighLine.color('false', :yellow, :bold)}`
34
+ so you have to explicitly use --no-publish to set `<%= HighLine.color('published', :yellow) %>:
35
+ <%= HighLine.color('false', :yellow, :bold) %>`
34
36
 
35
37
  POSTDOC
38
+ ).result
36
39
  end
40
+
37
41
  module Tags
38
- GEN = <<-GENDOC
39
-
42
+ GEN = ERB.new(<<-GENDOC
43
+
40
44
  GENDOC
45
+ ).result
41
46
  end
42
47
  end
43
48
  end