textbringer-json 0.1.1

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: 5cfb6c01f320342fe715015a377db585a51e2ac1daeab54ebacce44d5eb899f6
4
+ data.tar.gz: d45868c552229342ca4b2966fa9d7abbb8f6e1df7884f355332d49a8ca86068c
5
+ SHA512:
6
+ metadata.gz: 63be4dc7c7d172a121c6eeefe2c650b04eff72f4a9d41070228b3bc764905c4d9b5f00af2cd1fc374d99697b28396fb36992a27d22a1a5b665c1f0549dc7bd2c
7
+ data.tar.gz: 4b1aa2cd19bd1453a70669ef017bc53ed98e144be65203cb79e5691a80d0d636fd0a4e3e53caefd6e634e8b4de970c772bccd65c1edd1beae72ffb30e7c335f1
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2026 Shinta Koyanagi <yancya@upec.jp>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Textbringer Json
2
+
3
+ A Textbringer plugin that provides json mode support.
4
+
5
+ ## Installation
6
+
7
+ Install the gem by executing:
8
+
9
+ ```bash
10
+ gem install textbringer-json
11
+ ```
12
+
13
+ Or add it to your Gemfile:
14
+
15
+ ```bash
16
+ bundle add textbringer-json
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ The plugin is automatically loaded when you start Textbringer. Simply open any `.json` file and the mode will be applied automatically.
22
+
23
+ No additional configuration is required.
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`.
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ShintaKoyanagi/textbringer-json.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [WTFPL](http://www.wtfpl.net/).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Textbringer
4
+ module Json
5
+ VERSION = "0.1.1"
6
+ end
7
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "json/version"
4
+
5
+ module Textbringer
6
+ # Define faces for syntax elements
7
+ Face.define :json_keyword, foreground: "cyan", bold: true
8
+ Face.define :json_string, foreground: "green"
9
+ Face.define :json_key, foreground: "yellow", bold: true
10
+ Face.define :json_number, foreground: "magenta"
11
+ Face.define :json_structure, foreground: "white"
12
+
13
+ class JsonMode < Mode
14
+ self.file_name_pattern = /\.json\z/i
15
+
16
+ # Keywords: true, false, null
17
+ define_syntax :json_keyword, /\b(?:true|false|null)\b/
18
+
19
+ # Numbers: integers, floats, exponential notation
20
+ define_syntax :json_number, /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/
21
+
22
+ # Object keys: strings followed by colon (higher priority than string values)
23
+ define_syntax :json_key, /"(?:[^"\\]|\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}))*"\s*:/
24
+
25
+ # String values: regular strings
26
+ define_syntax :json_string, /"(?:[^"\\]|\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}))*"/
27
+
28
+ # Structure characters: {}[],:
29
+ define_syntax :json_structure, /[{}\[\]:,]/
30
+
31
+ def initialize(buffer)
32
+ super(buffer)
33
+ @buffer[:indent_tabs_mode] = false
34
+ @buffer[:tab_width] = 2
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "textbringer/json"
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
5
+ # Mock Textbringer for testing without the actual dependency
6
+ module Textbringer
7
+ class Face
8
+ def self.define(name, **options)
9
+ # Mock Face.define
10
+ end
11
+ end
12
+
13
+ class Mode
14
+ attr_reader :buffer
15
+
16
+ def initialize(buffer)
17
+ @buffer = buffer
18
+ end
19
+
20
+ def self.define_syntax(face, pattern)
21
+ # Mock define_syntax
22
+ end
23
+
24
+ def self.file_name_pattern
25
+ @file_name_pattern
26
+ end
27
+
28
+ def self.file_name_pattern=(pattern)
29
+ @file_name_pattern = pattern
30
+ end
31
+ end
32
+ end
33
+
34
+ require "textbringer/json"
35
+
36
+ require "test/unit"
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class Textbringer::JsonTest < Test::Unit::TestCase
6
+ test "VERSION is defined" do
7
+ assert do
8
+ ::Textbringer::Json.const_defined?(:VERSION)
9
+ end
10
+ end
11
+
12
+ test "JsonMode class exists" do
13
+ assert do
14
+ defined?(Textbringer::JsonMode)
15
+ end
16
+ end
17
+
18
+ test "JsonMode file pattern matches .json files" do
19
+ assert do
20
+ Textbringer::JsonMode.file_name_pattern =~ "test.json"
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: textbringer-json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Shinta Koyanagi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: textbringer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: A Textbringer plugin that provides json mode support with syntax highlighting.
28
+ email:
29
+ - yancya@upec.jp
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ - Rakefile
37
+ - lib/textbringer/json.rb
38
+ - lib/textbringer/json/version.rb
39
+ - lib/textbringer_plugin.rb
40
+ - test/test_helper.rb
41
+ - test/textbringer_json_test.rb
42
+ homepage: https://github.com/ShintaKoyanagi/textbringer-json
43
+ licenses:
44
+ - WTFPL
45
+ metadata:
46
+ allowed_push_host: https://rubygems.org
47
+ homepage_uri: https://github.com/ShintaKoyanagi/textbringer-json
48
+ source_code_uri: https://github.com/ShintaKoyanagi/textbringer-json
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.2.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.4.19
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Json mode for Textbringer
68
+ test_files: []