togglate 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/togglate/cli.rb +20 -1
- data/lib/togglate/version.rb +1 -1
- data/spec/togglate_cli_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d573daf3d95b1c968fffaa6e2f82ef0fd93cefa7
|
4
|
+
data.tar.gz: 61addd322ccd6d0596eba3a02cedd430ee14c6b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9281cc535ab9cdc9e9401a24d29aaa85db22c9286a775d33d085b7b9595696805dd603e4708b6641c32042aac8f68c48bcce46df2b4d828c5f2217a3924f2f66
|
7
|
+
data.tar.gz: b1a3aa396ba32ba7b4b50885da5938e6d0141666faaf4d87f40fc5320641935db2334c33e3a8560f2da61e6e4b3bc3f05651a6cfa763c77cd542da7db662a487
|
data/lib/togglate/cli.rb
CHANGED
@@ -8,16 +8,35 @@ module Togglate
|
|
8
8
|
option :toggle_link_text, type: :array, default:["*", "hide"]
|
9
9
|
option :code_block, aliases:'-c', default:false, type: :boolean, desc:"Enable code blocks not to be wrapped"
|
10
10
|
def create(file)
|
11
|
-
opts = options
|
11
|
+
opts = symbolize_keys(options)
|
12
12
|
opts.update(wrap_exceptions:[/^```/, /^ {4}/]) if opts[:code_block]
|
13
13
|
puts Togglate.create(file, opts)
|
14
14
|
end
|
15
15
|
|
16
|
+
desc "append_code FILE", "Append a hover or toggle code to a FILE"
|
17
|
+
option :method, aliases:'-m', default:'hover', desc:"Select a display method: 'hover' or 'toggle'"
|
18
|
+
option :toggle_link_text, type: :array, default:["*", "hide"]
|
19
|
+
def append_code(file)
|
20
|
+
text = File.read(file)
|
21
|
+
opts = symbolize_keys(options)
|
22
|
+
method = opts.delete(:method)
|
23
|
+
code = Togglate.append_code(method, opts)
|
24
|
+
puts "#{text}\n#{code}"
|
25
|
+
rescue => e
|
26
|
+
STDERR.puts "something go wrong. #{e}"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
16
30
|
desc "version", "Show Togglate version"
|
17
31
|
def version
|
18
32
|
puts "Togglate #{Togglate::VERSION} (c) 2014 kyoendo"
|
19
33
|
end
|
20
34
|
map "-v" => :version
|
21
35
|
|
36
|
+
no_tasks do
|
37
|
+
def symbolize_keys(options)
|
38
|
+
options.inject({}) { |h, (k,v)| h[k.intern] = v; h }
|
39
|
+
end
|
40
|
+
end
|
22
41
|
end
|
23
42
|
end
|
data/lib/togglate/version.rb
CHANGED
data/spec/togglate_cli_spec.rb
CHANGED
@@ -61,4 +61,16 @@ describe Togglate::CLI do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe "#append_code" do
|
66
|
+
it "appends hover code to a file" do
|
67
|
+
Togglate::CLI.start(['append_code', 'README.md'])
|
68
|
+
expect($stdout.string).to match(/<script.*nodeType==8.*<\/script>/m)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "appends toggle code to a file" do
|
72
|
+
Togglate::CLI.start(['append_code', 'README.md', '-m=toggle', '--toggle-link-text', 'showme', 'closeme'])
|
73
|
+
expect($stdout.string).to match(/<script.*showme.*<\/script>/m)
|
74
|
+
end
|
75
|
+
end
|
64
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: togglate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kyoendo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|