falkorlib 0.6.19 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +88 -0
  4. data/.travis.yml +56 -4
  5. data/Gemfile +4 -4
  6. data/Gemfile.lock +55 -27
  7. data/Rakefile +12 -8
  8. data/Vagrantfile +68 -0
  9. data/completion/_falkor +55 -7
  10. data/falkorlib.gemspec +14 -12
  11. data/lib/falkorlib.rb +22 -21
  12. data/lib/falkorlib/bootstrap.rb +5 -1
  13. data/lib/falkorlib/bootstrap/base.rb +385 -693
  14. data/lib/falkorlib/bootstrap/git.rb +137 -0
  15. data/lib/falkorlib/bootstrap/latex.rb +186 -0
  16. data/lib/falkorlib/bootstrap/link.rb +108 -96
  17. data/lib/falkorlib/bootstrap/ruby.rb +102 -0
  18. data/lib/falkorlib/cli.rb +82 -26
  19. data/lib/falkorlib/cli/config.rb +8 -8
  20. data/lib/falkorlib/cli/link.rb +8 -9
  21. data/lib/falkorlib/cli/new.rb +25 -39
  22. data/lib/falkorlib/common.rb +425 -425
  23. data/lib/falkorlib/config.rb +114 -110
  24. data/lib/falkorlib/error.rb +27 -16
  25. data/lib/falkorlib/gem_tasks.rb +12 -11
  26. data/lib/falkorlib/git.rb +3 -4
  27. data/lib/falkorlib/git/base.rb +439 -396
  28. data/lib/falkorlib/git/flow.rb +163 -165
  29. data/lib/falkorlib/git_tasks.rb +31 -31
  30. data/lib/falkorlib/loader.rb +1 -1
  31. data/lib/falkorlib/puppet.rb +3 -5
  32. data/lib/falkorlib/puppet/base.rb +10 -15
  33. data/lib/falkorlib/puppet/modules.rb +367 -365
  34. data/lib/falkorlib/puppet_tasks.rb +11 -8
  35. data/lib/falkorlib/tasks.rb +51 -54
  36. data/lib/falkorlib/tasks/gem.rake +42 -43
  37. data/lib/falkorlib/tasks/gem.rb +12 -11
  38. data/lib/falkorlib/tasks/git.rake +101 -107
  39. data/lib/falkorlib/tasks/git.rb +31 -31
  40. data/lib/falkorlib/tasks/gitflow.rake +131 -141
  41. data/lib/falkorlib/tasks/puppet.rb +11 -8
  42. data/lib/falkorlib/tasks/puppet_modules.rake +143 -154
  43. data/lib/falkorlib/tasks/rspec.rake +94 -59
  44. data/lib/falkorlib/tasks/yard.rake +35 -39
  45. data/lib/falkorlib/version.rb +55 -55
  46. data/lib/falkorlib/versioning.rb +169 -167
  47. data/spec/falkorlib/bootstrap_helpers_spec.rb +106 -56
  48. data/spec/falkorlib/bootstrap_latex_spec.rb +145 -0
  49. data/spec/falkorlib/bootstrap_link_spec.rb +137 -0
  50. data/spec/falkorlib/bootstrap_ruby_spec.rb +118 -0
  51. data/spec/falkorlib/bootstrap_spec.rb +112 -129
  52. data/spec/falkorlib/git_spec.rb +94 -22
  53. data/spec/falkorlib/gitflow_spec.rb +54 -42
  54. data/spec/falkorlib/puppet_modules_spec.rb +35 -26
  55. data/spec/falkorlib/versioning_puppet_module_spec.rb +94 -90
  56. data/spec/falkorlib_spec.rb +5 -0
  57. data/spec/spec_helper.rb +88 -47
  58. data/templates/latex/article-ieee/main.tex.erb +509 -0
  59. data/templates/latex/article/_abstract.tex.erb +19 -0
  60. data/templates/latex/article/_acronyms.tex.erb +116 -0
  61. data/templates/latex/article/_conclusion.tex.erb +25 -0
  62. data/templates/latex/article/_context.tex.erb +17 -0
  63. data/templates/latex/article/_experiments.tex.erb +27 -0
  64. data/templates/latex/article/_implem.tex.erb +17 -0
  65. data/templates/latex/article/_introduction.tex.erb +39 -0
  66. data/templates/latex/article/_related_works.tex.erb +19 -0
  67. data/templates/latex/article/biblio.bib.erb +28 -0
  68. data/templates/latex/article/template.tex.erb +16 -0
  69. data/templates/latex/ieee/IEEEtran.bst +2409 -0
  70. data/templates/latex/ieee/IEEEtran.cls +6347 -0
  71. data/templates/motd/motd.erb +2 -1
  72. metadata +82 -2
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # gitflow_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Sun 2016-10-16 22:06 svarrette>
5
+ # Time-stamp: <Wed 2016-11-09 09:16 svarrette>
6
6
  #
7
7
  # @description Check the Git Flow operations -- see https://github.com/nvie/gitflow
8
8
  #
@@ -14,58 +14,70 @@ require 'spec_helper'
14
14
  require 'tmpdir'
15
15
 
16
16
  describe FalkorLib::GitFlow do
17
- include FalkorLib::Common
17
+ include FalkorLib::Common
18
18
 
19
- if command?('git-flow')
19
+ if command?('git-flow')
20
20
 
21
21
 
22
- dir = Dir.mktmpdir
23
- afile = File.join(dir, 'a_file')
22
+ dir = Dir.mktmpdir
23
+ afile = File.join(dir, 'a_file')
24
24
 
25
- after :all do
26
- FileUtils.remove_entry_secure dir
27
- end
25
+ after :all do
26
+ FileUtils.remove_entry_secure dir
27
+ end
28
+
29
+ #############################################################
30
+ context "Test git-flow operations within temporary directory " do
28
31
 
29
- #############################################################
30
- context "Test git-flow operations within temporary directory " do
32
+ it "#init? - fails on non-git directory" do
33
+ t = FalkorLib::GitFlow.init?(dir)
34
+ expect(t).to be false
35
+ end
31
36
 
32
- it "#init? - fails on non-git directory" do
33
- t = FalkorLib::GitFlow.init?(dir)
34
- expect(t).to be false
35
- end
37
+ it "#init - initialize a git-flow repository" do
38
+ expect(STDIN).to receive(:gets).and_return('Yes')
39
+ i = FalkorLib::GitFlow.init(dir)
40
+ expect(i).to eq(0)
41
+ t = FalkorLib::Git.init?(dir)
42
+ expect(t).to be true
43
+ end
36
44
 
37
- it "#init - initialize a git-flow repository" do
38
- expect(STDIN).to receive(:gets).and_return('Yes')
39
- i = FalkorLib::GitFlow.init(dir)
40
- expect(i).to eq(0)
41
- t = FalkorLib::Git.init?(dir)
42
- expect(t).to be true
43
- end
45
+ it "#init? - succeed on git-flow enabled directory" do
46
+ t = FalkorLib::GitFlow.init?(dir)
47
+ expect(t).to be true
48
+ end
44
49
 
45
- it "#init? - succeed on git-flow enabled directory" do
46
- t = FalkorLib::GitFlow.init?(dir)
47
- expect(t).to be true
48
- end
50
+ it "#branch" do
51
+ expected = {
52
+ :master => 'production',
53
+ :develop => 'devel'
54
+ }
55
+ expected.each do |type,v|
56
+ b = FalkorLib::GitFlow.branches(type.to_sym, dir)
57
+ expect(b).to eq(expected[type.to_sym])
58
+ end
59
+ end
49
60
 
50
- #['feature', 'hotfix', 'support'].each do |op|
51
- ['feature'].each do |op|
52
- name = 'toto'
53
- it "#start -- should start a '#{op}' GitFlow operation" do
54
- a = FalkorLib::GitFlow.start(op, name, dir)
55
- expect(a).to eq(0)
56
- br = FalkorLib::Git.branch?( dir )
57
- expect(br).to eq("#{op}/#{name}")
58
- end
59
61
 
60
- it "#finish -- should finish a '#{op}' GitFlow operation" do
61
- expect(STDIN).to receive(:gets).and_return("Test #{op} operation") if [ 'hotfix', 'support' ].include?(op)
62
- a = FalkorLib::GitFlow.finish(op, name, dir)
63
- expect(a).to eq(0)
64
- br = FalkorLib::Git.branch?( dir )
65
- expect(br).to eq(FalkorLib.config[:gitflow][:branches][:develop])
66
- end
67
- end
62
+ #['feature', 'hotfix', 'support'].each do |op|
63
+ ['feature'].each do |op|
64
+ name = 'toto'
65
+ it "#start -- should start a '#{op}' GitFlow operation" do
66
+ a = FalkorLib::GitFlow.start(op, name, dir)
67
+ expect(a).to eq(0)
68
+ br = FalkorLib::Git.branch?( dir )
69
+ expect(br).to eq("#{op}/#{name}")
68
70
  end
69
71
 
72
+ it "#finish -- should finish a '#{op}' GitFlow operation" do
73
+ expect(STDIN).to receive(:gets).and_return("Test #{op} operation") if [ 'hotfix', 'support' ].include?(op)
74
+ a = FalkorLib::GitFlow.finish(op, name, dir)
75
+ expect(a).to eq(0)
76
+ br = FalkorLib::Git.branch?( dir )
77
+ expect(br).to eq(FalkorLib.config[:gitflow][:branches][:develop])
78
+ end
79
+ end
70
80
  end
81
+
82
+ end
71
83
  end
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # puppet_modules_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Sun 2016-10-16 22:06 svarrette>
5
+ # Time-stamp: <Thu 2016-11-10 02:01 svarrette>
6
6
  #
7
7
  # @description Check the Puppet Modules operations
8
8
  #
@@ -19,10 +19,11 @@ describe FalkorLib::Puppet::Modules do
19
19
  include FalkorLib::Common
20
20
 
21
21
  dir = Dir.mktmpdir
22
+
22
23
  # Module name
23
24
  name = 'toto'
24
25
  moduledir = File.join(dir, name)
25
- jsonfile = File.join( moduledir, 'metadata.json')
26
+ jsonfile = File.join(moduledir, 'metadata.json')
26
27
 
27
28
  #afile = File.join(dir, 'a_file')
28
29
  # before :all do
@@ -30,8 +31,16 @@ describe FalkorLib::Puppet::Modules do
30
31
  # ENV['GIT_AUTHOR_EMAIL'] = 'travis@domain.org' if ENV['GIT_AUTHOR_EMAIL'].nil?
31
32
  # end
32
33
 
34
+ #_____________
35
+ before :all do
36
+ $stdout.sync = true
37
+ FalkorLib.config[:no_interaction] = true
38
+ end
39
+
40
+ #____________
33
41
  after :all do
34
42
  FileUtils.remove_entry_secure dir
43
+ FalkorLib.config[:no_interaction] = false
35
44
  end
36
45
 
37
46
  #############################################################
@@ -40,7 +49,7 @@ describe FalkorLib::Puppet::Modules do
40
49
 
41
50
  it "#init -- create a puppet module" do
42
51
  # Prepare answer to the questions
43
- Array.new(17).each { |e| expect(STDIN).to receive(:gets).and_return('') }
52
+ #Array.new(17).each { |e| expect(STDIN).to receive(:gets).and_return('') }
44
53
  FalkorLib::Puppet::Modules.init(moduledir)
45
54
  templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
46
55
  s = true
@@ -106,15 +115,15 @@ describe FalkorLib::Puppet::Modules do
106
115
  metadata = FalkorLib::Puppet::Modules.parse(moduledir, { :no_interaction => true })
107
116
  diff = (metadata.to_a - ref.to_a).flatten.sort
108
117
  expect(diff).to eq([
109
- 'classes',
110
- 'definitions',
111
- 'toto',
112
- 'toto::common',
113
- 'toto::common::debian',
114
- 'toto::common::redhat',
115
- 'toto::mydef',
116
- 'toto::params',
117
- ])
118
+ 'classes',
119
+ 'definitions',
120
+ 'toto',
121
+ 'toto::common',
122
+ 'toto::common::debian',
123
+ 'toto::common::redhat',
124
+ 'toto::mydef',
125
+ 'toto::params',
126
+ ])
118
127
  end
119
128
 
120
129
  it "#parse again -- should not exhibit any difference" do
@@ -132,20 +141,20 @@ describe FalkorLib::Puppet::Modules do
132
141
  expect(a).to include newdep
133
142
  end
134
143
 
135
- it "#parse again -- should ask new dependency elements" do
136
- ref = JSON.parse( IO.read( jsonfile ) )
137
- expect(STDIN).to receive(:gets).and_return('svarrette')
138
- expect(STDIN).to receive(:gets).and_return('1.2')
139
- expect(STDIN).to receive(:gets).and_return('Yes')
140
- expect(STDIN).to receive(:gets).and_return('')
141
- metadata = FalkorLib::Puppet::Modules.parse(moduledir)
142
- diff = (metadata.to_a - ref.to_a).flatten
143
- expect(diff).to eq([
144
- 'dependencies',
145
- {"name"=>"puppetlabs-stdlib", "version_requirement"=>">=4.2.2 <5.0.0"},
146
- {"name"=>"svarrette/tata", "version_requirement"=>"1.2"}
147
- ])
148
- end
144
+ # it "#parse again -- should ask new dependency elements" do
145
+ # ref = JSON.parse( IO.read( jsonfile ) )
146
+ # expect(STDIN).to receive(:gets).and_return('svarrette')
147
+ # expect(STDIN).to receive(:gets).and_return('1.2')
148
+ # expect(STDIN).to receive(:gets).and_return('Yes')
149
+ # expect(STDIN).to receive(:gets).and_return('')
150
+ # metadata = FalkorLib::Puppet::Modules.parse(moduledir)
151
+ # diff = (metadata.to_a - ref.to_a).flatten
152
+ # expect(diff).to eq([
153
+ # 'dependencies',
154
+ # {"name"=>"puppetlabs-stdlib", "version_requirement"=>">=4.2.2 <5.0.0"},
155
+ # {"name"=>"svarrette/tata", "version_requirement"=>"1.2"}
156
+ # ])
157
+ # end
149
158
 
150
159
  upgraded_files_default = 1
151
160
  it "#upgrade" do
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # versioning_puppet_module_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Tue 2016-06-28 18:51 svarrette>
5
+ # Time-stamp: <Thu 2016-11-10 02:04 svarrette>
6
6
  #
7
7
  # @description Check the versioning operations on Gems
8
8
  #
@@ -16,96 +16,100 @@ require 'tmpdir'
16
16
 
17
17
  describe FalkorLib::Versioning::Puppet do
18
18
 
19
- include FalkorLib::Common
20
-
21
- dir = Dir.mktmpdir
22
- name = 'toto'
23
- moduledir = File.join(dir, name)
24
- default_version = FalkorLib.config[:versioning][:default]
25
-
26
- workingversion = {
27
- :default => '4.5.6',
28
- :patch => '4.5.7',
29
- :minor => '4.6.0',
30
- :major => '5.0.0'
31
- }
32
-
33
- before :all do
34
- configatron.temp_start
35
- FalkorLib.config.versioning do |c|
36
- c[:type] = 'puppet_module'
37
- end
38
- end
39
-
40
- after :all do
41
- configatron.temp_end
42
- FileUtils.remove_entry_secure dir
43
- FalkorLib.config.versioning[:type] = 'file'
19
+ include FalkorLib::Common
20
+
21
+ dir = Dir.mktmpdir
22
+ name = 'toto'
23
+ moduledir = File.join(dir, name)
24
+ default_version = FalkorLib.config[:versioning][:default]
25
+
26
+ workingversion = {
27
+ :default => '4.5.6',
28
+ :patch => '4.5.7',
29
+ :minor => '4.6.0',
30
+ :major => '5.0.0'
31
+ }
32
+
33
+ #_____________
34
+ before :all do
35
+ configatron.temp_start
36
+ FalkorLib.config[:no_interaction] = true
37
+ FalkorLib.config.versioning do |c|
38
+ c[:type] = 'puppet_module'
44
39
  end
40
+ end
41
+
42
+ #_____________
43
+ after :all do
44
+ configatron.temp_end
45
+ FileUtils.remove_entry_secure dir
46
+ FalkorLib.config.versioning[:type] = 'file'
47
+ FalkorLib.config[:no_interaction] = false
48
+ end
49
+
50
+ # configatron.temp do
51
+ # FalkorLib.config.versioning do |c|
52
+ # c[:type] = 'puppet_module'
53
+ # end
54
+
55
+ ###################################################################
56
+ context 'Test Puppet Module versioning operations within temporary directory' do
57
+
58
+ ap default_version
59
+ it "#get_version -- get default version #{default_version} after initialization" do
60
+ #Array.new(17).each { |e| expect(STDIN).to receive(:gets).and_return('') }
61
+ FalkorLib::Puppet::Modules.init(moduledir)
62
+ v = FalkorLib::Versioning.get_version(moduledir)
63
+ expect(v).to eq(default_version)
64
+ if command?('git-flow')
65
+ a = FalkorLib::GitFlow.finish('feature', 'bootstrapping', moduledir)
66
+ expect(a).to eq(0)
67
+ end
68
+ end
69
+
70
+ it "#set_version -- should set the '#{workingversion[:default]}' version" do
71
+ #expect(STDIN).to receive(:gets).and_return('Yes')
72
+ v = FalkorLib::Versioning.set_version(workingversion[:default], moduledir)
73
+ expect(v).to eq(0)
74
+ end
75
+
76
+ it "#get_version -- should get the '#{workingversion[:default]}'" do
77
+ v = FalkorLib::Versioning.get_version(moduledir)
78
+ expect(v).to eq(workingversion[:default])
79
+ end
80
+
81
+ it "#major -- should collect the major version" do
82
+ v = FalkorLib::Versioning.get_version(moduledir)
83
+ m = FalkorLib::Versioning.major(v)
84
+ expect(m).to eq('4')
85
+ end
86
+ it "#minor -- should collect the minor version" do
87
+ v = FalkorLib::Versioning.get_version(moduledir)
88
+ m = FalkorLib::Versioning.minor(v)
89
+ expect(m).to eq('5')
90
+ end
91
+ it "#patch -- should collect the patch version" do
92
+ v = FalkorLib::Versioning.get_version(moduledir)
93
+ m = FalkorLib::Versioning.patch(v)
94
+ expect(m).to eq('6')
95
+ end
96
+
97
+ #FalkorLib.config[:versioning][:levels].reverse.each do |level|
98
+ ['patch', 'minor'].each do |level|
99
+ it "#set_version #bump -- #{level} bump version number from #{workingversion[:default]} to #{workingversion[level.to_sym]}" do
100
+ v = FalkorLib::Versioning.get_version(moduledir)
101
+ expect(v).to eq(workingversion[:default])
102
+ v2 = FalkorLib::Versioning.bump(v, level.to_sym)
103
+ expect(v2).to eq(workingversion[level.to_sym])
104
+ #STDIN.should_receive(:gets).and_return('Yes')
105
+ #d = FalkorLib::Versioning.set_version(v2, moduledir)
106
+ #d.should == 0
107
+ #v3 = FalkorLib::Versioning.get_version(moduledir)
108
+ #v3.should == v2
109
+ end
110
+ end
111
+ end
45
112
 
46
- # configatron.temp do
47
- # FalkorLib.config.versioning do |c|
48
- # c[:type] = 'puppet_module'
49
- # end
50
-
51
- ###################################################################
52
- context 'Test Puppet Module versioning operations within temporary directory' do
53
-
54
- ap default_version
55
- it "#get_version -- get default version #{default_version} after initialization" do
56
- Array.new(17).each { |e| expect(STDIN).to receive(:gets).and_return('') }
57
- FalkorLib::Puppet::Modules.init(moduledir)
58
- v = FalkorLib::Versioning.get_version(moduledir)
59
- expect(v).to eq(default_version)
60
- if command?('git-flow')
61
- a = FalkorLib::GitFlow.finish('feature', 'bootstrapping', moduledir)
62
- expect(a).to eq(0)
63
- end
64
- end
65
-
66
- it "#set_version -- should set the '#{workingversion[:default]}' version" do
67
- expect(STDIN).to receive(:gets).and_return('Yes')
68
- v = FalkorLib::Versioning.set_version(workingversion[:default], moduledir)
69
- expect(v).to eq(0)
70
- end
71
-
72
- it "#get_version -- should get the '#{workingversion[:default]}'" do
73
- v = FalkorLib::Versioning.get_version(moduledir)
74
- expect(v).to eq(workingversion[:default])
75
- end
76
-
77
- it "#major -- should collect the major version" do
78
- v = FalkorLib::Versioning.get_version(moduledir)
79
- m = FalkorLib::Versioning.major(v)
80
- expect(m).to eq('4')
81
- end
82
- it "#minor -- should collect the minor version" do
83
- v = FalkorLib::Versioning.get_version(moduledir)
84
- m = FalkorLib::Versioning.minor(v)
85
- expect(m).to eq('5')
86
- end
87
- it "#patch -- should collect the patch version" do
88
- v = FalkorLib::Versioning.get_version(moduledir)
89
- m = FalkorLib::Versioning.patch(v)
90
- expect(m).to eq('6')
91
- end
92
-
93
- #FalkorLib.config[:versioning][:levels].reverse.each do |level|
94
- ['patch', 'minor'].each do |level|
95
- it "#set_version #bump -- #{level} bump version number from #{workingversion[:default]} to #{workingversion[level.to_sym]}" do
96
- v = FalkorLib::Versioning.get_version(moduledir)
97
- expect(v).to eq(workingversion[:default])
98
- v2 = FalkorLib::Versioning.bump(v, level.to_sym)
99
- expect(v2).to eq(workingversion[level.to_sym])
100
- #STDIN.should_receive(:gets).and_return('Yes')
101
- #d = FalkorLib::Versioning.set_version(v2, moduledir)
102
- #d.should == 0
103
- #v3 = FalkorLib::Versioning.get_version(moduledir)
104
- #v3.should == v2
105
- end
106
- end
107
- end
108
-
109
- #end #configatron.temp
113
+ #end #configatron.temp
110
114
 
111
115
  end # describe FalkorLib::Versioning
@@ -5,4 +5,9 @@ describe FalkorLib do
5
5
  expect(FalkorLib.const_defined?(:VERSION)).to be true
6
6
  end
7
7
 
8
+ it "self.lib" do
9
+ expect(FalkorLib.lib).to include 'lib'
10
+ end
11
+
12
+
8
13
  end
@@ -1,6 +1,11 @@
1
1
  require "codeclimate-test-reporter"
2
2
  CodeClimate::TestReporter.start
3
3
 
4
+ # See https://github.com/colszowka/simplecov
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+
4
9
  require 'rubygems'
5
10
  require 'bundler/setup'
6
11
  Bundler.setup
@@ -14,37 +19,73 @@ require 'falkorlib'
14
19
  require 'falkorlib/common'
15
20
  require 'falkorlib/git'
16
21
 
17
- def capture(stream)
18
- begin
19
- stream = stream.to_s
20
- eval "$#{stream} = StringIO.new"
21
- yield
22
- result = eval("$#{stream}").string
23
- ensure
24
- eval("$#{stream} = #{stream.upcase}")
25
- end
26
- result
27
- end
28
22
 
29
- # Credits: [nu7hatch](https://gist.github.com/nu7hatch/631329)
30
- module Helpers
31
- # Replace standard input with faked one StringIO.
32
- def fake_stdin(*args)
23
+
24
+ # Based on Thor
25
+ RSpec.configure do |config|
26
+
27
+ def capture(stream)
33
28
  begin
34
- $stdin = StringIO.new
35
- $stdin.puts(args.shift) until args.empty?
36
- $stdin.rewind
29
+ stream = stream.to_s
30
+ eval "$#{stream} = StringIO.new"
37
31
  yield
32
+ result = eval("$#{stream}").string
38
33
  ensure
39
- $stdin = STDIN
34
+ eval("$#{stream} = #{stream.upcase}")
40
35
  end
36
+
37
+ result
41
38
  end
42
- end
43
39
 
44
- RSpec.configure do |conf|
45
- conf.include(Helpers)
40
+ # # This code was adapted from Ruby on Rails, available under MIT-LICENSE
41
+ # # Copyright (c) 2004-2013 David Heinemeier Hansson
42
+ # def silence_warnings
43
+ # old_verbose, $VERBOSE = $VERBOSE, nil
44
+ # yield
45
+ # ensure
46
+ # $VERBOSE = old_verbose
47
+ # end
48
+
49
+ # alias silence capture
46
50
  end
47
51
 
52
+
53
+ # def capture(stream)
54
+ # begin
55
+ # stream = stream.to_s
56
+ # eval "$#{stream} = StringIO.new"
57
+ # yield
58
+ # result = eval("$#{stream}").string
59
+ # ensure
60
+ # eval("$#{stream} = #{stream.upcase}")
61
+ # end
62
+ # result
63
+ # end
64
+
65
+ # # Credits: [nu7hatch](https://gist.github.com/nu7hatch/631329)
66
+ # module Helpers
67
+ # # Replace standard input with faked one StringIO.
68
+ # def fake_stdin(*args)
69
+ # begin
70
+ # $stdin = StringIO.new
71
+ # $stdin.puts(args.shift) until args.empty?
72
+ # $stdin.rewind
73
+ # yield
74
+ # ensure
75
+ # $stdin = STDIN
76
+ # end
77
+ # end
78
+ # end
79
+
80
+
81
+ # RSpec.configure do |conf|
82
+ # conf.include(Helpers)
83
+
84
+
85
+ # end
86
+
87
+
88
+
48
89
  # require 'minitest/autorun'
49
90
  # require 'minitest/spec'
50
91
 
@@ -56,32 +97,32 @@ end
56
97
  # end
57
98
 
58
99
  # credits to [gabebw](http://gabebw.wordpress.com/2011/03/21/temp-files-in-rspec/)
59
- module UsesTempFiles
60
- def self.included(example_group)
61
- example_group.extend(self)
62
- end
100
+ # module UsesTempFiles
101
+ # def self.included(example_group)
102
+ # example_group.extend(self)
103
+ # end
63
104
 
64
- def in_directory_with_file(file)
65
- before do
66
- @pwd = Dir.pwd
67
- @tmp_dir = File.join(File.dirname(__FILE__), 'tmp')
68
- FileUtils.mkdir_p(@tmp_dir)
69
- Dir.chdir(@tmp_dir)
105
+ # def in_directory_with_file(file)
106
+ # before do
107
+ # @pwd = Dir.pwd
108
+ # @tmp_dir = File.join(File.dirname(__FILE__), 'tmp')
109
+ # FileUtils.mkdir_p(@tmp_dir)
110
+ # Dir.chdir(@tmp_dir)
70
111
 
71
- FileUtils.mkdir_p(File.dirname(file))
72
- FileUtils.touch(file)
73
- end
112
+ # FileUtils.mkdir_p(File.dirname(file))
113
+ # FileUtils.touch(file)
114
+ # end
74
115
 
75
- define_method(:content_for_file) do |content|
76
- f = File.new(File.join(@tmp_dir, file), 'a+')
77
- f.write(content)
78
- f.flush # VERY IMPORTANT
79
- f.close
80
- end
116
+ # define_method(:content_for_file) do |content|
117
+ # f = File.new(File.join(@tmp_dir, file), 'a+')
118
+ # f.write(content)
119
+ # f.flush # VERY IMPORTANT
120
+ # f.close
121
+ # end
81
122
 
82
- after do
83
- Dir.chdir(@pwd)
84
- FileUtils.rm_rf(@tmp_dir)
85
- end
86
- end
87
- end
123
+ # after do
124
+ # Dir.chdir(@pwd)
125
+ # FileUtils.rm_rf(@tmp_dir)
126
+ # end
127
+ # end
128
+ # end