mkmatter 3.0.44 → 3.0.45

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8a12df223dfadcea474ccdd0ad3889bdb8ad424
4
- data.tar.gz: 7f7ac303bf1ba4b42d2bdfe2e995893c325455e8
3
+ metadata.gz: 2887153201c4031bf7657eaf3034510b57a124fb
4
+ data.tar.gz: ee281dfd39a59fbc5a7549cdb8fffe6bec2ebc51
5
5
  SHA512:
6
- metadata.gz: 5b728c67461d41a80c6b54542758143a1295e3a008407ae478abdc1e0075367dd0afb6d9be2374cdda58f8710128ffba61b06c49da97c9e5f926b5bfbfb71de6
7
- data.tar.gz: 0472a4a353cdb5c2b07a2cf4dcd9d3580bb23c38510ca47b260e2987aab2748fd4a4a658aee0144c81e33743c5513498f2b63451846199394aa70e11f9ad105e
6
+ metadata.gz: 70b2fb1a3ba7e594eb8f6fdaee2f36e3dc32388c05c0f265fc5aaa588cca0c2f19d01b698414962c469dc2053a5e08858f73d06b02229d21d97e6824b12d4cd3
7
+ data.tar.gz: 0e6424d949d23738c79ff423b5a5513525c3f98db1c6b065459e37b68428a4fc70589774f159904e04ec7bfd340351fb37e8d3a14627eed64c8048c5bfd557c4
data/README.md CHANGED
@@ -1,12 +1,8 @@
1
1
  # mkmatter
2
2
 
3
-
4
3
  [![Travis branch](https://img.shields.io/travis/IotaSpencer/mkmatter/dev.svg?style=for-the-badge)](https://travis-ci.org/IotaSpencer/mkmatter)
5
4
  [![Travis branch](https://img.shields.io/travis/IotaSpencer/mkmatter/master.svg?style=for-the-badge)](https://travis-ci.org/IotaSpencer/mkmatter)
6
5
 
7
- [![Github commits (since latest release)](https://img.shields.io/github/commits-since/IotaSpencer/mkmatter/latest.svg?style=for-the-badge)]()
8
- [![GitHub commits](https://img.shields.io/github/commits-since/IotaSpencer/mkmatter/3.0.38.svg?style=for-the-badge)]()
9
-
10
6
  [![Gem](https://img.shields.io/gem/v/mkmatter.svg?style=for-the-badge)](https://rubygems.org/gems/mkmatter)
11
7
  [![GitHub tag](https://img.shields.io/github/tag/IotaSpencer/mkmatter.svg?style=for-the-badge)](https://github.com/IotaSpencer/mkmatter/tree/v3.0.27)
12
8
 
@@ -27,7 +23,6 @@
27
23
 
28
24
  [![E-mail](https://img.shields.io/badge/mkmatter%20on%20IotaSpencer%2eme-Project-green.svg?style=for-the-badge)](https://iotaspencer.me/projects/mkmatter)
29
25
 
30
-
31
26
  ## About mkmatter
32
27
 
33
28
  'mkmatter' is a gem designed to make it easy to generate front matter for files and also subsequently edit them.
@@ -38,6 +33,24 @@ This is needed for any part that `reads from/writes to` the filesystem.
38
33
 
39
34
  ## Installation
40
35
 
36
+ **Note**: Thanks to [@zyedidia](https://github.com/zyedidia), His project [micro](https://github.com/zyedidia/micro) has been bundled alongside mkmatter. Just by using one command you can install it for your own use.
37
+
38
+ However, to use micro the way its installed using the gem, you need to have the directory in your `$PATH`.
39
+
40
+ ### Micro Installation
41
+
42
+ Add
43
+ ```shell
44
+ PATH="$HOME/bin:$HOME/.local/bin:$PATH"
45
+ ```
46
+
47
+ If you do install micro, it will use micro by default unless you override it with `--editor=EDITOR`
48
+
49
+
50
+ ### Mkmatter Installation
51
+
52
+ #### Bundler
53
+
41
54
  Add this line to your application's Gemfile:
42
55
 
43
56
  ```ruby
@@ -45,25 +58,32 @@ gem 'mkmatter'
45
58
  ```
46
59
 
47
60
  And then execute:
61
+ ```
62
+ $ bundle install
63
+ ```
48
64
 
49
- $ bundle install
50
-
51
- ### Standalone
65
+ #### Standalone
52
66
 
53
67
  To install to the system/user instead of a project, use the following
54
68
 
55
- #### System-wide
69
+ ##### System-wide
56
70
  As root or by using sudo, run:
57
71
 
58
- ```$ gem install mkmatter```
72
+ ```
73
+ $ gem install mkmatter
74
+ ```
59
75
 
60
76
  or
61
77
 
62
- ```$ sudo gem install mkmatter```
78
+ ```
79
+ $ sudo gem install mkmatter
80
+ ```
63
81
 
64
- #### User
82
+ ##### User
65
83
 
66
- ```$ gem install --user-install mkmatter```
84
+ ```
85
+ $ gem install --user-install mkmatter
86
+ ```
67
87
 
68
88
  ## Usage
69
89
 
@@ -9,29 +9,29 @@ module Minitest
9
9
  end
10
10
 
11
11
  class TravisReporter < Minitest::Reporters::BaseReporter
12
-
12
+ @@color_for_result_code = {
13
+ '.' => :green,
14
+ 'E' => :red,
15
+ 'F' => :red,
16
+ '$' => :yellow
17
+ }
18
+ @@result_code_to_unicode = {
19
+ '.' => "\u{2714}",
20
+ 'F' => "\u{2718}",
21
+ 'E' => "\u{203C}",
22
+ '$' => "\u{26A1}"
23
+ }
24
+ @@color = {
25
+ red: 31,
26
+ green: 32,
27
+ yellow: 33,
28
+ blue: 34
29
+ }
13
30
 
14
31
  def initialize(*)
15
32
  super
16
33
  @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
- }
34
+
35
35
  end
36
36
 
37
37
  def record(result)
@@ -167,7 +167,7 @@ module Minitest
167
167
  end
168
168
 
169
169
  def print_result_code(result_code)
170
- result = @result_code_to_unicode[result_code]
170
+ result = @@result_code_to_unicode[result_code]
171
171
  colors = {
172
172
  "\u{2714}" => :green,
173
173
  "\u{2718}" => :red,
@@ -179,7 +179,7 @@ module Minitest
179
179
 
180
180
  def color(string, color = :default)
181
181
  if color_enabled?
182
- color = @color.fetch(color, 0)
182
+ color = @@color.fetch(color, 0)
183
183
  "\e[#{color}m#{string}\e[0m"
184
184
  else
185
185
  string
@@ -4,14 +4,12 @@ require 'highline'
4
4
  module Mkmatter
5
5
  class Answers
6
6
  attr_accessor :title, :tags, :categories
7
- attr_accessor :date, :layout, :draft
7
+ attr_accessor :date, :draft
8
8
  attr_accessor :slug_date, :answer_hash
9
9
  attr_accessor :published, :file_format
10
10
  attr_reader :matter
11
11
 
12
12
  def initialize(question_hash, publish)
13
-
14
- @layout = question_hash[:layout]
15
13
  @title = question_hash[:title]
16
14
  @tags = question_hash[:tags]
17
15
  @categories = question_hash[:categories]
@@ -84,7 +84,10 @@ module Mkmatter
84
84
  end
85
85
 
86
86
  if Pathname(Dir.home).join('.local/bin/micro').exist?
87
- class_option(:editor, type: :string, default: "#{Dir.home}/.local/bin")
87
+ class_option(:editor, type: :string, default: "#{Dir.home}/.local/bin/micro")
88
+
89
+ elsif Methods.which('micro')
90
+ class_option(:editor, type: :string, default: 'micro')
88
91
  else
89
92
  class_option(:editor, type: :string, default: 'nano')
90
93
  end
@@ -29,13 +29,25 @@ module Mkmatter
29
29
  end
30
30
  end
31
31
  end
32
-
32
+
33
+ def Methods.which(cmd)
34
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
35
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
36
+ exts.each { |ext|
37
+ exe = File.join(path, "#{cmd}#{ext}")
38
+ return exe if File.executable?(exe) && !File.directory?(exe)
39
+ }
40
+ end
41
+ return nil
42
+ end
43
+ # @param [String] editor An editor to use
44
+ # @param [String] file_path Path to file to open
33
45
  # @return [NilClass] nil
34
46
  def Methods.launch_editor(editor, file_path)
35
47
  hl = HighLine.new($stdin, $stderr, 80)
36
48
  if file_path
37
49
  if hl.agree("Would you like to open an editor? ('editor' command) ", true)
38
- pid = spawn("#{} #{file_path}")
50
+ pid = spawn("#{editor} #{file_path}")
39
51
  Process.wait pid
40
52
  end
41
53
  end
@@ -43,6 +43,7 @@ module Mkmatter
43
43
  path = Pathname(folder).realdirpath.join(filename)
44
44
  end
45
45
  File.open(path.to_path, 'a') do |fd|
46
+ answers.to_h = {'layout' => 'page'}
46
47
  fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
47
48
  fd.puts '---'
48
49
  end
@@ -52,6 +53,7 @@ module Mkmatter
52
53
  exit 1
53
54
  end
54
55
  else
56
+ @questions = Mkmatter::Questions::Page.new(HILINE).ask
55
57
  answers = Mkmatter::Answers.new(@questions, options.fetch(:publish, nil))
56
58
  puts ''
57
59
  puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
@@ -96,6 +98,7 @@ module Mkmatter
96
98
  path = Pathname(folder).realdirpath.join(filename)
97
99
  end
98
100
  File.open(path.to_path, 'a') do |fd|
101
+ answers.to_h = {'layout' => 'post'}
99
102
  fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
100
103
  fd.puts '---'
101
104
  end
@@ -133,6 +136,7 @@ module Mkmatter
133
136
  path = Pathname(folder).realdirpath.join(filename)
134
137
  end
135
138
  File.open(path.to_path, 'a') do |fd|
139
+ answers.to_h = {'layout' => 'post'}
136
140
  fd.puts answers.to_h.stringify_keys.to_yaml(indentation: 2)
137
141
  fd.puts '---'
138
142
  end
@@ -1,3 +1,3 @@
1
1
  module Mkmatter
2
- VERSION = '3.0.44'
2
+ VERSION = '3.0.45'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkmatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.44
4
+ version: 3.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Spencer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline