Skip to content

Commit 2913836

Browse files
committed
Initial commit
0 parents  commit 2913836

File tree

16 files changed

+450
-0
lines changed

16 files changed

+450
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "bundler"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Main
2+
on:
3+
- push
4+
- pull_request_target
5+
jobs:
6+
ci:
7+
name: CI
8+
runs-on: ubuntu-latest
9+
env:
10+
CI: true
11+
steps:
12+
- uses: actions/checkout@master
13+
- uses: ruby/setup-ruby@v1
14+
with:
15+
bundler-cache: true
16+
ruby-version: '3.1'
17+
- name: Test
18+
run: bundle exec rake test
19+
automerge:
20+
name: AutoMerge
21+
needs: ci
22+
runs-on: ubuntu-latest
23+
if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
24+
steps:
25+
- uses: actions/github-script@v3
26+
with:
27+
script: |
28+
github.pulls.merge({
29+
owner: context.payload.repository.owner.login,
30+
repo: context.payload.repository.name,
31+
pull_number: context.payload.pull_request.number
32+
})

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
10+
test.json

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [0.1.0] - 2022-03-31
10+
11+
### Added
12+
13+
- 🎉 Initial release! 🎉
14+
15+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-json/compare/v0.1.0...HEAD
16+
[0.1.0]: https://github.com/ruby-syntax-tree/syntax_tree-json/compare/c52ff8...v0.1.0

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gemspec

Gemfile.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
PATH
2+
remote: .
3+
specs:
4+
syntax_tree-json (0.1.0)
5+
json
6+
syntax_tree (>= 2.0.1)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
docile (1.4.0)
12+
json (2.6.1)
13+
minitest (5.15.0)
14+
rake (13.0.6)
15+
simplecov (0.21.2)
16+
docile (~> 1.1)
17+
simplecov-html (~> 0.11)
18+
simplecov_json_formatter (~> 0.1)
19+
simplecov-html (0.12.3)
20+
simplecov_json_formatter (0.1.4)
21+
syntax_tree (2.0.1)
22+
23+
PLATFORMS
24+
x86_64-darwin-21
25+
26+
DEPENDENCIES
27+
bundler
28+
minitest
29+
rake
30+
simplecov
31+
syntax_tree-json!
32+
33+
BUNDLED WITH
34+
2.3.6

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022-present Kevin Newton
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.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SyntaxTree::JSON
2+
3+
[![Build Status](https://github.com/ruby-syntax-tree/syntax_tree-json/actions/workflows/main.yml/badge.svg)](https://github.com/ruby-syntax-tree/syntax_tree-json/actions/workflows/main.yml)
4+
[![Gem Version](https://img.shields.io/gem/v/syntax_tree-json.svg)](https://rubygems.org/gems/syntax_tree-json)
5+
6+
[Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) support for JSON.
7+
8+
## Installation
9+
10+
Add this line to your application's Gemfile:
11+
12+
```ruby
13+
gem "syntax_tree-json"
14+
```
15+
16+
And then execute:
17+
18+
$ bundle install
19+
20+
Or install it yourself as:
21+
22+
$ gem install syntax_tree-json
23+
24+
## Usage
25+
26+
From code:
27+
28+
```ruby
29+
require "syntax_tree/json"
30+
31+
pp SyntaxTree::JSON.parse(source) # print out the AST
32+
puts SyntaxTree::JSON.format(source) # format the AST
33+
```
34+
35+
From the CLI:
36+
37+
```sh
38+
$ stree ast --plugins=json file.json
39+
(root children=[(tag name="span" value="Hello, world!")])
40+
```
41+
42+
or
43+
44+
```sh
45+
$ stree format --plugins=json file.json
46+
%span Hello, world!
47+
```
48+
49+
or
50+
51+
```sh
52+
$ stree write --plugins=json file.json
53+
file.json 1ms
54+
```
55+
56+
## Development
57+
58+
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.
59+
60+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
61+
62+
## Contributing
63+
64+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-syntax-tree/syntax_tree-json.
65+
66+
## License
67+
68+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Rakefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

bin/console

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "syntax_tree/json"
6+
7+
require "irb"
8+
IRB.start(__FILE__)

0 commit comments

Comments
 (0)