qippet 0.1.2 → 0.1.3
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 +4 -4
- data/bin/console +11 -0
- data/bin/qippet +10 -0
- data/bin/setup +8 -0
- data/lib/qippet/boxes/box.rb +0 -1
- data/lib/qippet/boxes/code_box.rb +2 -2
- data/lib/qippet/builder/xml.rb +3 -4
- data/lib/qippet/builder.rb +1 -8
- data/lib/qippet/config.rb +19 -0
- data/lib/qippet/extract.rb +9 -2
- data/lib/qippet/version.rb +1 -1
- data/lib/qippet.rb +9 -33
- metadata +10 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea5d8882d623e083ef779748038cf06b2d4f01d22698eb0a129892a5aa356c66
|
4
|
+
data.tar.gz: 4341c18fb3736feab842188fd487ace6c35085259de8799a9ccf3163de93c3a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b2b5a7525ee5f1c064eb1aa4e4e001c1c68d16a4f5b1ac19d5e684725f61c6bd8c5b67d261c2b5dad74e6b0bf54657cca55623b194d85051f61457a64a5ff60
|
7
|
+
data.tar.gz: c42e90506d4cebd4674f2e396c9cd75cb7be1a4f01d6079d23b850601b96ae8484d89262aef851a1b71271d1ef2e5820b89580708556a0153414056102969529
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "qippet"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/qippet
ADDED
data/bin/setup
ADDED
data/lib/qippet/boxes/box.rb
CHANGED
@@ -84,7 +84,7 @@ module Qippet
|
|
84
84
|
|
85
85
|
def write_token(token_with_color)
|
86
86
|
color, token_type, token = token_with_color
|
87
|
-
token.prepend("\\") if token_type.shortname.
|
87
|
+
token.prepend("\\") if token_type.shortname.to_s.strip.empty?
|
88
88
|
|
89
89
|
escape_special_characters(token)
|
90
90
|
token_width = writer.get_type_metrics(token).width
|
@@ -126,7 +126,7 @@ module Qippet
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def image_width(*)
|
129
|
-
code_lines.map { |line| line.
|
129
|
+
code_lines.map { |line| line.to_s.strip.empty? ? 0 : writer.get_type_metrics(line).width }.max + (2 * PADDING)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
data/lib/qippet/builder/xml.rb
CHANGED
@@ -9,7 +9,6 @@ module Qippet
|
|
9
9
|
module Builder
|
10
10
|
# Builder from XML content to box
|
11
11
|
module Xml
|
12
|
-
extend ActiveSupport::Autoload
|
13
12
|
extend self
|
14
13
|
|
15
14
|
def build(content = "")
|
@@ -29,16 +28,16 @@ module Qippet
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def setup_node(node)
|
32
|
-
return nil
|
31
|
+
return nil if node.nil?
|
33
32
|
|
34
33
|
node.content.strip!
|
35
|
-
node_box = get_node_box(node
|
34
|
+
node_box = get_node_box(node&.name)
|
36
35
|
add_box_attributes(node_box, node.attribute_nodes)
|
37
36
|
return node_box if node.children.empty?
|
38
37
|
|
39
38
|
node.children.each do |child|
|
40
39
|
box = setup_node(child)
|
41
|
-
node_box.add_child box
|
40
|
+
node_box.add_child box unless box.nil?
|
42
41
|
end
|
43
42
|
|
44
43
|
node_box
|
data/lib/qippet/builder.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require "active_support/core_ext/object/blank"
|
3
|
+
require_relative "./builder/xml"
|
5
4
|
|
6
5
|
# Qippet
|
7
6
|
module Qippet
|
8
|
-
extend ActiveSupport::Autoload
|
9
|
-
|
10
7
|
# Builder Class
|
11
8
|
module Builder
|
12
|
-
extend ActiveSupport::Autoload
|
13
|
-
|
14
|
-
autoload :Xml
|
15
|
-
|
16
9
|
class << self
|
17
10
|
def build(content)
|
18
11
|
Xml.build(content)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Qippet
|
4
|
+
# Configuration module for Qippet
|
5
|
+
module Config
|
6
|
+
# Configuration Instance
|
7
|
+
class Configuration
|
8
|
+
attr_accessor :font_family
|
9
|
+
end
|
10
|
+
|
11
|
+
def config
|
12
|
+
@config ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure
|
16
|
+
yield config if block_given?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/qippet/extract.rb
CHANGED
@@ -13,8 +13,7 @@ module Qippet
|
|
13
13
|
GITHUB_BASE_API_URL = "https://api.github.com/repos/"
|
14
14
|
|
15
15
|
def from_file(path)
|
16
|
-
|
17
|
-
read_file(path)
|
16
|
+
read_file absolute_path(path)
|
18
17
|
end
|
19
18
|
|
20
19
|
def from_github(path = "rails/rails/contents/version.rb")
|
@@ -33,6 +32,14 @@ module Qippet
|
|
33
32
|
rescue Errno::ENOENT, Errno::EISDIR
|
34
33
|
nil
|
35
34
|
end
|
35
|
+
|
36
|
+
def absolute_path(path)
|
37
|
+
path = Pathname.new path
|
38
|
+
|
39
|
+
return path if path.absolute?
|
40
|
+
|
41
|
+
Pathname.getwd / path
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
data/lib/qippet/version.rb
CHANGED
data/lib/qippet.rb
CHANGED
@@ -1,43 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support"
|
4
3
|
require_relative "qippet/version"
|
4
|
+
require_relative "./qippet/builder"
|
5
|
+
require_relative "./qippet/extract"
|
6
|
+
require_relative "./qippet/config"
|
5
7
|
|
6
8
|
# Main object for Qippet. This is the main entry point for
|
7
9
|
# the application.
|
8
10
|
module Qippet
|
9
|
-
extend ActiveSupport::Autoload
|
10
|
-
|
11
|
-
# autoload :Xml, "qippet/extraction/xml"
|
12
|
-
autoload :Extract
|
13
|
-
autoload :Builder
|
14
11
|
class Error < StandardError; end
|
15
|
-
|
16
|
-
# Configuration class Object
|
17
|
-
class Configuration
|
18
|
-
attr_accessor :font_family
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
@font_family = "helvetica"
|
22
|
-
@font_size = 15
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
12
|
+
extend Qippet::Config
|
26
13
|
class << self
|
27
|
-
|
14
|
+
def generate(layout_path = nil, output_path = "output.png")
|
15
|
+
yield config if block_given?
|
28
16
|
|
29
|
-
|
30
|
-
@configuration ||= Configuration.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def configure
|
34
|
-
yield configuration
|
35
|
-
end
|
36
|
-
|
37
|
-
def generate(path, output_file)
|
38
|
-
yield configuration if block_given?
|
39
|
-
|
40
|
-
extracted = Extract.from_file(path)
|
17
|
+
extracted = Extract.from_file(layout_path)
|
41
18
|
node = Builder.build(extracted)
|
42
19
|
|
43
20
|
if node.nil?
|
@@ -46,9 +23,8 @@ module Qippet
|
|
46
23
|
end
|
47
24
|
|
48
25
|
result = node&.render
|
49
|
-
|
50
|
-
|
51
|
-
output_file
|
26
|
+
result.write(output_path)
|
27
|
+
output_path
|
52
28
|
end
|
53
29
|
end
|
54
30
|
end
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qippet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unegbu Kingsley
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '7.1'
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 7.1.3.2
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '7.1'
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 7.1.3.2
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: nokogiri
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +66,8 @@ dependencies:
|
|
86
66
|
version: 4.2.1
|
87
67
|
description: Create beautify code snippet image.
|
88
68
|
email: kingsobino@gmail.com
|
89
|
-
executables:
|
69
|
+
executables:
|
70
|
+
- qippet
|
90
71
|
extensions: []
|
91
72
|
extra_rdoc_files: []
|
92
73
|
files:
|
@@ -97,6 +78,9 @@ files:
|
|
97
78
|
- LICENSE.txt
|
98
79
|
- README.md
|
99
80
|
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/qippet
|
83
|
+
- bin/setup
|
100
84
|
- lib/assets/default.xml
|
101
85
|
- lib/qippet.rb
|
102
86
|
- lib/qippet/boxes/box.rb
|
@@ -106,6 +90,7 @@ files:
|
|
106
90
|
- lib/qippet/builder.rb
|
107
91
|
- lib/qippet/builder/xml.rb
|
108
92
|
- lib/qippet/colors.rb
|
93
|
+
- lib/qippet/config.rb
|
109
94
|
- lib/qippet/extract.rb
|
110
95
|
- lib/qippet/version.rb
|
111
96
|
- sig/qippet.rbs
|
@@ -131,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
116
|
- !ruby/object:Gem::Version
|
132
117
|
version: '0'
|
133
118
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.5.11
|
135
120
|
signing_key:
|
136
121
|
specification_version: 4
|
137
122
|
summary: Code Snippet Imagery.
|