prettyprint 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ae9c29bdf4d1698ed37bd984cb88cc2185d3adbcb167ce7041862a0852c4e66
4
- data.tar.gz: e9959e096d793bfea23236de42c3a8fe9f882ba60783af4d3cbde9f3e00cf443
3
+ metadata.gz: 85e19096bea949d9ba4527ab4c725ff93b0cd58607663ddeaf874f594a5ec411
4
+ data.tar.gz: 4fd1396f96864266b0306943b841f9f5725928fb53438851cd45d595136e402e
5
5
  SHA512:
6
- metadata.gz: 2f926e5ae6da0608c6ca997b7c3209da719eb33acd70cf636e491d1e51e4d1a23c80324cbfaf52d3eb4af2a921eb9ee4b1996ba37e1799639900045589c3fa77
7
- data.tar.gz: 64ef90afb2f0f900e56f805c3e4ae1e54b1e1d9dfdf32190ad9db5bf1e5aa527f5ff45a42b1e165f449c79d6145f74257c53d5026d52cad4dd2a5804d06c0849
6
+ metadata.gz: 01f0fdabe285415df33bc492afb51bd76cea47da6e8d90625cb78138f80a2f8a34cd3c5a0e05b69533d90afd6ebea87227b7d68a9b41a8b691cae0ba12223c7a
7
+ data.tar.gz: bbc550544885800b388fdb8429e826c8a87b9a22d0fad8a965ab1c86e8c53e4847b83e1802689e7906b35878bf141d4ecd04fb44913620a825279918f4ece1b3
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -1,24 +1,41 @@
1
1
  name: test
2
2
 
3
- on: [push, pull_request]
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ - cron: '15 3 * * *'
4
8
 
5
9
  jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
10
+ ruby-versions:
11
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
+ with:
13
+ engine: cruby
14
+ min_version: 2.5
15
+
16
+ test:
17
+ needs: ruby-versions
8
18
  strategy:
9
19
  matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
11
- os: [ ubuntu-latest, macos-latest ]
20
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
21
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
22
+ exclude:
23
+ - { os: windows-latest , ruby: head }
24
+ include:
25
+ - { os: windows-latest , ruby: mingw }
26
+ - { os: windows-latest , ruby: mswin }
12
27
  runs-on: ${{ matrix.os }}
13
28
  steps:
14
- - uses: actions/checkout@master
29
+ - uses: actions/checkout@v4
15
30
  - name: Set up Ruby
16
31
  uses: ruby/setup-ruby@v1
17
32
  with:
18
33
  ruby-version: ${{ matrix.ruby }}
19
34
  - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
35
+ run: bundle install
36
+ - name: Build
37
+ run: rake build
23
38
  - name: Run test
24
39
  run: rake test
40
+ - name: Installation test
41
+ run: gem install pkg/*.gem
data/README.md CHANGED
@@ -1,8 +1,20 @@
1
- # Prettyprint
1
+ # PrettyPrint
2
2
 
3
- 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/prettyprint`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This class implements a pretty printing algorithm. It finds line breaks and
4
+ nice indentations for grouped structure.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ By default, the class assumes that primitive elements are strings and each
7
+ byte in the strings have single column in width. But it can be used for
8
+ other situations by giving suitable arguments for some methods:
9
+
10
+ * newline object and space generation block for PrettyPrint.new
11
+ * optional width argument for PrettyPrint#text
12
+ * PrettyPrint#breakable
13
+
14
+ There are several candidate uses:
15
+
16
+ * text formatting using proportional fonts
17
+ * multibyte characters which has columns different to number of bytes
6
18
 
7
19
  ## Installation
8
20
 
@@ -20,10 +32,6 @@ Or install it yourself as:
20
32
 
21
33
  $ gem install prettyprint
22
34
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
35
  ## Development
28
36
 
29
37
  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.
@@ -32,5 +40,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
40
 
33
41
  ## Contributing
34
42
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/prettyprint.
36
-
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/prettyprint.
data/lib/prettyprint.rb CHANGED
@@ -23,16 +23,18 @@
23
23
  #
24
24
  # == References
25
25
  # Christian Lindig, Strictly Pretty, March 2000,
26
- # http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
26
+ # https://lindig.github.io/papers/strictly-pretty-2000.pdf
27
27
  #
28
28
  # Philip Wadler, A prettier printer, March 1998,
29
- # http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
29
+ # https://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
30
30
  #
31
31
  # == Author
32
32
  # Tanaka Akira <akr@fsij.org>
33
33
  #
34
34
  class PrettyPrint
35
35
 
36
+ VERSION = "0.2.0"
37
+
36
38
  # This is a convenience method which is same as follows:
37
39
  #
38
40
  # begin
@@ -102,7 +104,7 @@ class PrettyPrint
102
104
 
103
105
  # The maximum width of a line, before it is separated in to a newline
104
106
  #
105
- # This defaults to 79, and should be a Fixnum
107
+ # This defaults to 79, and should be an Integer
106
108
  attr_reader :maxwidth
107
109
 
108
110
  # The value that is appended to +output+ to add a new line.
@@ -110,7 +112,7 @@ class PrettyPrint
110
112
  # This defaults to "\n", and should be String
111
113
  attr_reader :newline
112
114
 
113
- # A lambda or Proc, that takes one argument, of a Fixnum, and returns
115
+ # A lambda or Proc, that takes one argument, of an Integer, and returns
114
116
  # the corresponding number of spaces.
115
117
  #
116
118
  # By default this is:
@@ -340,7 +342,7 @@ class PrettyPrint
340
342
  #
341
343
  # Arguments:
342
344
  # * +sep+ String of the separator
343
- # * +width+ Fixnum width of the +sep+
345
+ # * +width+ Integer width of the +sep+
344
346
  # * +q+ parent PrettyPrint object, to base from
345
347
  def initialize(sep, width, q)
346
348
  @obj = sep
data/prettyprint.gemspec CHANGED
@@ -1,6 +1,13 @@
1
+ name = File.basename(__FILE__, ".gemspec")
2
+ version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
3
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
4
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
5
+ end rescue nil
6
+ end
7
+
1
8
  Gem::Specification.new do |spec|
2
- spec.name = "prettyprint"
3
- spec.version = "0.1.0"
9
+ spec.name = name
10
+ spec.version = version
4
11
  spec.authors = ["Tanaka Akira"]
5
12
  spec.email = ["akr@fsij.org"]
6
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prettyprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Implements a pretty printing algorithm for readable structure.
14
14
  email:
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/dependabot.yml"
20
21
  - ".github/workflows/test.yml"
21
22
  - ".gitignore"
22
23
  - Gemfile
@@ -49,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  - !ruby/object:Gem::Version
50
51
  version: '0'
51
52
  requirements: []
52
- rubygems_version: 3.2.0.rc.1
53
+ rubygems_version: 3.5.0.dev
53
54
  signing_key:
54
55
  specification_version: 4
55
56
  summary: Implements a pretty printing algorithm for readable structure.