zxc 0.1.0 → 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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -14
  3. data/bin/zxc +29 -0
  4. data/lib/zxc/version.rb +1 -1
  5. metadata +7 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8a6facbb820de32db32cb8a5c71221e959deffcc78ce3583be2fd45dfd01bbe
4
- data.tar.gz: 8332a68e6627a9bba769116b4e0b4a52f47f1f24a7afb33e552032536a21b2f6
3
+ metadata.gz: f773e74ecf369e69253cdf0d61a98d05c88eea29dfe0e143830795ce687bae31
4
+ data.tar.gz: d273a757deb2e8a15cf8c2a1c8bca8a78b4d625d0ece31fb36466be0b92d943e
5
5
  SHA512:
6
- metadata.gz: 88bb3a737aff502363e517723d1b74b957dfaa81fb94ac0eafcbb92bf8962d3225aab4819c166fb7de9f6dcce02e9a2657900af6e00ebc08c72d030afdef9d88
7
- data.tar.gz: 1529d74ab9d6cc8b5896336dc5d514ad8aa2217ef41289cc4f76df0e6cfc2a29aed8a030e20fd065e1264d75f2d310bf2a4d29872ea5fef98808ac49de627203
6
+ metadata.gz: 0c760b9ecc6652389fdb27643bee1664e7668124d8934546ed63bf2744dc2555906737f0ac6f5afc748284a72a1ba62055a8ebe338bc9b5d4df9a295eda60f87
7
+ data.tar.gz: 9c99fc06e8404f667b0eda2bac11306a33826b976cc5e04aa0dc48f79574822af4d5171957d82360838d254e1311bb10682721975ed8a155e84eb4458dd00059
data/README.md CHANGED
@@ -1,38 +1,48 @@
1
1
  # Zxc
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ **zxc** allows you to quickly perform a few common opperations on STDIN, for example:
4
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/zxc`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ```bash
6
+ echo $PATH | zxc split : split / present print
7
+ ```
6
8
 
7
- ## Installation
9
+ The command chain above will
10
+ 1. get the list of directories in your `$PATH`,
11
+ 2. split it into a list, using ":" as a delimiter,
12
+ 3. split each element of said list into a sublist, using "/" as a delimiter,
13
+ 4. remove empty elements,
14
+ 5. print every element of every sublist.
15
+
16
+ This works by generating a tree, where each node contains text, and exposing "steps" to the user, which are procedures over said tree, In the example above, "split", "present" and "print" are steps, the first one taking arguments.
17
+
18
+ Use `zxc -H` to read a manual listing available steps.
8
19
 
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.
20
+ ## Installation
10
21
 
11
22
  Install the gem and add to the application's Gemfile by executing:
12
23
 
13
24
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
25
+ bundle add zxc
15
26
  ```
16
27
 
17
28
  If bundler is not being used to manage dependencies, install the gem by executing:
18
29
 
19
30
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
31
+ gem install zxc
21
32
  ```
22
33
 
23
34
  ## Usage
24
35
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
36
+ ```bash
37
+ zxc [OPTIONS] [STEP [ARG]...]...
38
+ ```
30
39
 
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).
40
+ **zxc** reads text from STDIN, converts it into the root node of a tree, and applies operations (steps) onto said tree.
32
41
 
33
- ## Contributing
42
+ ### Options
34
43
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/zxc.
44
+ - **-h , --help**: Displays a short help message and exits
45
+ - **-H ", --Help**: Displays this page and exits
36
46
 
37
47
  ## License
38
48
 
data/bin/zxc ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative "../lib/zxc"
6
+
7
+ MAN_PAGE = File.join(__dir__,'..','man','zxc.1')
8
+
9
+ if %w[-h --help].include? ARGV[0]
10
+ puts <<~EOT.chomp
11
+ usage: zxc [options] [step [arg...]...]
12
+ \t-h,\t--help\t\tShow this help message
13
+ \t-H,\t--Help\t\tDisplay detailed help page
14
+ EOT
15
+ exit
16
+ elsif %w[-H --Help].include? ARGV[0]
17
+ system("man", MAN_PAGE)
18
+ exit
19
+ end
20
+
21
+ begin
22
+ Zxc::Zxc.new.run
23
+ rescue Zxc::UnknownStepError => e
24
+ STDERR.puts "Unknown step '#{e.meta[:step]}'."
25
+ rescue Zxc::WrongArgumentNumberError => e
26
+ STDERR.puts "At step '#{e.meta[:step]}': " \
27
+ "expected #{e.meta[:expected]} argument(s), " \
28
+ "but got #{e.meta[:actual]}."
29
+ end
data/lib/zxc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zxc
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,41 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tiago-macedo
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- `zxc` allows you to quickly perform a few common opperations on STDIN, for example:
15
- ```
16
- $ echo $PATH | zxc split : split / present print
17
- ```
18
- The command chain above will
19
- 1. get the list of directories in your `$PATH`,
20
- 2. split it into a list, using ":" as a delimiter,
21
- 3. split each element of said list into a sublist, using "/" as a delimiter,
22
- 4. remove empty elements,
23
- 5. print every element of every sublist.
24
-
25
- This works by generating a tree, where each node contains text, and exposing
26
- "steps" to the user, which are procedures over said tree, In the example above,
27
- "split", "present" and "print" are steps, the first one taking arguments.
28
-
29
- Use `zxc -H` to read a manual listing available steps.
13
+ description: "`zxc` is a command line program that takes in text, turns it into a
14
+ tree, and exposes procedures to manipulate this tree."
30
15
  email:
31
16
  - tiagomacedo@ufrj.br
32
- executables: []
17
+ executables:
18
+ - zxc
33
19
  extensions: []
34
20
  extra_rdoc_files: []
35
21
  files:
36
22
  - LICENSE.txt
37
23
  - README.md
38
24
  - Rakefile
25
+ - bin/zxc
39
26
  - lib/zxc.rb
40
27
  - lib/zxc/error.rb
41
28
  - lib/zxc/errors/unknown_step_error.rb