stickyflag 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO.md +2 -1
- data/lib/stickyflag/version.rb +1 -1
- data/stickyflag.gemspec +5 -4
- metadata +8 -116
- data/.gitignore +0 -7
- data/.rspec +0 -4
- data/.simplecov +0 -9
- data/.travis.yml +0 -13
- data/features/clear.feature +0 -14
- data/features/clear_quietly.feature +0 -23
- data/features/configuration.feature +0 -14
- data/features/get.feature +0 -14
- data/features/get_quietly.feature +0 -23
- data/features/set.feature +0 -14
- data/features/set_quietly.feature +0 -22
- data/features/step_definitions/configuration_steps.rb +0 -31
- data/features/step_definitions/database_steps.rb +0 -41
- data/features/step_definitions/pending_steps.rb +0 -5
- data/features/step_definitions/tag_steps.rb +0 -62
- data/features/support/cukegem.rb +0 -82
- data/features/support/env.rb +0 -37
- data/features/tags.feature +0 -18
- data/features/unset.feature +0 -14
- data/features/unset_quietly.feature +0 -23
- data/spec/spec_helper.rb +0 -22
- data/spec/stickyflag/configuration_spec.rb +0 -132
- data/spec/stickyflag/database_spec.rb +0 -331
- data/spec/stickyflag/external_cmds_spec.rb +0 -175
- data/spec/stickyflag/patches/tempfile_encoding_spec.rb +0 -26
- data/spec/stickyflag/patches/tmpnam_spec.rb +0 -35
- data/spec/stickyflag/paths_spec.rb +0 -29
- data/spec/stickyflag/tag_factory_spec.rb +0 -126
- data/spec/stickyflag/tags/c_spec.rb +0 -14
- data/spec/stickyflag/tags/mkv_spec.rb +0 -54
- data/spec/stickyflag/tags/mmd_spec.rb +0 -40
- data/spec/stickyflag/tags/pdf_spec.rb +0 -39
- data/spec/stickyflag/tags/png_spec.rb +0 -6
- data/spec/stickyflag/tags/tex_spec.rb +0 -6
- data/spec/stickyflag_spec.rb +0 -482
- data/spec/support/examples.rb +0 -32
- data/spec/support/examples/c_all_comments.c +0 -3
- data/spec/support/examples/c_no_tags.c +0 -5
- data/spec/support/examples/c_with_tag.c +0 -6
- data/spec/support/examples/mkv_no_tags.mkv +0 -0
- data/spec/support/examples/mkv_with_tag.mkv +0 -0
- data/spec/support/examples/mmd_all_meta.mmd +0 -6
- data/spec/support/examples/mmd_crazy_keys.mmd +0 -8
- data/spec/support/examples/mmd_crazy_tags.mmd +0 -9
- data/spec/support/examples/mmd_no_tags.mmd +0 -1
- data/spec/support/examples/mmd_with_tag.mmd +0 -3
- data/spec/support/examples/pdf_no_tags.pdf +0 -0
- data/spec/support/examples/pdf_with_tag.pdf +0 -0
- data/spec/support/examples/png_no_tags.png +0 -0
- data/spec/support/examples/png_with_tag.png +0 -0
- data/spec/support/examples/tex_no_tags.tex +0 -10
- data/spec/support/examples/tex_with_tag.tex +0 -11
- data/spec/support/examples/untaggable.txt +0 -0
- data/spec/support/run_with_args.rb +0 -36
- data/spec/support/silence_stream.rb +0 -12
- data/spec/support/tag_handler_behavior.rb +0 -125
data/spec/support/examples.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'fileutils'
|
3
|
-
require 'pathname'
|
4
|
-
require 'tmpdir'
|
5
|
-
|
6
|
-
def example_root
|
7
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'examples'))
|
8
|
-
end
|
9
|
-
|
10
|
-
def example_path(example)
|
11
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'examples', example))
|
12
|
-
end
|
13
|
-
|
14
|
-
def copy_example(example)
|
15
|
-
path = example_path(example)
|
16
|
-
temp_path = File.expand_path(File.join(Dir.tmpdir, "temp-#{Random.rand(1000)}-#{example}"))
|
17
|
-
|
18
|
-
# If the file doesn't exist, then just return a bad file path
|
19
|
-
if File.exist? path
|
20
|
-
counter = 0
|
21
|
-
while File.exist? temp_path
|
22
|
-
temp_path = File.expand_path(File.join(Dir.tmpdir, "temp-#{Random.rand(1000)}-#{example}"))
|
23
|
-
counter += 1
|
24
|
-
|
25
|
-
raise "Cannot create temporary file" if counter >= 100
|
26
|
-
end
|
27
|
-
|
28
|
-
FileUtils.cp(path, temp_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
temp_path
|
32
|
-
end
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
This is a test MMD document.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'thor'
|
3
|
-
require 'stickyflag'
|
4
|
-
|
5
|
-
class DatabaseHelper
|
6
|
-
def database_path
|
7
|
-
":memory:"
|
8
|
-
end
|
9
|
-
|
10
|
-
include StickyFlag::Database
|
11
|
-
end
|
12
|
-
|
13
|
-
def run_with_args(*args)
|
14
|
-
# We want to load an in-memory database ourselves, so that we can tear it
|
15
|
-
# down in this function (there's nowhere to hook in Thor for after the
|
16
|
-
# task is completed)
|
17
|
-
dbh = DatabaseHelper.new
|
18
|
-
dbh.load_database
|
19
|
-
database = dbh.instance_variable_get(:@database)
|
20
|
-
|
21
|
-
StickyFlag::ThorApp.send(:dispatch, nil, args, nil, {}) do |instance|
|
22
|
-
# Always stub out load_ and save_config! and database_path, so that we
|
23
|
-
# don't tromp on the user's own private data.
|
24
|
-
instance.stub(:load_config!) { }
|
25
|
-
instance.stub(:save_config!) { }
|
26
|
-
|
27
|
-
# Patch in the new database
|
28
|
-
instance.instance_variable_set(:@database, database)
|
29
|
-
instance.create_tables
|
30
|
-
|
31
|
-
yield instance if block_given?
|
32
|
-
end
|
33
|
-
|
34
|
-
# Clean up
|
35
|
-
database.disconnect
|
36
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
module Kernel
|
4
|
-
def silence_stream(stream)
|
5
|
-
old_stream = stream.dup
|
6
|
-
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
7
|
-
stream.sync = true
|
8
|
-
yield
|
9
|
-
ensure
|
10
|
-
stream.reopen(old_stream)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
shared_examples_for 'a tag handler' do
|
4
|
-
let(:params) { [] }
|
5
|
-
|
6
|
-
def file_extension
|
7
|
-
described_class.to_s.gsub('StickyFlag::Tags::', '').downcase
|
8
|
-
end
|
9
|
-
|
10
|
-
def example_with_tag
|
11
|
-
example_path "#{file_extension}_with_tag.#{file_extension}"
|
12
|
-
end
|
13
|
-
def example_no_tags
|
14
|
-
example_path "#{file_extension}_no_tags.#{file_extension}"
|
15
|
-
end
|
16
|
-
def copy_example_with_tag
|
17
|
-
copy_example "#{file_extension}_with_tag.#{file_extension}"
|
18
|
-
end
|
19
|
-
def copy_example_no_tags
|
20
|
-
copy_example "#{file_extension}_no_tags.#{file_extension}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def params_for(*new_params)
|
24
|
-
new_params.concat(params)
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.get' do
|
28
|
-
it 'exists' do
|
29
|
-
described_class.methods.should include(:get) if RUBY_VERSION >= "1.9.0"
|
30
|
-
described_class.methods.should include("get") if RUBY_VERSION < "1.9.0"
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'gets tags from tagged files' do
|
34
|
-
described_class.get(*params_for(example_with_tag)).should include('test')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'does not get tags from untagged files' do
|
38
|
-
described_class.get(*params_for(example_no_tags)).should_not include('test')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '.set' do
|
43
|
-
it 'exists' do
|
44
|
-
described_class.methods.should include(:set) if RUBY_VERSION >= "1.9.0"
|
45
|
-
described_class.methods.should include("set") if RUBY_VERSION < "1.9.0"
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'sets tags in an untagged file' do
|
49
|
-
path = copy_example_no_tags
|
50
|
-
|
51
|
-
described_class.set(*params_for(path, 'rspec'))
|
52
|
-
described_class.get(*params_for(path)).should include('rspec')
|
53
|
-
|
54
|
-
File.unlink(path)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'sets tags in a tagged file' do
|
58
|
-
path = copy_example_with_tag
|
59
|
-
|
60
|
-
described_class.set(*params_for(path, 'rspec'))
|
61
|
-
described_class.get(*params_for(path)).should include('rspec')
|
62
|
-
|
63
|
-
File.unlink(path)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'does the right thing when setting an already set tag' do
|
67
|
-
path = copy_example_with_tag
|
68
|
-
|
69
|
-
described_class.set(*params_for(path, 'test'))
|
70
|
-
described_class.get(*params_for(path)).count('test').should eq(1)
|
71
|
-
|
72
|
-
File.unlink(path)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '.unset' do
|
77
|
-
it 'exists' do
|
78
|
-
described_class.methods.should include(:unset) if RUBY_VERSION >= "1.9.0"
|
79
|
-
described_class.methods.should include("unset") if RUBY_VERSION < "1.9.0"
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'removes tags from a tagged file' do
|
83
|
-
path = copy_example_with_tag
|
84
|
-
|
85
|
-
described_class.unset(*params_for(path, 'test'))
|
86
|
-
described_class.get(*params_for(path)).should_not include('test')
|
87
|
-
|
88
|
-
File.unlink(path)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'does the right thing when removing an already removed tag' do
|
92
|
-
path = copy_example_with_tag
|
93
|
-
|
94
|
-
described_class.unset(*params_for(path, 'rspec'))
|
95
|
-
described_class.get(*params_for(path)).should eq([ 'test' ])
|
96
|
-
|
97
|
-
File.unlink(path)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '.clear' do
|
102
|
-
it 'exists' do
|
103
|
-
described_class.methods.should include(:clear) if RUBY_VERSION >= "1.9.0"
|
104
|
-
described_class.methods.should include("clear") if RUBY_VERSION < "1.9.0"
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'clears tags from tagged files' do
|
108
|
-
path = copy_example_with_tag
|
109
|
-
|
110
|
-
described_class.clear(*params_for(path))
|
111
|
-
described_class.get(*params_for(path)).should be_empty
|
112
|
-
|
113
|
-
File.unlink(path)
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'does not break untagged files' do
|
117
|
-
path = copy_example_no_tags
|
118
|
-
|
119
|
-
described_class.clear(*params_for(path))
|
120
|
-
described_class.get(*params_for(path)).should be_empty
|
121
|
-
|
122
|
-
File.unlink(path)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|