apender 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: 66fb5c0b4aedbedb0583f4881782380314309c7bb4942d53aead05ff0daa5eb6
4
+ data.tar.gz: ff1ff8c3918edec89cbfdf79a9ce40222268d26d3f7882682d10632f017cdc29
5
+ SHA512:
6
+ metadata.gz: fb3743f39a42d79e6db87b16da9b73558ca705a74815037bbefa89de6564046e2a6fb4aadbac98d504d6c93f8b620d7e481c356669c49fff78c15af895e5bf1b
7
+ data.tar.gz: 67c4baff60dfb0a5693183a145173dfacf4f0aeb0e9221f8fee333d075211358b3a7856f5051ff6d9bf808adadaf7d190c3544e4c2a6d1697731b05f3b7aeada
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-11-01
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "apender" 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 ["TODO: Write your email address"](mailto:"TODO: Write your email address").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 TODO: Write your name
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
+ # Apender
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/apender`. 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/[USERNAME]/apender. 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/[USERNAME]/apender/blob/master/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 Apender project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/apender/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ task default: :test
data/exe/append ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "apender"
5
+ require "optparse"
6
+
7
+ options = {}
8
+
9
+ parser = OptionParser.new do |opts|
10
+ opts.banner = "Usage: append -p PATH (-c CONTENT | -n)"
11
+
12
+ opts.on("-p PATH", "--path PATH", "File path") do |path|
13
+ options[:path] = path
14
+ end
15
+
16
+ opts.on("-c CONTENT", "--content CONTENT", "Content to append") do |content|
17
+ options[:content] = content
18
+ end
19
+
20
+ opts.on("-n", "--null", "Append an empty line") do
21
+ options[:null] = true
22
+ end
23
+ end
24
+
25
+ begin
26
+ parser.parse!
27
+
28
+ raise OptionParser::MissingArgument, "-p PATH" unless options[:path]
29
+
30
+ if options.key?(:content) == !!options[:null]
31
+ raise OptionParser::InvalidArgument,
32
+ "Use either -c CONTENT or -n, not both"
33
+ end
34
+
35
+ if options[:null]
36
+ Apender.newline(options[:path])
37
+ else
38
+ Apender.append(options[:path], options[:content])
39
+ end
40
+
41
+ rescue OptionParser::ParseError, Apender::Error => e
42
+ warn "append: #{e.message}"
43
+ exit 1
44
+ end
45
+
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apender
4
+ VERSION = "0.1.0"
5
+ end
data/lib/apender.rb ADDED
@@ -0,0 +1,30 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "apender/version"
5
+
6
+ module Apender
7
+ class Error < StandardError; end
8
+
9
+ def self.append(path, content)
10
+ raise Error, "File does not exist: #{path}" unless File.file?(path)
11
+
12
+ File.open(path, "a") do |file|
13
+ unless File.zero?(path)
14
+ last_byte = File.binread(path, 1, File.size(path) - 1)
15
+ file.write("\n") unless last_byte == "\n"
16
+ end
17
+
18
+ file.puts(content)
19
+ end
20
+ end
21
+
22
+ def self.newline(path)
23
+ raise Error, "File does not exist: #{path}" unless File.file?(path)
24
+
25
+ File.open(path, "a") do |file|
26
+ file.puts
27
+ end
28
+ end
29
+ end
30
+
data/sig/apender.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Apender
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apender
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nicolau
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ email:
13
+ - nic13araujo@proton.me
14
+ executables:
15
+ - append
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - CHANGELOG.md
20
+ - CODE_OF_CONDUCT.md
21
+ - LICENSE.txt
22
+ - README.md
23
+ - Rakefile
24
+ - exe/append
25
+ - lib/apender.rb
26
+ - lib/apender/version.rb
27
+ - sig/apender.rbs
28
+ homepage: https://github.com
29
+ licenses:
30
+ - MIT
31
+ metadata:
32
+ homepage_uri: https://github.com
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.6.9
48
+ specification_version: 4
49
+ summary: Add content on the next line of a file
50
+ test_files: []