montage 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.document +5 -0
  2. data/.gitignore +31 -0
  3. data/History.md +40 -0
  4. data/LICENSE +19 -0
  5. data/README.md +89 -0
  6. data/Rakefile +41 -0
  7. data/VERSION +1 -0
  8. data/bin/montage +22 -0
  9. data/lib/montage.rb +33 -0
  10. data/lib/montage/commands.rb +32 -0
  11. data/lib/montage/commands/generate.rb +234 -0
  12. data/lib/montage/commands/init.rb +119 -0
  13. data/lib/montage/core_ext.rb +80 -0
  14. data/lib/montage/project.rb +185 -0
  15. data/lib/montage/sass_builder.rb +37 -0
  16. data/lib/montage/source.rb +75 -0
  17. data/lib/montage/sprite.rb +132 -0
  18. data/lib/montage/templates/montage.yml +26 -0
  19. data/lib/montage/templates/sass_mixins.erb +20 -0
  20. data/lib/montage/templates/sources/book.png +0 -0
  21. data/lib/montage/templates/sources/box-label.png +0 -0
  22. data/lib/montage/templates/sources/calculator.png +0 -0
  23. data/lib/montage/templates/sources/calendar-month.png +0 -0
  24. data/lib/montage/templates/sources/camera.png +0 -0
  25. data/lib/montage/templates/sources/eraser.png +0 -0
  26. data/lib/montage/version.rb +3 -0
  27. data/montage.gemspec +145 -0
  28. data/spec/fixtures/custom_dirs/montage.yml +8 -0
  29. data/spec/fixtures/default/montage.yml +7 -0
  30. data/spec/fixtures/default/public/images/sprites/src/one.png +0 -0
  31. data/spec/fixtures/default/public/images/sprites/src/three.png +0 -0
  32. data/spec/fixtures/default/public/images/sprites/src/two.png +0 -0
  33. data/spec/fixtures/directory_config/config/montage.yml +5 -0
  34. data/spec/fixtures/missing_source/montage.yml +3 -0
  35. data/spec/fixtures/missing_source_dir/montage.yml +5 -0
  36. data/spec/fixtures/root_config/montage.yml +5 -0
  37. data/spec/fixtures/root_config/public/images/sprites/src/source_one.png +0 -0
  38. data/spec/fixtures/root_config/public/images/sprites/src/source_three.jpg +0 -0
  39. data/spec/fixtures/root_config/public/images/sprites/src/source_two +0 -0
  40. data/spec/fixtures/sources/hundred.png +0 -0
  41. data/spec/fixtures/sources/mammoth.png +0 -0
  42. data/spec/fixtures/sources/other.png +0 -0
  43. data/spec/fixtures/sources/twenty.png +0 -0
  44. data/spec/fixtures/subdirs/montage.yml +5 -0
  45. data/spec/fixtures/subdirs/sub/sub/keep +0 -0
  46. data/spec/lib/command_runner.rb +140 -0
  47. data/spec/lib/fixtures.rb +7 -0
  48. data/spec/lib/have_public_method_defined.rb +19 -0
  49. data/spec/lib/project_helper.rb +135 -0
  50. data/spec/lib/shared_project_specs.rb +32 -0
  51. data/spec/lib/shared_sprite_specs.rb +30 -0
  52. data/spec/montage/commands/generate_spec.rb +308 -0
  53. data/spec/montage/commands/init_spec.rb +120 -0
  54. data/spec/montage/core_ext_spec.rb +33 -0
  55. data/spec/montage/project_spec.rb +181 -0
  56. data/spec/montage/sass_builder_spec.rb +269 -0
  57. data/spec/montage/source_spec.rb +53 -0
  58. data/spec/montage/spec/have_public_method_defined_spec.rb +31 -0
  59. data/spec/montage/sprite_spec.rb +170 -0
  60. data/spec/rcov.opts +8 -0
  61. data/spec/spec.opts +4 -0
  62. data/spec/spec_helper.rb +19 -0
  63. data/tasks/spec.rake +17 -0
  64. data/tasks/yard.rake +11 -0
  65. metadata +249 -0
@@ -0,0 +1,53 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Montage::Source do
4
+ subject { Montage::Source }
5
+
6
+ # --- path -----------------------------------------------------------------
7
+
8
+ it { should have_public_method_defined(:path) }
9
+
10
+ describe '#path' do
11
+ before(:each) do
12
+ @helper = Montage::Spec::ProjectHelper.new
13
+ @helper.write_config <<-CONFIG
14
+ ---
15
+ sprite_one:
16
+ - one
17
+ - two
18
+ CONFIG
19
+
20
+ @helper.write_source('one', 100, 25)
21
+ @helper.write_source('two', 100, 25)
22
+ end
23
+
24
+ it 'should return the path when the source file exists' do
25
+ name = @helper.project.sprites.first.sources.first.name
26
+
27
+ source = Montage::Source.new(@helper.project.paths.sources, name, 'nm')
28
+ source.path.should == @helper.project.paths.sources + "#{name}.png"
29
+ end
30
+
31
+ it 'should raise an error when the source file does not exist' do
32
+ running = lambda {
33
+ Montage::Source.new(
34
+ @helper.project.paths.sources, '__invalid__', 'nm').path
35
+ }
36
+
37
+ running.should raise_error(Montage::MissingSource,
38
+ /Couldn't find a matching file/)
39
+ end
40
+
41
+ it 'should raise an error when the source directory does not exist' do
42
+ name = @helper.project.sprites.first.sources.first.name
43
+
44
+ running = lambda {
45
+ Montage::Source.new(Pathname.new('__invalid__'), name, 'nm').path
46
+ }
47
+
48
+ running.should raise_error(Montage::MissingSource,
49
+ /Couldn't find the source directory/)
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe 'have_public_method_defined matcher' do
4
+ before(:all) do
5
+ @exception = Spec::Expectations::ExpectationNotMetError
6
+ end
7
+
8
+ describe 'with should' do
9
+ it 'should pass when the method is defined' do
10
+ running = lambda { String.should have_public_method_defined(:length) }
11
+ running.should_not raise_exception(@exception)
12
+ end
13
+
14
+ it 'should fail when the method is not defined' do
15
+ running = lambda { String.should have_public_method_defined(:__invalid__) }
16
+ running.should raise_exception(@exception)
17
+ end
18
+ end
19
+
20
+ describe 'with should_not' do
21
+ it 'should fail when the method is defined' do
22
+ running = lambda { String.should_not have_public_method_defined(:length) }
23
+ running.should raise_exception(@exception)
24
+ end
25
+
26
+ it 'should pass when the method is not defined' do
27
+ running = lambda { String.should_not have_public_method_defined(:__invalid__) }
28
+ running.should_not raise_exception(@exception)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,170 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Montage::Sprite do
4
+ subject { Montage::Sprite }
5
+
6
+ # --- images ---------------------------------------------------------------
7
+
8
+ it { should have_public_method_defined(:images) }
9
+
10
+ describe '#images' do
11
+ before(:each) do
12
+ @helper = Montage::Spec::ProjectHelper.new
13
+ @helper.write_config <<-CONFIG
14
+ ---
15
+ sprite_one:
16
+ - one
17
+ - two
18
+ CONFIG
19
+
20
+ @helper.write_source('one', 100, 25)
21
+ @helper.write_source('two', 100, 25)
22
+
23
+ @sprite = @helper.project.sprite('sprite_one')
24
+ end
25
+
26
+ describe 'when the sprite contains no sources' do
27
+ before(:each) do
28
+ @sprite = Montage::Sprite.new('sprite', [],
29
+ @helper.project.paths.sources)
30
+ end
31
+
32
+ it 'should return an array' do
33
+ @sprite.images.should be_kind_of(Array)
34
+ end
35
+
36
+ it 'should be empty' do
37
+ @sprite.images.should be_empty
38
+ end
39
+ end
40
+
41
+ describe 'when the sprite contains two sources' do
42
+ it 'should return an array' do
43
+ @sprite.images.should be_kind_of(Array)
44
+ @sprite.images.should have(2).images
45
+ end
46
+
47
+ it 'should contain Magick::Image instances' do
48
+ @sprite.images.each { |i| i.should be_kind_of(Magick::Image) }
49
+ end
50
+ end
51
+ end
52
+
53
+ # --- position_of ----------------------------------------------------------
54
+
55
+ it { should have_public_method_defined(:position_of) }
56
+
57
+ describe '#position_of' do
58
+ before(:each) do
59
+ @helper = Montage::Spec::ProjectHelper.new
60
+ @helper.write_config <<-CONFIG
61
+ ---
62
+ sprite_one:
63
+ - one
64
+ - two
65
+ CONFIG
66
+
67
+ @helper.write_source('one', 100, 25)
68
+ @helper.write_source('two', 100, 25)
69
+
70
+ @sprite = @helper.project.sprite('sprite_one')
71
+ end
72
+
73
+ it 'should raise a MissingSource when the given source is not present' do
74
+ running = lambda { @sprite.position_of('__invalid__') }
75
+ running.should raise_error(Montage::MissingSource,
76
+ /'__invalid__' is not present in the 'sprite_one' sprite/)
77
+ end
78
+
79
+ it 'should return an integer' do
80
+ @sprite.position_of('one').should == 0
81
+ end
82
+
83
+ it 'should account for the padding' do
84
+ # 25px source, plus 20px padding
85
+ @sprite.position_of('two').should == 45
86
+ end
87
+
88
+ it 'should accept a Source instance' do
89
+ @sprite.position_of(@sprite.sources.first).should == 0
90
+ end
91
+ end
92
+
93
+ # --- digest ---------------------------------------------------------------
94
+
95
+ it { should have_public_method_defined(:digest) }
96
+
97
+ describe '#digest' do
98
+ before(:each) do
99
+ @helper = Montage::Spec::ProjectHelper.new
100
+ @helper.write_config <<-CONFIG
101
+ ---
102
+ sprite_one:
103
+ - one
104
+ - two
105
+
106
+ sprite_two:
107
+ - three
108
+ CONFIG
109
+
110
+ @helper.write_source('one', 100, 25)
111
+ @helper.write_source('two', 100, 25)
112
+ @helper.write_source('three', 100, 25)
113
+ end
114
+
115
+ it 'should return a string' do
116
+ @helper.project.sprites.first.digest.should be_a(String)
117
+ end
118
+
119
+ context 'when changing the source order for a sprite' do
120
+ before(:each) do
121
+ @sprite_one_digest = @helper.project.sprite('sprite_one').digest
122
+ @sprite_two_digest = @helper.project.sprite('sprite_two').digest
123
+ @helper.write_config <<-CONFIG
124
+ ---
125
+ sprite_one:
126
+ - two
127
+ - one
128
+
129
+ sprite_two:
130
+ - three
131
+ CONFIG
132
+ end
133
+
134
+ it 'should return something different when it is affected' do
135
+ @helper.project.sprite('sprite_one').digest.should_not ==
136
+ @sprite_one_digest
137
+ end
138
+
139
+ it 'should return the same value when unaffected' do
140
+ @helper.project.sprite('sprite_two').digest.should ==
141
+ @sprite_two_digest
142
+ end
143
+ end # when changing the source order for a sprite
144
+
145
+ context 'when changing the image for a source' do
146
+ before(:each) do
147
+ @sprite_one_digest = @helper.project.sprite('sprite_one').digest
148
+ @sprite_two_digest = @helper.project.sprite('sprite_two').digest
149
+ @helper.write_source('one', 100, 30)
150
+ end
151
+
152
+ it 'should return something different when it is affected' do
153
+ @helper.project.sprite('sprite_one').digest.should_not ==
154
+ @sprite_one_digest
155
+ end
156
+
157
+ it 'should return the same value when unaffected' do
158
+ @helper.project.sprite('sprite_two').digest.should ==
159
+ @sprite_two_digest
160
+ end
161
+ end # when changing the image for a source
162
+ end
163
+
164
+ # --- write ----------------------------------------------------------------
165
+
166
+ it { should have_public_method_defined(:write) }
167
+
168
+ # Fully spec'ed in spec/montage/commands/generate_spec.rb
169
+
170
+ end
data/spec/rcov.opts ADDED
@@ -0,0 +1,8 @@
1
+ --exclude "spec"
2
+ --exclude "activesupport"
3
+ --exclude "rcov"
4
+ --sort coverage
5
+ --callsites
6
+ --xrefs
7
+ --profile
8
+ --text-summary
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --loadby random
3
+ --format progress
4
+ --backtrace
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'tmpdir'
5
+
6
+ require 'rubygems'
7
+ require 'spec'
8
+ require 'spec/autorun'
9
+
10
+ require 'montage'
11
+ require 'sass'
12
+
13
+ # Spec libraries.
14
+ spec_libs = Dir.glob(File.expand_path(File.dirname(__FILE__)) + '/lib/**/*.rb')
15
+ spec_libs.each { |file| require file }
16
+
17
+ Spec::Runner.configure do |config|
18
+ config.after(:suite) { Montage::Spec::ProjectHelper.cleanup! }
19
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'spec/rake/spectask'
3
+
4
+ Spec::Rake::SpecTask.new(:spec) do |spec|
5
+ spec.pattern = 'spec/**/*_spec.rb'
6
+ spec.libs << 'lib' << 'spec'
7
+ spec.spec_opts << '--options' << 'spec/spec.opts'
8
+ end
9
+
10
+ desc "Run the specs, followed by the Cucumber features (if specs pass)"
11
+
12
+ rescue LoadError
13
+ task :spec do
14
+ abort 'rspec is not available. In order to run spec, you must: gem ' \
15
+ 'install rspec'
16
+ end
17
+ end
data/tasks/yard.rake ADDED
@@ -0,0 +1,11 @@
1
+ begin
2
+ require 'yard'
3
+ YARD::Rake::YardocTask.new do |doc|
4
+ doc.options << '--no-highlight'
5
+ end
6
+ rescue LoadError
7
+ task :yard do
8
+ abort 'YARD is not available. In order to run yard, you must: gem ' \
9
+ 'install yard'
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,249 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: montage
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 1
9
+ version: 0.2.1
10
+ platform: ruby
11
+ authors:
12
+ - Anthony Williams
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-08 00:00:00 +01:00
18
+ default_executable: montage
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 0
30
+ - 0
31
+ - beta
32
+ version: 3.0.0.beta
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rmagick
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 2
44
+ - 12
45
+ version: "2.12"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: highline
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 5
58
+ version: "1.5"
59
+ type: :runtime
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 3
71
+ - 0
72
+ version: 1.3.0
73
+ type: :development
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: cucumber
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ - 6
85
+ version: "0.6"
86
+ type: :development
87
+ version_requirements: *id005
88
+ - !ruby/object:Gem::Dependency
89
+ name: open4
90
+ prerelease: false
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 1
97
+ - 0
98
+ version: "1.0"
99
+ type: :development
100
+ version_requirements: *id006
101
+ - !ruby/object:Gem::Dependency
102
+ name: haml
103
+ prerelease: false
104
+ requirement: &id007 !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ segments:
109
+ - 3
110
+ - 0
111
+ - 0
112
+ - beta
113
+ - 1
114
+ version: 3.0.0.beta.1
115
+ type: :development
116
+ version_requirements: *id007
117
+ - !ruby/object:Gem::Dependency
118
+ name: yard
119
+ prerelease: false
120
+ requirement: &id008 !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ segments:
125
+ - 0
126
+ - 5
127
+ version: "0.5"
128
+ type: :development
129
+ version_requirements: *id008
130
+ description: Even Rocky had a montage.
131
+ email: hi@antw.me
132
+ executables:
133
+ - montage
134
+ extensions: []
135
+
136
+ extra_rdoc_files:
137
+ - LICENSE
138
+ - README.md
139
+ files:
140
+ - .document
141
+ - .gitignore
142
+ - History.md
143
+ - LICENSE
144
+ - README.md
145
+ - Rakefile
146
+ - VERSION
147
+ - bin/montage
148
+ - lib/montage.rb
149
+ - lib/montage/commands.rb
150
+ - lib/montage/commands/generate.rb
151
+ - lib/montage/commands/init.rb
152
+ - lib/montage/core_ext.rb
153
+ - lib/montage/project.rb
154
+ - lib/montage/sass_builder.rb
155
+ - lib/montage/source.rb
156
+ - lib/montage/sprite.rb
157
+ - lib/montage/templates/montage.yml
158
+ - lib/montage/templates/sass_mixins.erb
159
+ - lib/montage/templates/sources/book.png
160
+ - lib/montage/templates/sources/box-label.png
161
+ - lib/montage/templates/sources/calculator.png
162
+ - lib/montage/templates/sources/calendar-month.png
163
+ - lib/montage/templates/sources/camera.png
164
+ - lib/montage/templates/sources/eraser.png
165
+ - lib/montage/version.rb
166
+ - montage.gemspec
167
+ - spec/fixtures/custom_dirs/montage.yml
168
+ - spec/fixtures/default/montage.yml
169
+ - spec/fixtures/default/public/images/sprites/src/one.png
170
+ - spec/fixtures/default/public/images/sprites/src/three.png
171
+ - spec/fixtures/default/public/images/sprites/src/two.png
172
+ - spec/fixtures/directory_config/config/montage.yml
173
+ - spec/fixtures/missing_source/montage.yml
174
+ - spec/fixtures/missing_source_dir/montage.yml
175
+ - spec/fixtures/root_config/montage.yml
176
+ - spec/fixtures/root_config/public/images/sprites/src/source_one.png
177
+ - spec/fixtures/root_config/public/images/sprites/src/source_three.jpg
178
+ - spec/fixtures/root_config/public/images/sprites/src/source_two
179
+ - spec/fixtures/sources/hundred.png
180
+ - spec/fixtures/sources/mammoth.png
181
+ - spec/fixtures/sources/other.png
182
+ - spec/fixtures/sources/twenty.png
183
+ - spec/fixtures/subdirs/montage.yml
184
+ - spec/fixtures/subdirs/sub/sub/keep
185
+ - spec/lib/command_runner.rb
186
+ - spec/lib/fixtures.rb
187
+ - spec/lib/have_public_method_defined.rb
188
+ - spec/lib/project_helper.rb
189
+ - spec/lib/shared_project_specs.rb
190
+ - spec/lib/shared_sprite_specs.rb
191
+ - spec/montage/commands/generate_spec.rb
192
+ - spec/montage/commands/init_spec.rb
193
+ - spec/montage/core_ext_spec.rb
194
+ - spec/montage/project_spec.rb
195
+ - spec/montage/sass_builder_spec.rb
196
+ - spec/montage/source_spec.rb
197
+ - spec/montage/spec/have_public_method_defined_spec.rb
198
+ - spec/montage/sprite_spec.rb
199
+ - spec/rcov.opts
200
+ - spec/spec.opts
201
+ - spec/spec_helper.rb
202
+ - tasks/spec.rake
203
+ - tasks/yard.rake
204
+ has_rdoc: false
205
+ homepage: http://github.com/antw/montage
206
+ licenses: []
207
+
208
+ post_install_message:
209
+ rdoc_options:
210
+ - --charset=UTF-8
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ segments:
218
+ - 0
219
+ version: "0"
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ segments:
225
+ - 0
226
+ version: "0"
227
+ requirements: []
228
+
229
+ rubyforge_project:
230
+ rubygems_version: 1.3.6
231
+ signing_key:
232
+ specification_version: 3
233
+ summary: Montage
234
+ test_files:
235
+ - spec/lib/command_runner.rb
236
+ - spec/lib/fixtures.rb
237
+ - spec/lib/have_public_method_defined.rb
238
+ - spec/lib/project_helper.rb
239
+ - spec/lib/shared_project_specs.rb
240
+ - spec/lib/shared_sprite_specs.rb
241
+ - spec/montage/commands/generate_spec.rb
242
+ - spec/montage/commands/init_spec.rb
243
+ - spec/montage/core_ext_spec.rb
244
+ - spec/montage/project_spec.rb
245
+ - spec/montage/sass_builder_spec.rb
246
+ - spec/montage/source_spec.rb
247
+ - spec/montage/spec/have_public_method_defined_spec.rb
248
+ - spec/montage/sprite_spec.rb
249
+ - spec/spec_helper.rb