Trk

Easier manipulation for https://trk.tools/ code.

We use https://trk.tools to link various code snippets so we know where is the source of that code.

How to write README

For simple commands we do not need any links, for example

# run in your terminal
mkdir ~/trk

For a single line or for complete file we can use comment

# This code is from: https://trk.tools/app/trk-readme-source-links/-/blob/main/README.md

When a part of the file is extracted from trk.tools we can use Start and End of code from:

# .bashrc
# Start of code from: https://trk.tools/app/trk-readme-source-links#links-for-code-in-readme
...
# End of code from: https://trk.tools/app/trk-readme-source-links#links-for-code-in-readme

For download use wget and raw instead of blob

# wget -P path https://trk.tools/app/trk-readme-source-links/-/raw/main/README.md

Using this gem you can get the string with

trk link-show

For vim you can use mapping

# .vimrc
# Start of code from: https://trk.tools/app/trk-readme-source-links/-/blob/main/README.md
nnoremap <leader>s :r !trk link-show %<CR>
# End of code from: https://trk.tools/app/trk-readme-source-links/-/blob/main/README.md

# local gem
nnoremap <leader>s :r !cd ~/trk.tools/app/trk-readme-source-links && bundle exec exe/trk link-show %:p<CR>
nnoremap <leader>e :r !cd ~/trk.tools/app/trk-readme-source-links && bundle exec exe/trk link-show-end %:p<CR>
nnoremap <leader>r :r !cd ~/trk.tools/app/trk-readme-source-links && bundle exec exe/trk link-show-raw %:p<CR>

For other files we need to link to specific file

# config/initializers/result.rb

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add trk

If bundler is not being used to manage dependencies, install the gem by executing:

gem install trk

Usage

Pull code in all repos under ~/trk.tools/*/*

trk pull

Development

To install this gem onto your local machine, run bundle exec rake install.

Run without installing the gem

bundle exec exe/trk pull

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To put a debugger use

binding.break

Test

To run all tests

rake test

To run single file

ruby -Itest test/test_link.rb

or single test

ruby -Itest test/test_link.rb --name test_link_show_success

Gem push

To release a new version, update the version number, git commit

vi lib/trk/version.rb
bundle

git commit -am"Update"

then deploy with:

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.

Contributing

Build

gem build trk.gemspec

install locally and publish

gem install trk-0.1.0.gem
gem push trk-0.1.0.gem

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/trk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Trk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.