stickyflag 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/TODO.md +2 -1
  2. data/lib/stickyflag/version.rb +1 -1
  3. data/stickyflag.gemspec +5 -4
  4. metadata +8 -116
  5. data/.gitignore +0 -7
  6. data/.rspec +0 -4
  7. data/.simplecov +0 -9
  8. data/.travis.yml +0 -13
  9. data/features/clear.feature +0 -14
  10. data/features/clear_quietly.feature +0 -23
  11. data/features/configuration.feature +0 -14
  12. data/features/get.feature +0 -14
  13. data/features/get_quietly.feature +0 -23
  14. data/features/set.feature +0 -14
  15. data/features/set_quietly.feature +0 -22
  16. data/features/step_definitions/configuration_steps.rb +0 -31
  17. data/features/step_definitions/database_steps.rb +0 -41
  18. data/features/step_definitions/pending_steps.rb +0 -5
  19. data/features/step_definitions/tag_steps.rb +0 -62
  20. data/features/support/cukegem.rb +0 -82
  21. data/features/support/env.rb +0 -37
  22. data/features/tags.feature +0 -18
  23. data/features/unset.feature +0 -14
  24. data/features/unset_quietly.feature +0 -23
  25. data/spec/spec_helper.rb +0 -22
  26. data/spec/stickyflag/configuration_spec.rb +0 -132
  27. data/spec/stickyflag/database_spec.rb +0 -331
  28. data/spec/stickyflag/external_cmds_spec.rb +0 -175
  29. data/spec/stickyflag/patches/tempfile_encoding_spec.rb +0 -26
  30. data/spec/stickyflag/patches/tmpnam_spec.rb +0 -35
  31. data/spec/stickyflag/paths_spec.rb +0 -29
  32. data/spec/stickyflag/tag_factory_spec.rb +0 -126
  33. data/spec/stickyflag/tags/c_spec.rb +0 -14
  34. data/spec/stickyflag/tags/mkv_spec.rb +0 -54
  35. data/spec/stickyflag/tags/mmd_spec.rb +0 -40
  36. data/spec/stickyflag/tags/pdf_spec.rb +0 -39
  37. data/spec/stickyflag/tags/png_spec.rb +0 -6
  38. data/spec/stickyflag/tags/tex_spec.rb +0 -6
  39. data/spec/stickyflag_spec.rb +0 -482
  40. data/spec/support/examples.rb +0 -32
  41. data/spec/support/examples/c_all_comments.c +0 -3
  42. data/spec/support/examples/c_no_tags.c +0 -5
  43. data/spec/support/examples/c_with_tag.c +0 -6
  44. data/spec/support/examples/mkv_no_tags.mkv +0 -0
  45. data/spec/support/examples/mkv_with_tag.mkv +0 -0
  46. data/spec/support/examples/mmd_all_meta.mmd +0 -6
  47. data/spec/support/examples/mmd_crazy_keys.mmd +0 -8
  48. data/spec/support/examples/mmd_crazy_tags.mmd +0 -9
  49. data/spec/support/examples/mmd_no_tags.mmd +0 -1
  50. data/spec/support/examples/mmd_with_tag.mmd +0 -3
  51. data/spec/support/examples/pdf_no_tags.pdf +0 -0
  52. data/spec/support/examples/pdf_with_tag.pdf +0 -0
  53. data/spec/support/examples/png_no_tags.png +0 -0
  54. data/spec/support/examples/png_with_tag.png +0 -0
  55. data/spec/support/examples/tex_no_tags.tex +0 -10
  56. data/spec/support/examples/tex_with_tag.tex +0 -11
  57. data/spec/support/examples/untaggable.txt +0 -0
  58. data/spec/support/run_with_args.rb +0 -36
  59. data/spec/support/silence_stream.rb +0 -12
  60. data/spec/support/tag_handler_behavior.rb +0 -125
@@ -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
@@ -1,3 +0,0 @@
1
- // all comments
2
- // but no tags
3
- //
@@ -1,5 +0,0 @@
1
- // This is some example C++ code
2
-
3
- int main(int argc, char *argv[]) {
4
- return 0;
5
- }
@@ -1,6 +0,0 @@
1
- // SF_TAGS = test
2
- // This is some example C++ code
3
-
4
- int main(int argc, char *argv[]) {
5
- return 0;
6
- }
@@ -1,6 +0,0 @@
1
- Author: Charles H. Pence
2
- Description: This is a test of a key with a value
3
- that goes on for lots and lots of
4
- different lines and whatnot.
5
- Date: October 8, 2012
6
- Other: This file is all metadata, but has no tags
@@ -1,8 +0,0 @@
1
- Author: Charles H. Pence
2
- Description: This is a test of a key with a value
3
- that goes on for lots and lots of
4
- different lines and whatnot.
5
- Tags: test
6
- Date: October 8, 2012
7
-
8
- This is a test MMD document.
@@ -1,9 +0,0 @@
1
- Author: Charles H. Pence
2
- Description: This is a test of a key with a value
3
- that goes on for lots and lots of
4
- different lines and whatnot.
5
- Tags: asdf, sdfg, dfgh, fghj,
6
- qwer
7
- Date: October 8, 2012
8
-
9
- This is a test MMD document.
@@ -1 +0,0 @@
1
- This is a test MMD document.
@@ -1,3 +0,0 @@
1
- Tags: test
2
-
3
- This is a test MMD document.
@@ -1,10 +0,0 @@
1
- % This is a comment
2
- % Here's another comment
3
-
4
- \documentclass[10pt]{article}
5
- \begin{document}
6
- \title{A TeX example}
7
- \author{StickyFlag}
8
- \date{\today}
9
- \maketitle
10
- \end{document}
@@ -1,11 +0,0 @@
1
- % SF_TAGS = test
2
- % This is a comment
3
- % Here's another comment
4
-
5
- \documentclass[10pt]{article}
6
- \begin{document}
7
- \title{A TeX example}
8
- \author{StickyFlag}
9
- \date{\today}
10
- \maketitle
11
- \end{document}
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