puzzlize 0.0.1

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.
Files changed (55) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +61 -0
  4. data/CHANGELOG +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +7 -0
  7. data/README.md +76 -0
  8. data/Rakefile +5 -0
  9. data/lib/puzzlize.rb +6 -0
  10. data/lib/puzzlize/action_view_helpers.rb +89 -0
  11. data/lib/puzzlize/cutter.rb +199 -0
  12. data/lib/puzzlize/model_additions.rb +18 -0
  13. data/lib/puzzlize/model_instance_methods.rb +125 -0
  14. data/lib/puzzlize/railtie.rb +17 -0
  15. data/lib/puzzlize/schema.rb +26 -0
  16. data/lib/puzzlize/version.rb +3 -0
  17. data/puzzlize.gemspec +26 -0
  18. data/spec/puzzlize/cutter_spec.rb +198 -0
  19. data/spec/puzzlize/model_additions_spec.rb +30 -0
  20. data/spec/puzzlize_spec.rb +50 -0
  21. data/spec/spec_helper.rb +3 -0
  22. data/spec/support/correct/regular_photo-0_0.gif +0 -0
  23. data/spec/support/correct/regular_photo-0_1.gif +0 -0
  24. data/spec/support/correct/regular_photo-1_0.gif +0 -0
  25. data/spec/support/correct/regular_photo-1_1.gif +0 -0
  26. data/spec/support/correct/regular_photo-2_0.gif +0 -0
  27. data/spec/support/correct/regular_photo-2_1.gif +0 -0
  28. data/spec/support/correct/regular_photo-3_0.gif +0 -0
  29. data/spec/support/correct/regular_photo-3_1.gif +0 -0
  30. data/spec/support/correct/regular_photo.jpg +0 -0
  31. data/spec/support/correct/simple_sample-0_0.gif +0 -0
  32. data/spec/support/correct/simple_sample-0_1.gif +0 -0
  33. data/spec/support/correct/simple_sample-0_2.gif +0 -0
  34. data/spec/support/correct/simple_sample-0_3.gif +0 -0
  35. data/spec/support/correct/simple_sample-1_0.gif +0 -0
  36. data/spec/support/correct/simple_sample-1_1.gif +0 -0
  37. data/spec/support/correct/simple_sample-1_2.gif +0 -0
  38. data/spec/support/correct/simple_sample-1_3.gif +0 -0
  39. data/spec/support/correct/simple_sample-2_0.gif +0 -0
  40. data/spec/support/correct/simple_sample-2_1.gif +0 -0
  41. data/spec/support/correct/simple_sample-2_2.gif +0 -0
  42. data/spec/support/correct/simple_sample-2_3.gif +0 -0
  43. data/spec/support/correct/simple_sample-3_0.gif +0 -0
  44. data/spec/support/correct/simple_sample-3_1.gif +0 -0
  45. data/spec/support/correct/simple_sample-3_2.gif +0 -0
  46. data/spec/support/correct/simple_sample-3_3.gif +0 -0
  47. data/spec/support/correct/simple_sample.jpg +0 -0
  48. data/spec/support/images/sample_image.png +0 -0
  49. data/spec/support/made/.DS_Store +0 -0
  50. data/spec/support/made/.gitignore +0 -0
  51. data/spec/support/made/regular_photo.jpg +0 -0
  52. data/spec/support/made/simple_sample.jpg +0 -0
  53. data/spec/support/regular_photo.jpg +0 -0
  54. data/spec/support/simple_sample.jpg +0 -0
  55. metadata +223 -0
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ class Puzzle < SuperModel::Base
4
+ extend Puzzlize::ModelAdditions
5
+ puzzlize :puzzle
6
+
7
+ #patch for to avoid paperclip
8
+ @@image_path_location = ""
9
+
10
+ def default_puzzle_image_path
11
+ @@image_path_location
12
+ end
13
+
14
+ def self.image_path_location=(path)
15
+ @@image_path_location = path
16
+ end
17
+ end
18
+
19
+ describe "puzzlize" do
20
+
21
+ it "test should create a whole puzzle using a square image" do
22
+ root = Dir.getwd
23
+ Puzzle.image_path_location = "#{root}/spec/support/made/simple_sample.jpg"
24
+ img_handle = Puzzle.new({:image => File.new(root + '/spec/support/simple_sample.jpg')})
25
+ img_handle.save.should == true
26
+ id = img_handle.id.to_s
27
+ 4.times do |x|
28
+ 4.times do |y|
29
+ File.size(File.join(root, "spec", "support", "made", "simple_sample-#{x}_#{y}.gif")).to_s.should == File.size(File.join(root, "spec", "support", "correct", "simple_sample-#{x}_#{y}.gif")).to_s
30
+ end
31
+ end
32
+ `cd #{root}/spec/support/made/ && rm -rf simple_sample-*`
33
+ end
34
+
35
+ it "test should create a whole puzzle using regular photo" do
36
+ root = Dir.getwd
37
+
38
+ # instead adding paperclip to the test, we stub out the method that we usually use paperclip for.
39
+ Puzzle.image_path_location = "#{root}/spec/support/made/regular_photo.jpg"
40
+ img_handle = Puzzle.create!({:image => File.new(root + '/spec/support/regular_photo.jpg')})
41
+ id = img_handle.id.to_s
42
+ 4.times do |x|
43
+ 2.times do |y|
44
+ File.size(File.join(root, "spec", "support", "made", "regular_photo-#{x}_#{y}.gif")).to_s.should == File.size(File.join(root, "spec", "support", "correct", "regular_photo-#{x}_#{y}.gif")).to_s
45
+ end
46
+ end
47
+ `cd #{root}/spec/support/made/ && rm -rf regular_photo-*`
48
+ end
49
+
50
+ end
@@ -0,0 +1,3 @@
1
+ require "puzzlize"
2
+ require "super_model"
3
+ require "rmagick"
Binary file
File without changes
Binary file
Binary file
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puzzlize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ziemek Wolski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: supermodel
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: paperclip
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rmagick
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: This gem is made up off two libraries. A cutter library - determines
95
+ all the points to cut. Rmagick rapper, which actually cuts up the images.
96
+ email:
97
+ - ziemek.wolski+gem@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - .rspec
104
+ - .rvmrc
105
+ - CHANGELOG
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - lib/puzzlize.rb
111
+ - lib/puzzlize/action_view_helpers.rb
112
+ - lib/puzzlize/cutter.rb
113
+ - lib/puzzlize/model_additions.rb
114
+ - lib/puzzlize/model_instance_methods.rb
115
+ - lib/puzzlize/railtie.rb
116
+ - lib/puzzlize/schema.rb
117
+ - lib/puzzlize/version.rb
118
+ - puzzlize.gemspec
119
+ - spec/puzzlize/cutter_spec.rb
120
+ - spec/puzzlize/model_additions_spec.rb
121
+ - spec/puzzlize_spec.rb
122
+ - spec/spec_helper.rb
123
+ - spec/support/correct/regular_photo-0_0.gif
124
+ - spec/support/correct/regular_photo-0_1.gif
125
+ - spec/support/correct/regular_photo-1_0.gif
126
+ - spec/support/correct/regular_photo-1_1.gif
127
+ - spec/support/correct/regular_photo-2_0.gif
128
+ - spec/support/correct/regular_photo-2_1.gif
129
+ - spec/support/correct/regular_photo-3_0.gif
130
+ - spec/support/correct/regular_photo-3_1.gif
131
+ - spec/support/correct/regular_photo.jpg
132
+ - spec/support/correct/simple_sample-0_0.gif
133
+ - spec/support/correct/simple_sample-0_1.gif
134
+ - spec/support/correct/simple_sample-0_2.gif
135
+ - spec/support/correct/simple_sample-0_3.gif
136
+ - spec/support/correct/simple_sample-1_0.gif
137
+ - spec/support/correct/simple_sample-1_1.gif
138
+ - spec/support/correct/simple_sample-1_2.gif
139
+ - spec/support/correct/simple_sample-1_3.gif
140
+ - spec/support/correct/simple_sample-2_0.gif
141
+ - spec/support/correct/simple_sample-2_1.gif
142
+ - spec/support/correct/simple_sample-2_2.gif
143
+ - spec/support/correct/simple_sample-2_3.gif
144
+ - spec/support/correct/simple_sample-3_0.gif
145
+ - spec/support/correct/simple_sample-3_1.gif
146
+ - spec/support/correct/simple_sample-3_2.gif
147
+ - spec/support/correct/simple_sample-3_3.gif
148
+ - spec/support/correct/simple_sample.jpg
149
+ - spec/support/images/sample_image.png
150
+ - spec/support/made/.DS_Store
151
+ - spec/support/made/.gitignore
152
+ - spec/support/made/regular_photo.jpg
153
+ - spec/support/made/simple_sample.jpg
154
+ - spec/support/regular_photo.jpg
155
+ - spec/support/simple_sample.jpg
156
+ homepage: https://github.com/ziemekwolski/puzzlize
157
+ licenses: []
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ segments:
169
+ - 0
170
+ hash: 26816253885957104
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ segments:
178
+ - 0
179
+ hash: 26816253885957104
180
+ requirements: []
181
+ rubyforge_project: puzzlize
182
+ rubygems_version: 1.8.19
183
+ signing_key:
184
+ specification_version: 3
185
+ summary: Gem created a puzzle using images from a predefined image on a model.
186
+ test_files:
187
+ - spec/puzzlize/cutter_spec.rb
188
+ - spec/puzzlize/model_additions_spec.rb
189
+ - spec/puzzlize_spec.rb
190
+ - spec/spec_helper.rb
191
+ - spec/support/correct/regular_photo-0_0.gif
192
+ - spec/support/correct/regular_photo-0_1.gif
193
+ - spec/support/correct/regular_photo-1_0.gif
194
+ - spec/support/correct/regular_photo-1_1.gif
195
+ - spec/support/correct/regular_photo-2_0.gif
196
+ - spec/support/correct/regular_photo-2_1.gif
197
+ - spec/support/correct/regular_photo-3_0.gif
198
+ - spec/support/correct/regular_photo-3_1.gif
199
+ - spec/support/correct/regular_photo.jpg
200
+ - spec/support/correct/simple_sample-0_0.gif
201
+ - spec/support/correct/simple_sample-0_1.gif
202
+ - spec/support/correct/simple_sample-0_2.gif
203
+ - spec/support/correct/simple_sample-0_3.gif
204
+ - spec/support/correct/simple_sample-1_0.gif
205
+ - spec/support/correct/simple_sample-1_1.gif
206
+ - spec/support/correct/simple_sample-1_2.gif
207
+ - spec/support/correct/simple_sample-1_3.gif
208
+ - spec/support/correct/simple_sample-2_0.gif
209
+ - spec/support/correct/simple_sample-2_1.gif
210
+ - spec/support/correct/simple_sample-2_2.gif
211
+ - spec/support/correct/simple_sample-2_3.gif
212
+ - spec/support/correct/simple_sample-3_0.gif
213
+ - spec/support/correct/simple_sample-3_1.gif
214
+ - spec/support/correct/simple_sample-3_2.gif
215
+ - spec/support/correct/simple_sample-3_3.gif
216
+ - spec/support/correct/simple_sample.jpg
217
+ - spec/support/images/sample_image.png
218
+ - spec/support/made/.DS_Store
219
+ - spec/support/made/.gitignore
220
+ - spec/support/made/regular_photo.jpg
221
+ - spec/support/made/simple_sample.jpg
222
+ - spec/support/regular_photo.jpg
223
+ - spec/support/simple_sample.jpg