tty-box 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 385f1356929f59e50fd7818fa826c6276a1a110862d05273a549879683301874
4
- data.tar.gz: 308a4a0d28e4933f0856990a5ba072822568bfe9c63b52879ba0147bdae95546
3
+ metadata.gz: a9daceddbaca9658a170dde1ce447aebc05af9972015cc71aa003de5e120b2c8
4
+ data.tar.gz: d9ba3ea634b244a7b6044d1060a1cb38a2164646a6ff7bc9c716000bd49e78cd
5
5
  SHA512:
6
- metadata.gz: 32d66ca08caafc132eee52d584da928861493361cbefc0a1376513bfff138f9993061c10374e88da3ba8ce5f44799024af46c5a00cb7f731111095f00fc9fa31
7
- data.tar.gz: 9a705f75359808f18022b2f0fde41dfd4ee1c0fc989d23b20ad229105037a0103da39fee329d516470f7a15df1952f7a639ce27a741ed6ba2537dbcac7798a39
6
+ metadata.gz: b7d43320b77c1edb2164684e90f5a2431e58f48f31838170b20b16349f2d0074c4274fe92348457546bafd2ad29874ca5b889c9c7a40c7271721fa599a0ae2cf
7
+ data.tar.gz: 422d8dc8a0b7eaa183e2f7db40a3e2c0d89dae5bdfde98181919109bdc86555de82a957f3855fe73338f285d40df118fdf82a2622a87831dc50899ad3e9fcea2
@@ -1,7 +1,14 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.2.0] - 2018-07-31
4
+
5
+ ### Changed
6
+ * Change to stop positioning box without `:top` & `:left` coordinates
7
+ * Change to load manually required files in gemspec without using git
8
+
3
9
  ## [v0.1.0] - 2018-07-23
4
10
 
5
11
  * Initial implementation and release
6
12
 
13
+ [v0.2.0]: https://github.com/piotrmurach/tty-box/compare/v0.1.0...v0.2.0
7
14
  [v0.1.0]: https://github.com/piotrmurach/tty-box/compare/v0.1.0
data/README.md CHANGED
@@ -136,12 +136,14 @@ print box
136
136
 
137
137
  ### 2.2 position
138
138
 
139
- By default, a box will be positioned in the top left corner of the terminal emulator. Use `:top` and `:left` keyword arguments to change this:
139
+ By default, a box will not be positioned. To position your box absolutely within a terminal window use `:top` and `:left` keyword arguments:
140
140
 
141
141
  ```ruby
142
142
  TTY::Box.frame(top: 5, left: 10)
143
143
  ```
144
144
 
145
+ This will place box 10 columns to the right and 5 lines down counting from the top left corner.
146
+
145
147
  If you wish to center your box within the terminal window then consider using [tty-screen](https://github.com/piotrmurach/tty-screen) for gathering terminal screen size information.
146
148
 
147
149
  ### 2.3 dimension
@@ -152,6 +154,14 @@ At the very minimum a box requires to be given size by using two keyword argumen
152
154
  TTY::Box.frame(width: 30, height: 10)
153
155
  ```
154
156
 
157
+ If you wish to create a box that depends on the terminal window size then consider using [tty-screen](https://github.com/piotrmurach/tty-screen) for gathering terminal screen size information.
158
+
159
+ For example to print a box that spans the whole terminal window do:
160
+
161
+ ```ruby
162
+ TTY::Box.frame(width: TTY::Screen.width, height: TTY::Screen.height)
163
+ ```
164
+
155
165
  ### 2.4 title
156
166
 
157
167
  You can specify titles using the `:title` keyword and a hash value that contains one of the `:top_left`, `:top_center`, `:top_right`, `:bottom_left`, `:bottom_center`, `:bottom_right` keys and actual title as value. For example, to add titles to top left and bottom right of the frame do:
@@ -71,10 +71,11 @@ module TTY
71
71
  # Create a frame
72
72
  #
73
73
  # @api public
74
- def frame(top: 0, left: 0, width: 35, height: 3, align: :left, padding: 0,
74
+ def frame(top: nil, left: nil, width: 35, height: 3, align: :left, padding: 0,
75
75
  title: {}, border: :light, style: {})
76
76
  output = []
77
77
  content = []
78
+ position = top && left
78
79
 
79
80
  border = Border.parse(border)
80
81
 
@@ -86,16 +87,17 @@ module TTY
86
87
  border_fg, border_bg = *extract_style(style[:border] || {})
87
88
 
88
89
  if border.top?
89
- output << cursor.move_to(left, top)
90
+ output << cursor.move_to(left, top) if position
90
91
  output << top_border(title, width, border.type, style)
92
+ output << "\n" unless position
91
93
  end
92
94
  (height - 2).times do |i|
93
95
  if border.left?
94
- output << cursor.move_to(left, top + i + 1)
96
+ output << cursor.move_to(left, top + i + 1) if position
95
97
  output << border_bg.(border_fg.(pipe_char(border.type)))
96
98
  end
97
- if content[i].nil?
98
- output << bg.(fg.(' ' * (width - 2))) if style[:fg] || style[:bg]
99
+ if content[i].nil? && (style[:fg] || style[:bg] || !position)
100
+ output << bg.(fg.(' ' * (width - 2)))
99
101
  else
100
102
  output << bg.(fg.(content[i]))
101
103
  if style[:fg] || style[:bg]
@@ -103,13 +105,15 @@ module TTY
103
105
  end
104
106
  end
105
107
  if border.right?
106
- output << cursor.move_to(left + width - 1, top + i + 1)
108
+ output << cursor.move_to(left + width - 1, top + i + 1) if position
107
109
  output << border_bg.(border_fg.(pipe_char(border.type)))
108
110
  end
111
+ output << "\n" unless position
109
112
  end
110
113
  if border.bottom?
111
- output << cursor.move_to(left, top + height - 1)
114
+ output << cursor.move_to(left, top + height - 1) if position
112
115
  output << bottom_border(title, width, border.type, style)
116
+ output << "\n" unless position
113
117
  end
114
118
 
115
119
  output.join
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Box
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end # Box
7
7
  end # TTY
@@ -13,9 +13,11 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://piotrmurach.github.io/tty"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- end
16
+ spec.files = Dir.glob('lib/**/*.rb') + Dir.glob('bin/*')
17
+ spec.files += Dir.glob('examples/*.rb') + Dir.glob('tasks/*.rake')
18
+ spec.files += Dir.glob('[A-Z]*') + Dir.glob('[a-z]*\.*')
19
+ spec.files.reject! { |f| f.match(%r{.lock$}) }
20
+
19
21
  spec.bindir = "exe"
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-box
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
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
@@ -101,9 +101,6 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
- - ".rspec"
106
- - ".travis.yml"
107
104
  - CHANGELOG.md
108
105
  - CODE_OF_CONDUCT.md
109
106
  - Gemfile
@@ -111,7 +108,6 @@ files:
111
108
  - README.md
112
109
  - Rakefile
113
110
  - appveyor.yml
114
- - assets/tty-box-drawing.png
115
111
  - bin/console
116
112
  - bin/setup
117
113
  - examples/commander.rb
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /Gemfile.lock
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --warnings
@@ -1,26 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- before_install: "gem update bundler"
6
- script: "bundle exec rake ci"
7
- rvm:
8
- - 2.0.0
9
- - 2.1.10
10
- - 2.2.9
11
- - 2.3.6
12
- - 2.4.4
13
- - 2.5.1
14
- - ruby-head
15
- - jruby-9.1.5.0
16
- - jruby-head
17
- matrix:
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-9.1.5.0
21
- - rvm: jruby-head
22
- fast_finish: true
23
- branches:
24
- only: master
25
- notifications:
26
- email: false
Binary file