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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea39e52122a1076ad5e3d977597333ab3ea3796d5e21bdc0fa16f6ce49e72225
4
- data.tar.gz: 01c45b5f6499d56e23cee766725d454e745b2e5d20b4b76ee3762380fc5acbb9
3
+ metadata.gz: ea5d8882d623e083ef779748038cf06b2d4f01d22698eb0a129892a5aa356c66
4
+ data.tar.gz: 4341c18fb3736feab842188fd487ace6c35085259de8799a9ccf3163de93c3a4
5
5
  SHA512:
6
- metadata.gz: 1d0996916149d69c9e8d995b209501f779668cf079e1962d8807336ae1fce1b4b8b6e38f6f7993ef292affa254c73aecc2178709ef1aa045e5873ea8baa4a983
7
- data.tar.gz: cdaa36d820892412ebf4774a3ea6039bb1cb6f41991c40d493b095746bb14613ada3f52fd57228868c0821671c644a30c6931e5e4e836ff981ff7de2a30b848c
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
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "qippet"
5
+
6
+ layout_name = ARGV[0]
7
+
8
+ output_name = ARGV[1] || "output.png"
9
+
10
+ Qippet.generate layout_name, output_name
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
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rmagick"
4
- require "active_support/core_ext/enumerable"
5
4
 
6
5
  module Qippet
7
6
  module Boxes
@@ -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.blank?
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.blank? ? 0 : writer.get_type_metrics(line).width }.max + (2 * PADDING)
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
@@ -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 unless node.presence
31
+ return nil if node.nil?
33
32
 
34
33
  node.content.strip!
35
- node_box = get_node_box(node.name.presence)
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 if box.present?
40
+ node_box.add_child box unless box.nil?
42
41
  end
43
42
 
44
43
  node_box
@@ -1,18 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support"
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
@@ -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
- path = Pathname.new(Dir.pwd).join(path)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Qippet
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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
- @configuration = nil
14
+ def generate(layout_path = nil, output_path = "output.png")
15
+ yield config if block_given?
28
16
 
29
- def configuration
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
- result.write(output_file)
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unegbu Kingsley
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-21 00:00:00.000000000 Z
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.3.26
119
+ rubygems_version: 3.5.11
135
120
  signing_key:
136
121
  specification_version: 4
137
122
  summary: Code Snippet Imagery.