counter_string 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 +4 -4
- data/README.md +10 -1
- data/bin/counter_string +2 -0
- data/lib/counter_string.rb +1 -0
- data/lib/counter_string_cli.rb +21 -0
- data/lib/version.rb +1 -1
- data/spec/counter_string_cli_spec.rb +25 -0
- data/spec/counter_string_spec.rb +4 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 936337d1818014ef9f8a35a73ff423b9ee2c9d92
|
4
|
+
data.tar.gz: 4a60ac2e507f86dd844a8d19fbb066a8632c2946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c5ed0cd6064aec05f102481e4913fba14cda5227628dbf444ff1d772ffd9b69aa80d2b7cfe3e1838bb57195046a536b8d31e0b199c72a0988434094bae73a6b
|
7
|
+
data.tar.gz: 46237d4c7477f3e0ec595b6e406858b8f64913a79907355b6b1b1931707384a15cef8920682851126c22662c8fce30af0e660e2a3acc5f72c84b5becd9ba0fa7
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ James Bach, [describes counter strings](http://www.satisfice.com/blog/archives/2
|
|
4
4
|
|
5
5
|
"A counterstring is a graduated string of arbitrary length. No matter where you are in the string, you always know the character position. This comes in handy when you are pasting huge strings into fields and they get truncated at a certain point. You want to know how many characters that is."
|
6
6
|
|
7
|
-
Here's a simple example of its use:
|
7
|
+
Here's a simple example of its use as a library:
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
require 'rubygems'
|
@@ -16,3 +16,12 @@ p cs.generate 35
|
|
16
16
|
|
17
17
|
=> "2*4*6*8*11*14*17*20*23*26*29*32*35*"
|
18
18
|
```
|
19
|
+
|
20
|
+
It's easy to generate counter strings from the command line, too (thanks [@hogfish](https://github.com/hogfish)):
|
21
|
+
|
22
|
+
```
|
23
|
+
$ counter_string 10
|
24
|
+
2*4*6*8*11
|
25
|
+
```
|
26
|
+
|
27
|
+
The counter string is automatically copied to your clipboard.
|
data/bin/counter_string
ADDED
data/lib/counter_string.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'counter_string'
|
4
|
+
|
5
|
+
cs = CounterString.new
|
6
|
+
|
7
|
+
def paste_command
|
8
|
+
if RUBY_PLATFORM =~ /mswin/
|
9
|
+
'clip'
|
10
|
+
else
|
11
|
+
'pbcopy'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if ARGV[0] != nil
|
16
|
+
output = cs.generate ARGV[0]
|
17
|
+
`echo #{output} | #{paste_command}`
|
18
|
+
puts output
|
19
|
+
else
|
20
|
+
puts "Please specify the string length"
|
21
|
+
end
|
data/lib/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = '0.
|
1
|
+
VERSION = '0.2.0'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
describe "CounterString CLI" do
|
4
|
+
before(:each) do
|
5
|
+
$stdout = StringIO.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should copy the counterstring to clipboard" do
|
9
|
+
system("ruby lib/counter_string_cli.rb 10")
|
10
|
+
|
11
|
+
if RUBY_PLATFORM =~ /mswin/
|
12
|
+
expect(IO.popen('paste', 'r+').read).to eq("2*4*6*8*11\n")
|
13
|
+
else
|
14
|
+
expect(IO.popen('pbpaste', 'r+').read).to eq("2*4*6*8*11\n")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should print the counterstring to the command line" do
|
19
|
+
expect(IO.popen("ruby lib/counter_string_cli.rb 14").read).to eq("2*4*6*8*11*14*\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should print an error when there are no arguments" do
|
23
|
+
expect(IO.popen("ruby lib/counter_string_cli.rb").read).to eq("Please specify the string length\n")
|
24
|
+
end
|
25
|
+
end
|
data/spec/counter_string_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: counter_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Martin
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description: Counter strings are self documenting strings with respect to their length.
|
56
56
|
This class will create counter strings of arbitrary length.
|
57
57
|
email: counterstring@jmrtn.com
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- counter_string
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -63,9 +64,12 @@ files:
|
|
63
64
|
- Gemfile
|
64
65
|
- README.md
|
65
66
|
- Rakefile
|
67
|
+
- bin/counter_string
|
66
68
|
- counterstring.gemspec
|
67
69
|
- lib/counter_string.rb
|
70
|
+
- lib/counter_string_cli.rb
|
68
71
|
- lib/version.rb
|
72
|
+
- spec/counter_string_cli_spec.rb
|
69
73
|
- spec/counter_string_spec.rb
|
70
74
|
- spec/spec.opts
|
71
75
|
homepage: http://github.com/jamesmartin/counterstring
|
@@ -92,5 +96,6 @@ signing_key:
|
|
92
96
|
specification_version: 4
|
93
97
|
summary: A class for generating self documenting strings
|
94
98
|
test_files:
|
99
|
+
- spec/counter_string_cli_spec.rb
|
95
100
|
- spec/counter_string_spec.rb
|
96
101
|
- spec/spec.opts
|