picky 0.2.4 → 0.3.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.
File without changes
File without changes
File without changes
File without changes
@@ -2,9 +2,35 @@ require 'spec_helper'
2
2
 
3
3
  describe Hash do
4
4
 
5
- describe 'dump_to' do
6
- it 'should description' do
7
- # TODO
5
+ describe 'dump_to_json' do
6
+ it 'uses the right file' do
7
+ File.should_receive(:open).once.with('some/file/path.json', 'w')
8
+
9
+ {}.dump_to_json 'some/file/path'
10
+ end
11
+ it "uses the right encoder" do
12
+ file = stub :file
13
+ File.should_receive(:open).and_yield file
14
+
15
+ Yajl::Encoder.should_receive(:encode).once.with({ :some => :hash }, file)
16
+
17
+ { :some => :hash }.dump_to_json 'unimportant'
18
+ end
19
+ end
20
+
21
+ describe 'dump_to_marshalled' do
22
+ it 'uses the right file' do
23
+ File.should_receive(:open).once.with('some/file/path.dump', 'w:binary')
24
+
25
+ {}.dump_to_marshalled 'some/file/path'
26
+ end
27
+ it "uses the right encoder" do
28
+ file = stub :file
29
+ File.should_receive(:open).and_yield file
30
+
31
+ Marshal.should_receive(:dump).once.with({ :some => :hash }, file)
32
+
33
+ { :some => :hash }.dump_to_marshalled 'unimportant'
8
34
  end
9
35
  end
10
36
 
@@ -10,7 +10,7 @@ describe Picky::Generator do
10
10
 
11
11
  describe "generator_for_class" do
12
12
  it "should return me a generator for the given class" do
13
- @generator.generator_for_class(Picky::Generator::Project, :some_args).should be_kind_of(Picky::Generator::Project)
13
+ @generator.generator_for_class(Picky::Generator::Project, :some_identifier, :some_args).should be_kind_of(Picky::Generator::Project)
14
14
  end
15
15
  end
16
16
 
@@ -41,14 +41,14 @@ describe Picky::Generator do
41
41
  describe Picky::Generator::Project do
42
42
 
43
43
  before(:each) do
44
- @generator = Picky::Generator::Project.new 'some_name', []
44
+ @generator = Picky::Generator::Project.new :identifier, 'some_name', []
45
45
  @generator.stub! :exclaim
46
46
  end
47
47
 
48
48
  context "after initialize" do
49
49
  it "should have a prototype project basedir" do
50
50
  lambda {
51
- @generator.prototype_project_basedir
51
+ @generator.project_prototype_basedir
52
52
  }.should_not raise_error
53
53
  end
54
54
  it "should have a name" do
@@ -56,9 +56,9 @@ describe Picky::Generator do
56
56
  end
57
57
  end
58
58
 
59
- describe "prototype_project_basedir" do
59
+ describe "project_prototype_basedir" do
60
60
  it "should be the right basedir" do
61
- @generator.prototype_project_basedir.should == File.expand_path('../../../prototype_project', __FILE__)
61
+ @generator.project_prototype_basedir.should == File.expand_path('../../../project_prototype', __FILE__)
62
62
  end
63
63
  end
64
64
 
@@ -115,7 +115,7 @@ describe Picky::Generator do
115
115
  it "should return the right filename" do
116
116
  @generator.stub! :target_directory => 'some_target_directory'
117
117
 
118
- test_filename = File.expand_path 'some/file/name', @generator.prototype_project_basedir
118
+ test_filename = File.expand_path 'some/file/name', @generator.project_prototype_basedir
119
119
 
120
120
  @generator.target_filename_for(test_filename).should == 'some_target_directory/some/file/name'
121
121
  end
@@ -69,6 +69,7 @@ describe Index::Bundle do
69
69
 
70
70
  describe 'load_from_index_file' do
71
71
  it 'should call two methods in order' do
72
+ @index.should_receive(:load_from_index_generation_message).once.ordered
72
73
  @index.should_receive(:clear).once.ordered
73
74
  @index.should_receive(:retrieve).once.ordered
74
75
 
@@ -94,13 +95,12 @@ describe Index::Bundle do
94
95
  end
95
96
  end
96
97
 
97
- describe 'generate_caches_from_db' do
98
+ describe 'generate_caches_from_source' do
98
99
  it 'should call two methods in order' do
99
- @index.should_receive(:cache_from_db_generation_message).once.ordered
100
100
  @index.should_receive(:load_from_index_file).once.ordered
101
101
  @index.should_receive(:generate_caches_from_memory).once.ordered
102
102
 
103
- @index.generate_caches_from_db
103
+ @index.generate_caches_from_source
104
104
  end
105
105
  end
106
106
 
@@ -197,30 +197,62 @@ describe Index::Bundle do
197
197
  @index.load
198
198
  end
199
199
  end
200
-
200
+ describe "loading indexes" do
201
+ before(:each) do
202
+ @index.stub! :timed_exclaim
203
+ end
204
+ describe "load_index" do
205
+ it "uses the right file" do
206
+ Yajl::Parser.stub! :parse
207
+
208
+ File.should_receive(:open).once.with 'some/search/root/index/test/some_type/some_name_some_category_index.json', 'r'
209
+
210
+ @index.load_index
211
+ end
212
+ end
213
+ describe "load_similarity" do
214
+ it "uses the right file" do
215
+ Marshal.stub! :load
216
+
217
+ File.should_receive(:open).once.with 'some/search/root/index/test/some_type/some_name_some_category_similarity.dump', 'r:binary'
218
+
219
+ @index.load_similarity
220
+ end
221
+ end
222
+ describe "load_weights" do
223
+ it "uses the right file" do
224
+ Yajl::Parser.stub! :parse
225
+
226
+ File.should_receive(:open).once.with 'some/search/root/index/test/some_type/some_name_some_category_weights.json', 'r'
227
+
228
+ @index.load_weights
229
+ end
230
+ end
231
+ end
232
+
201
233
  describe 'dump' do
202
234
  it 'should trigger dumps' do
203
235
  @index.should_receive(:dump_index).once.with
204
236
  @index.should_receive(:dump_similarity).once.with
205
237
  @index.should_receive(:dump_weights).once.with
206
-
238
+
207
239
  @index.dump
208
240
  end
209
241
  end
210
-
242
+
211
243
  describe 'weights_cache_path' do
212
244
  it 'should return the correct file name' do
213
- @index.weights_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_weights.json'
245
+ @index.weights_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_weights'
214
246
  end
215
247
  end
216
248
  describe 'similarity_cache_path' do
217
249
  it 'should return the correct file name' do
218
- @index.similarity_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_similarity.json'
250
+ @index.similarity_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_similarity'
219
251
  end
220
252
  end
221
253
  describe 'index_cache_path' do
222
254
  it 'should return the correct file name' do
223
- @index.index_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_index.json'
255
+ @index.index_cache_path.should == 'some/search/root/index/test/some_type/some_name_some_category_index'
224
256
  end
225
257
  end
226
258
 
@@ -170,11 +170,11 @@ describe Index::Category do
170
170
  end
171
171
  end
172
172
 
173
- describe 'generate_caches_from_db' do
173
+ describe 'generate_caches_from_source' do
174
174
  it 'should delegate to exact' do
175
- @exact.should_receive(:generate_caches_from_db).once.with
175
+ @exact.should_receive(:generate_caches_from_source).once.with
176
176
 
177
- @category.generate_caches_from_db
177
+ @category.generate_caches_from_source
178
178
  end
179
179
  end
180
180
 
@@ -183,7 +183,7 @@ describe Index::Category do
183
183
  @category.stub! :exclaim
184
184
  end
185
185
  it 'should call three method in order' do
186
- @category.should_receive(:generate_caches_from_db).once.with().ordered
186
+ @category.should_receive(:generate_caches_from_source).once.with().ordered
187
187
  @category.should_receive(:generate_partial).once.with().ordered
188
188
  @category.should_receive(:generate_caches_from_memory).once.with().ordered
189
189
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 4
9
- version: 0.2.4
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -129,19 +129,19 @@ files:
129
129
  - lib/tasks/statistics.rake
130
130
  - lib/tasks/try.rake
131
131
  - lib/picky/ext/ruby19/performant.c
132
- - prototype_project/app/application.rb
133
- - prototype_project/app/db.yml
134
- - prototype_project/app/logging.rb
135
- - prototype_project/app/README
136
- - prototype_project/config.ru
137
- - prototype_project/Gemfile
138
- - prototype_project/Gemfile.lock
139
- - prototype_project/log/README
140
- - prototype_project/Rakefile
141
- - prototype_project/script/console
142
- - prototype_project/tmp/pids/README
143
- - prototype_project/tmp/README
144
- - prototype_project/unicorn.ru
132
+ - project_prototype/app/application.rb
133
+ - project_prototype/app/db.yml
134
+ - project_prototype/app/library.csv
135
+ - project_prototype/app/logging.rb
136
+ - project_prototype/app/README
137
+ - project_prototype/config.ru
138
+ - project_prototype/Gemfile
139
+ - project_prototype/log/README
140
+ - project_prototype/Rakefile
141
+ - project_prototype/script/console
142
+ - project_prototype/tmp/pids/README
143
+ - project_prototype/tmp/README
144
+ - project_prototype/unicorn.ru
145
145
  - spec/ext/performant_spec.rb
146
146
  - spec/lib/application_spec.rb
147
147
  - spec/lib/cacher/partial/default_spec.rb
@@ -1,33 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activerecord (2.3.10)
5
- activesupport (= 2.3.10)
6
- activesupport (2.3.10)
7
- mysql (2.8.1)
8
- picky (0.2.3)
9
- rack (1.2.1)
10
- rack-mount (0.6.13)
11
- rack (>= 1.0.0)
12
- rack_fast_escape (2009.06.24)
13
- url_escape
14
- text (0.2.0)
15
- unicorn (1.1.4)
16
- rack
17
- url_escape (2009.06.24)
18
- yajl-ruby (0.7.8)
19
-
20
- PLATFORMS
21
- ruby
22
-
23
- DEPENDENCIES
24
- activerecord (~> 2.3.8)
25
- bundler (>= 0.9.26)
26
- mysql
27
- picky (~> 0.2.0)
28
- rack (~> 1.2.1)
29
- rack-mount (~> 0.6.9)
30
- rack_fast_escape (= 2009.06.24)
31
- text (~> 0.2.0)
32
- unicorn
33
- yajl-ruby (~> 0.7.8)