bat-rb 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4722b32d5a6c04135ca9bd60b914d4015f95640976dce387dcafd04428314ecc
4
+ data.tar.gz: 61ea0b201ab38ca3ee3330e0f546b9dbc05235263190ae547e798de616eaec43
5
+ SHA512:
6
+ metadata.gz: f46f69a6979dd8fecc1665235b7d0cf81904fadbea938d7fd19b002661e975a21ba6577081288f2b79c9a089392fceed8c5dbafe4dca62a4515b335d66366994
7
+ data.tar.gz: 1bdda2e0a24e87d0b07058fe499a9764ef38d5b78d5c10239b84ee4d141f379dd56aa66b9744c6f186808b0504ea25fc1388fab76e1fc984a8e24c800e6c7841
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-03-03
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "bat-rb" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["daniel.vinciguerra@bivee.com.br"](mailto:"daniel.vinciguerra@bivee.com.br").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Daniel Vinciguerra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Bat::Rb
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ 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/bat/rb`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
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 the created tag, 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/dvinciguerra/bat-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dvinciguerra/bat-rb/blob/main/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Bat::Rb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dvinciguerra/bat-rb/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
data/exe/bat-rb ADDED
@@ -0,0 +1,54 @@
1
+ # !ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rouge"
5
+ require "optparse"
6
+
7
+ APP_NAME = File.basename($PROGRAM_NAME)
8
+
9
+ @options = { format: nil }
10
+
11
+ optparse = OptionParser.new do |opts|
12
+ opts.banner = "Usage: #{APP_NAME} [options] <filename>"
13
+
14
+ opts.on("-f", "--format FORMAT", "Output format (text, html, etc.)") do |format|
15
+ @options[:format] = format.to_sym
16
+ end
17
+ end
18
+
19
+ optparse.parse!
20
+
21
+ def lexer_by(code, language)
22
+ Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText
23
+ end
24
+
25
+ def render(code, language)
26
+ lexer = lexer_by(code, language)
27
+ formatter = Rouge::Formatters::Terminal256.new
28
+ formatter.format(lexer.lex(code))
29
+ end
30
+
31
+ filename = ARGV[0]
32
+ code = nil
33
+
34
+ # load file from stdin
35
+ code = $stdin.read if filename.nil? && !$stdin.tty?
36
+
37
+ if File.exist?(filename)
38
+ code = File.read(filename)
39
+ else
40
+ puts "File not found: #{filename}"
41
+ exit 1
42
+ end
43
+
44
+ if filename.nil? || code.nil?
45
+ puts "Usage: #{__FILE__} <filename>"
46
+ exit 1
47
+ end
48
+
49
+ if @options[:format].nil?
50
+ ext = File.extname(filename).sub(".", "")
51
+ @options[:format] = ext.empty? ? "text" : ext
52
+ end
53
+
54
+ puts render(code, @options[:format].to_s)
data/lib/bat-rb.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./bat_rb"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BatRB
4
+ VERSION = "0.1.0"
5
+ end
data/lib/bat_rb.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bat_rb/version"
4
+
5
+ module BatRB
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bat-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Vinciguerra
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2026-03-03 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rouge
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ description: A simple ruby version of the popular command-line tool 'bat' for syntax
27
+ highlighting and file previewing.
28
+ email:
29
+ - daniel.vinciguerra@bivee.com.br
30
+ executables:
31
+ - bat-rb
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CHANGELOG.md
36
+ - CODE_OF_CONDUCT.md
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - exe/bat-rb
41
+ - lib/bat-rb.rb
42
+ - lib/bat_rb.rb
43
+ - lib/bat_rb/version.rb
44
+ homepage: https://github.com/dvinciguerra/bat-rb
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/dvinciguerra/bat-rb
49
+ source_code_uri: https://github.com/dvinciguerra/bat-rb
50
+ changelog_uri: https://github.com/dvinciguerra/bat-rb/blob/main/CHANGELOG.md
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 3.0.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.6.2
66
+ specification_version: 4
67
+ summary: A simple ruby version of the popular command-line tool 'bat' for syntax highlighting
68
+ and file previewing.
69
+ test_files: []