inkan 1.0.0 → 1.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.
- data/README.textile +4 -2
- data/lib/inkan.rb +3 -3
- data/spec/inkan_spec.rb +3 -3
- metadata +10 -11
data/README.textile
CHANGED
@@ -6,6 +6,8 @@ This is particularly useful for generating configuration files and then wanting
|
|
6
6
|
|
7
7
|
All it actually does is generate a SHA hash of the file's contents, and adds it as a comment at the top of the file. If the file's contents are changed, the SHA won't match, and then you can decide whether you want to overwrite the file.
|
8
8
|
|
9
|
+
The name *inkan* comes from "the Japanese word for a document seal":http://en.wikipedia.org/wiki/Inkan#Japanese_usage.
|
10
|
+
|
9
11
|
h2. Installing
|
10
12
|
|
11
13
|
<pre><code>gem install inkan</code></pre>
|
@@ -22,7 +24,7 @@ inkan.seal</code></pre>
|
|
22
24
|
|
23
25
|
Or:
|
24
26
|
|
25
|
-
<pre><code>Inkan.seal('
|
27
|
+
<pre><code>Inkan.seal('path/to/file.txt') { |inkan|
|
26
28
|
inkan.print 'foo'
|
27
29
|
}</code></pre>
|
28
30
|
|
@@ -35,7 +37,7 @@ h3. Customising
|
|
35
37
|
You can customise the header comment using the following settings:
|
36
38
|
|
37
39
|
<pre><code>inkan = Inkan.new('/path/to/file.txt')
|
38
|
-
inkan.
|
40
|
+
inkan.comment_prefix = '/*' # Default is '#'.
|
39
41
|
inkan.comment_suffix = '*/' # Default is ''.
|
40
42
|
inkan.credit = 'My Magic Code' # Default is 'Generated by Inkan'</code></pre>
|
41
43
|
|
data/lib/inkan.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
|
3
3
|
class Inkan
|
4
|
-
attr_accessor :credit, :
|
4
|
+
attr_accessor :credit, :comment_prefix, :comment_suffix
|
5
5
|
|
6
6
|
def self.legitimate?(file)
|
7
7
|
legit = false
|
@@ -29,7 +29,7 @@ class Inkan
|
|
29
29
|
|
30
30
|
# Set Defaults
|
31
31
|
@credit = 'Generated by Inkan'
|
32
|
-
@
|
32
|
+
@comment_prefix = '#'
|
33
33
|
@comment_suffix = ''
|
34
34
|
end
|
35
35
|
|
@@ -43,7 +43,7 @@ class Inkan
|
|
43
43
|
|
44
44
|
def seal
|
45
45
|
File.open(@file, 'w') do |f|
|
46
|
-
f.puts "#{
|
46
|
+
f.puts "#{comment_prefix} #{credit}. #{sha} #{comment_suffix}"
|
47
47
|
f.print file_content
|
48
48
|
end
|
49
49
|
end
|
data/spec/inkan_spec.rb
CHANGED
@@ -97,15 +97,15 @@ describe "Inkan" do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe '#
|
100
|
+
describe '#comment_prefix' do
|
101
101
|
let(:inkan) { Inkan.new('/tmp/spec.txt') }
|
102
102
|
|
103
103
|
it "defaults to a hash symbol" do
|
104
|
-
inkan.
|
104
|
+
inkan.comment_prefix.should == '#'
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should pass through changes to the file credit" do
|
108
|
-
inkan.
|
108
|
+
inkan.comment_prefix = "//"
|
109
109
|
inkan.print "foo bar baz"
|
110
110
|
inkan.seal
|
111
111
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inkan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Allan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-18 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -27,13 +27,12 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - "="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
30
|
+
hash: 1
|
31
31
|
segments:
|
32
32
|
- 1
|
33
33
|
- 5
|
34
|
-
-
|
35
|
-
|
36
|
-
version: 1.5.0.pre5
|
34
|
+
- 1
|
35
|
+
version: 1.5.1
|
37
36
|
requirement: *id001
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
type: :development
|
@@ -60,12 +59,12 @@ dependencies:
|
|
60
59
|
requirements:
|
61
60
|
- - "="
|
62
61
|
- !ruby/object:Gem::Version
|
63
|
-
hash:
|
62
|
+
hash: 23
|
64
63
|
segments:
|
65
64
|
- 2
|
65
|
+
- 6
|
66
66
|
- 0
|
67
|
-
|
68
|
-
version: 2.0.1
|
67
|
+
version: 2.6.0
|
69
68
|
requirement: *id003
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
70
|
type: :development
|