hastie 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.autotest +9 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +10 -0
  5. data/LICENSE +21 -0
  6. data/README.textile +136 -0
  7. data/Rakefile +1 -0
  8. data/bin/hastie +64 -0
  9. data/hastie.gemspec +31 -0
  10. data/lib/hastie/config_file.rb +42 -0
  11. data/lib/hastie/config_generator.rb +37 -0
  12. data/lib/hastie/constants.rb +25 -0
  13. data/lib/hastie/report_generator.rb +118 -0
  14. data/lib/hastie/report_publisher.rb +162 -0
  15. data/lib/hastie/report_updater.rb +40 -0
  16. data/lib/hastie/report_watcher.rb +65 -0
  17. data/lib/hastie/server_generator.rb +47 -0
  18. data/lib/hastie/server_reader.rb +81 -0
  19. data/lib/hastie/templates/hastie_config.tt +6 -0
  20. data/lib/hastie/templates/report.markdown.tt +19 -0
  21. data/lib/hastie/templates/report.textile.tt +19 -0
  22. data/lib/hastie/templates/report_index.html.tt +8 -0
  23. data/lib/hastie/templates/server/.gitignore +1 -0
  24. data/lib/hastie/templates/server/_config.yml +25 -0
  25. data/lib/hastie/templates/server/_includes/.gitignore +0 -0
  26. data/lib/hastie/templates/server/_layouts/.gitignore +0 -0
  27. data/lib/hastie/templates/server/_plugins/.gitignore +0 -0
  28. data/lib/hastie/templates/server/_posts/.gitignore +0 -0
  29. data/lib/hastie/templates/server/_reports.yml +0 -0
  30. data/lib/hastie/templates/server/_server_config.yml +15 -0
  31. data/lib/hastie/templates/server/css/.gitignore +0 -0
  32. data/lib/hastie/templates/server/data/.gitignore +0 -0
  33. data/lib/hastie/templates/server/imgs/.gitignore +0 -0
  34. data/lib/hastie/templates/server/index.html +0 -0
  35. data/lib/hastie/templates/server/js/.gitignore +0 -0
  36. data/lib/hastie/version.rb +3 -0
  37. data/lib/hastie.rb +15 -0
  38. data/spec/config_generator_spec.rb +124 -0
  39. data/spec/fakefs_helper.rb +67 -0
  40. data/spec/fixtures/config.ru +29 -0
  41. data/spec/fixtures/hastie_config +2 -0
  42. data/spec/fixtures/report/2110-12-16-report.textile +19 -0
  43. data/spec/fixtures/report/_config.yml +9 -0
  44. data/spec/fixtures/report/data/report/.gitignore +0 -0
  45. data/spec/fixtures/report/imgs/report/.gitignore +0 -0
  46. data/spec/fixtures/report/js/.gitignore +0 -0
  47. data/spec/fixtures/report/report.yml +23 -0
  48. data/spec/fixtures/server/_config.yml +10 -0
  49. data/spec/fixtures/server/_posts/2011-11-11-jfv_mak_snp_analysis.textile +0 -0
  50. data/spec/fixtures/server/_reports.yml +1 -0
  51. data/spec/fixtures/server/css/style.css +126 -0
  52. data/spec/fixtures/server/data/jfv_mak_snp_analysis/.gitignore +0 -0
  53. data/spec/fixtures/server/imgs/favicon.ico +0 -0
  54. data/spec/fixtures/server/imgs/subset_images/.gitignore +0 -0
  55. data/spec/fixtures/server/js/.gitignore +0 -0
  56. data/spec/report_generator_spec.rb +168 -0
  57. data/spec/report_publisher_spec.rb +148 -0
  58. data/spec/report_updater_spec.rb +54 -0
  59. data/spec/report_watcher_spec.rb +99 -0
  60. data/spec/server_generator_spec.rb +68 -0
  61. data/spec/server_reader_spec.rb +120 -0
  62. data/spec/spec_helper.rb +52 -0
  63. metadata +234 -0
@@ -0,0 +1,120 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/fakefs_helper')
3
+ require 'hastie/server_reader'
4
+ require 'hastie/constants'
5
+
6
+ class ServerReaderChild < Hastie::ServerReader
7
+ no_tasks do
8
+ def config_file
9
+ FakeFsHelper::CONFIG_FILE
10
+ end
11
+ end
12
+
13
+ def output_options
14
+ options
15
+ end
16
+ end
17
+
18
+ describe Hastie::ServerReader, fakefs: true do
19
+ it "should take config_file as input parameter" do
20
+ other_config_file = "/tmp/temp_config_file"
21
+ other_dir = "/tmp/server_dir_path"
22
+ FakeFsHelper.stub_config_file other_config_file, other_dir
23
+ FakeFsHelper.stub_server_dir other_dir
24
+ FakeFsHelper.stub_server_config other_dir
25
+ FakeFsHelper.stub_reports_file other_dir
26
+
27
+ input = ["--config_file", other_config_file]
28
+ output = Hastie::ServerReader.start input
29
+ last_output = output[-1]
30
+ last_output["config_file"].should == other_config_file
31
+ end
32
+ end
33
+
34
+ describe Hastie::ServerReader do
35
+ it "should read from config file on real file system" do
36
+ config_file = File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "hastie_config"))
37
+ server_dir = File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "server"))
38
+ input = ["--config_file", config_file, "--server_root", server_dir]
39
+ content = capture(:stdout) do
40
+ lambda { Hastie::ServerReader.start input }.should_not raise_error SystemExit
41
+ end
42
+ content.should match /#{config_file}/
43
+ content.should match /#{server_dir}/
44
+ end
45
+ end
46
+
47
+ describe ServerReaderChild, fakefs: true do
48
+ describe "missing config file" do
49
+ it "should report missing config file and exit" do
50
+ content = capture(:stdout) do
51
+ lambda { ServerReaderChild.start }.should raise_error SystemExit
52
+ end
53
+ content.should match /[Nn]o config file found/
54
+ end
55
+ end
56
+
57
+ describe "missing server dir" do
58
+ before :each do
59
+ FakeFsHelper.stub_config_file
60
+ end
61
+
62
+ it "should report missing server dir and exit" do
63
+ File.exists?(FakeFsHelper::CONFIG_FILE).should == true
64
+ content = capture(:stdout) do
65
+ lambda { ServerReaderChild.start }.should raise_error SystemExit
66
+ end
67
+ content.should match /[Cc]annot find server/
68
+ end
69
+ end
70
+
71
+ describe "valid server dir" do
72
+ before :each do
73
+ FakeFsHelper.stub_config_file
74
+ FakeFsHelper.stub_server_dir
75
+ File.directory?(FakeFsHelper::SERVER_DIR).should == true
76
+ end
77
+
78
+ it "should report missing server config and exit" do
79
+ content = capture(:stdout) do
80
+ lambda { ServerReaderChild.start }.should raise_error SystemExit
81
+ end
82
+ content.should match /[Cc]annot find #{Hastie::SERVER_CONFIG_FILE} file in server/
83
+ end
84
+
85
+ it "should report missing reports.yml file and exit" do
86
+ FakeFsHelper.stub_server_config
87
+ content = capture(:stdout) do
88
+ lambda { ServerReaderChild.start }.should raise_error SystemExit
89
+ end
90
+ content.should match /[Cc]annot find #{Hastie::SERVER_REPORTS_FILE} file/
91
+ end
92
+
93
+ it "should report options when all required files are present" do
94
+ FakeFsHelper.stub_server_config
95
+ FakeFsHelper.stub_reports_file
96
+ content = capture(:stdout) do
97
+ lambda { ServerReaderChild.start }.should_not raise_error SystemExit
98
+ end
99
+ output = []
100
+ content = capture(:stdout) { output = ServerReaderChild.start }
101
+ last_output = output[-1]
102
+ last_output["server_root"].should == FakeFsHelper::SERVER_DIR
103
+ end
104
+
105
+ end
106
+ it "should take server_root as input parameter" do
107
+ FakeFsHelper.stub_config_file
108
+ new_dir = "/another/path/to/server"
109
+
110
+ FakeFsHelper.stub_server_dir new_dir
111
+ FakeFsHelper.stub_server_config new_dir
112
+ FakeFsHelper.stub_reports_file new_dir
113
+
114
+ input = ["--server_root", new_dir]
115
+ output = []
116
+ content = capture(:stdout) { output = ServerReaderChild.start input}
117
+ last_output = output[-1]
118
+ last_output["server_root"].should == new_dir
119
+ end
120
+ end
@@ -0,0 +1,52 @@
1
+ $TESTING=true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_group 'Libraries', 'lib'
6
+ add_group 'Specs', 'spec'
7
+ end
8
+
9
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
10
+ require 'hastie/report_generator'
11
+ require 'hastie/report_publisher'
12
+
13
+ require 'stringio'
14
+
15
+ require 'rdoc'
16
+ require 'rspec'
17
+
18
+ require 'fakefs/spec_helpers'
19
+
20
+ ARGV.clear
21
+
22
+ RSpec.configure do |config|
23
+ config.include FakeFS::SpecHelpers, fakefs: true
24
+
25
+ config.before :each do
26
+ ARGV.replace []
27
+ end
28
+
29
+ def capture(stream)
30
+ begin
31
+ stream = stream.to_s
32
+ eval "$#{stream} = StringIO.new"
33
+ yield
34
+ result = eval("$#{stream}").string
35
+ ensure
36
+ eval("$#{stream} = #{stream.upcase}")
37
+ end
38
+
39
+ result
40
+ end
41
+
42
+ def source_root
43
+ File.join(File.dirname(__FILE__), 'fixtures')
44
+ end
45
+
46
+ def destination_root
47
+ File.join(File.dirname(__FILE__), 'sandbox')
48
+ end
49
+
50
+ alias :silence :capture
51
+ end
52
+
metadata ADDED
@@ -0,0 +1,234 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hastie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jim Vallandingham
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &3725550 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.14.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *3725550
25
+ - !ruby/object:Gem::Dependency
26
+ name: grit
27
+ requirement: &3725300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.4.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *3725300
36
+ - !ruby/object:Gem::Dependency
37
+ name: sinatra
38
+ requirement: &3725070 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *3725070
47
+ - !ruby/object:Gem::Dependency
48
+ name: thin
49
+ requirement: &3724840 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.1
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *3724840
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &3724610 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '1.0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *3724610
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: &3724380 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '3.9'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *3724380
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &3724150 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '2.3'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *3724150
91
+ - !ruby/object:Gem::Dependency
92
+ name: simplecov
93
+ requirement: &3723920 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '0.4'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *3723920
102
+ - !ruby/object:Gem::Dependency
103
+ name: ZenTest
104
+ requirement: &3723690 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 4.5.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *3723690
113
+ description: ''
114
+ email: none@none.com
115
+ executables:
116
+ - hastie
117
+ extensions: []
118
+ extra_rdoc_files:
119
+ - LICENSE
120
+ - README.textile
121
+ files:
122
+ - .autotest
123
+ - .gitignore
124
+ - .rspec
125
+ - Gemfile
126
+ - LICENSE
127
+ - README.textile
128
+ - Rakefile
129
+ - bin/hastie
130
+ - hastie.gemspec
131
+ - lib/hastie.rb
132
+ - lib/hastie/config_file.rb
133
+ - lib/hastie/config_generator.rb
134
+ - lib/hastie/constants.rb
135
+ - lib/hastie/report_generator.rb
136
+ - lib/hastie/report_publisher.rb
137
+ - lib/hastie/report_updater.rb
138
+ - lib/hastie/report_watcher.rb
139
+ - lib/hastie/server_generator.rb
140
+ - lib/hastie/server_reader.rb
141
+ - lib/hastie/templates/hastie_config.tt
142
+ - lib/hastie/templates/report.markdown.tt
143
+ - lib/hastie/templates/report.textile.tt
144
+ - lib/hastie/templates/report_index.html.tt
145
+ - lib/hastie/templates/server/.gitignore
146
+ - lib/hastie/templates/server/_config.yml
147
+ - lib/hastie/templates/server/_includes/.gitignore
148
+ - lib/hastie/templates/server/_layouts/.gitignore
149
+ - lib/hastie/templates/server/_plugins/.gitignore
150
+ - lib/hastie/templates/server/_posts/.gitignore
151
+ - lib/hastie/templates/server/_reports.yml
152
+ - lib/hastie/templates/server/_server_config.yml
153
+ - lib/hastie/templates/server/css/.gitignore
154
+ - lib/hastie/templates/server/data/.gitignore
155
+ - lib/hastie/templates/server/imgs/.gitignore
156
+ - lib/hastie/templates/server/index.html
157
+ - lib/hastie/templates/server/js/.gitignore
158
+ - lib/hastie/version.rb
159
+ - spec/config_generator_spec.rb
160
+ - spec/fakefs_helper.rb
161
+ - spec/fixtures/config.ru
162
+ - spec/fixtures/hastie_config
163
+ - spec/fixtures/report/2110-12-16-report.textile
164
+ - spec/fixtures/report/_config.yml
165
+ - spec/fixtures/report/data/report/.gitignore
166
+ - spec/fixtures/report/imgs/report/.gitignore
167
+ - spec/fixtures/report/js/.gitignore
168
+ - spec/fixtures/report/report.yml
169
+ - spec/fixtures/server/_config.yml
170
+ - spec/fixtures/server/_posts/2011-11-11-jfv_mak_snp_analysis.textile
171
+ - spec/fixtures/server/_reports.yml
172
+ - spec/fixtures/server/css/style.css
173
+ - spec/fixtures/server/data/jfv_mak_snp_analysis/.gitignore
174
+ - spec/fixtures/server/imgs/favicon.ico
175
+ - spec/fixtures/server/imgs/subset_images/.gitignore
176
+ - spec/fixtures/server/js/.gitignore
177
+ - spec/report_generator_spec.rb
178
+ - spec/report_publisher_spec.rb
179
+ - spec/report_updater_spec.rb
180
+ - spec/report_watcher_spec.rb
181
+ - spec/server_generator_spec.rb
182
+ - spec/server_reader_spec.rb
183
+ - spec/spec_helper.rb
184
+ homepage: http://github.com/vlandham/hastie
185
+ licenses: []
186
+ post_install_message:
187
+ rdoc_options:
188
+ - --charset=UTF-8
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ! '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: 1.3.6
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 1.8.5
206
+ signing_key:
207
+ specification_version: 3
208
+ summary: ''
209
+ test_files:
210
+ - spec/config_generator_spec.rb
211
+ - spec/fakefs_helper.rb
212
+ - spec/fixtures/config.ru
213
+ - spec/fixtures/hastie_config
214
+ - spec/fixtures/report/2110-12-16-report.textile
215
+ - spec/fixtures/report/_config.yml
216
+ - spec/fixtures/report/data/report/.gitignore
217
+ - spec/fixtures/report/imgs/report/.gitignore
218
+ - spec/fixtures/report/js/.gitignore
219
+ - spec/fixtures/report/report.yml
220
+ - spec/fixtures/server/_config.yml
221
+ - spec/fixtures/server/_posts/2011-11-11-jfv_mak_snp_analysis.textile
222
+ - spec/fixtures/server/_reports.yml
223
+ - spec/fixtures/server/css/style.css
224
+ - spec/fixtures/server/data/jfv_mak_snp_analysis/.gitignore
225
+ - spec/fixtures/server/imgs/favicon.ico
226
+ - spec/fixtures/server/imgs/subset_images/.gitignore
227
+ - spec/fixtures/server/js/.gitignore
228
+ - spec/report_generator_spec.rb
229
+ - spec/report_publisher_spec.rb
230
+ - spec/report_updater_spec.rb
231
+ - spec/report_watcher_spec.rb
232
+ - spec/server_generator_spec.rb
233
+ - spec/server_reader_spec.rb
234
+ - spec/spec_helper.rb