montage 0.3.0 → 0.4.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.
data/Rakefile CHANGED
@@ -24,10 +24,13 @@ begin
24
24
  gem.add_dependency 'highline', '>= 1.5'
25
25
 
26
26
  # Development dependencies.
27
- gem.add_development_dependency 'rspec', '>= 1.3.0'
28
- gem.add_development_dependency 'open4', '>= 1.0'
29
- gem.add_development_dependency 'haml', '>= 3.0.0.beta.1'
30
- gem.add_development_dependency 'yard', '>= 0.5'
27
+ gem.add_development_dependency 'rspec-core', '>= 2.0.0.beta.12'
28
+ gem.add_development_dependency 'rspec-expectations', '>= 2.0.0.beta.12'
29
+ gem.add_development_dependency 'rspec-mocks', '>= 2.0.0.beta.12'
30
+
31
+ gem.add_development_dependency 'open4', '>= 1.0'
32
+ gem.add_development_dependency 'haml', '>= 3.0.0.beta.1'
33
+ gem.add_development_dependency 'yard', '>= 0.5'
31
34
  end
32
35
 
33
36
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -1,3 +1,4 @@
1
+ # Some simple string extensions to make things easier.
1
2
  class String
2
3
 
3
4
  # Replace sequences of whitespace (including newlines) with either
@@ -8,13 +9,10 @@ class String
8
9
  # FROM users
9
10
  # QUERY => "SELECT name FROM users"
10
11
  #
11
- # @param [TrueClass, FalseClass] spaced (default=true)
12
- # Determines whether returned string has whitespace collapsed or removed
13
- #
14
12
  # @return [String] Receiver with whitespace (including newlines) replaced
15
13
  #
16
- def compress_lines(spaced = true)
17
- split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
14
+ def compress_lines
15
+ split($/).map { |line| line.strip }.join(' ')
18
16
  end
19
17
 
20
18
  # Removes leading whitespace from each line, such as might be added when
@@ -91,10 +91,15 @@ module Montage
91
91
  MESSAGE
92
92
  end
93
93
 
94
- list = @sources.inject(Magick::ImageList.new) do |list, source|
94
+ list = Magick::ImageList.new
95
+
96
+ @sources.each do |source|
95
97
  list << source.image
96
- list << Magick::Image.new(1, @padding) do
97
- self.background_color = '#FFF0'
98
+
99
+ if @padding and @padding > 0
100
+ list << Magick::Image.new(1, @padding) do
101
+ self.background_color = '#FFF0'
102
+ end
98
103
  end
99
104
  end
100
105
 
@@ -48,10 +48,9 @@ module Montage
48
48
  option; please use only one.
49
49
  ERROR
50
50
  elsif not has_name_segment? and not @options.has_key?(:name)
51
- raise Montage::MissingName, <<-ERROR.compress_lines
52
- Sprite `#{path}' requires a name. Add a :name path segment
53
- or add a "name" option.
54
- ERROR
51
+ # Infer the sprite name from the filename.
52
+ @options[:name] =
53
+ File.basename(@options[:to], File.extname(@options[:to]))
55
54
  elsif has_name_segment? and not @options[:to] =~ /:name/
56
55
  raise Montage::MissingName, <<-ERROR.compress_lines
57
56
  Sprite `#{path}' requires :name in the "to" option.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{montage}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anthony Williams"]
12
- s.date = %q{2010-04-12}
12
+ s.date = %q{2010-07-14}
13
13
  s.default_executable = %q{montage}
14
14
  s.description = %q{Even Rocky had a montage.}
15
15
  s.email = %q{hi@antw.me}
@@ -68,7 +68,6 @@ Gem::Specification.new do |s|
68
68
  "spec/montage/sprite_definition_spec.rb",
69
69
  "spec/montage/sprite_spec.rb",
70
70
  "spec/rcov.opts",
71
- "spec/spec.opts",
72
71
  "spec/spec_helper.rb",
73
72
  "tasks/spec.rake",
74
73
  "tasks/yard.rake"
@@ -77,7 +76,7 @@ Gem::Specification.new do |s|
77
76
  s.homepage = %q{http://github.com/antw/montage}
78
77
  s.rdoc_options = ["--charset=UTF-8"]
79
78
  s.require_paths = ["lib"]
80
- s.rubygems_version = %q{1.3.6}
79
+ s.rubygems_version = %q{1.3.7}
81
80
  s.summary = %q{Montage}
82
81
  s.test_files = [
83
82
  "spec/lib/command_runner.rb",
@@ -101,17 +100,21 @@ Gem::Specification.new do |s|
101
100
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
102
101
  s.specification_version = 3
103
102
 
104
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
103
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
105
104
  s.add_runtime_dependency(%q<rmagick>, [">= 2.12"])
106
105
  s.add_runtime_dependency(%q<highline>, [">= 1.5"])
107
- s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
106
+ s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
107
+ s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
108
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
108
109
  s.add_development_dependency(%q<open4>, [">= 1.0"])
109
110
  s.add_development_dependency(%q<haml>, [">= 3.0.0.beta.1"])
110
111
  s.add_development_dependency(%q<yard>, [">= 0.5"])
111
112
  else
112
113
  s.add_dependency(%q<rmagick>, [">= 2.12"])
113
114
  s.add_dependency(%q<highline>, [">= 1.5"])
114
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
115
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
116
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
117
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
115
118
  s.add_dependency(%q<open4>, [">= 1.0"])
116
119
  s.add_dependency(%q<haml>, [">= 3.0.0.beta.1"])
117
120
  s.add_dependency(%q<yard>, [">= 0.5"])
@@ -119,7 +122,9 @@ Gem::Specification.new do |s|
119
122
  else
120
123
  s.add_dependency(%q<rmagick>, [">= 2.12"])
121
124
  s.add_dependency(%q<highline>, [">= 1.5"])
122
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
125
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.12"])
126
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.12"])
127
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.12"])
123
128
  s.add_dependency(%q<open4>, [">= 1.0"])
124
129
  s.add_dependency(%q<haml>, [">= 3.0.0.beta.1"])
125
130
  s.add_dependency(%q<yard>, [">= 0.5"])
@@ -54,7 +54,7 @@ module Montage
54
54
  #
55
55
  def run(command, &block)
56
56
  if command =~ /^montage(.*)$/
57
- command = "#{RUBY} -rubygems #{EXECUTABLE}#{$1} --no-color"
57
+ command = "#{RUBY} #{EXECUTABLE}#{$1} --no-color"
58
58
  end
59
59
 
60
60
  @status, @stderr, @stdout = nil, nil, nil
@@ -1,4 +1,4 @@
1
- ::Spec::Matchers.define :have_public_method_defined do |value|
1
+ ::RSpec::Matchers.define :have_public_method_defined do |value|
2
2
  match do |klass|
3
3
  klass.public_method_defined?(value.to_sym)
4
4
  end
@@ -1,4 +1,4 @@
1
- describe 'a project with correct paths', :shared => true do
1
+ shared_examples_for 'a project with correct paths' do
2
2
  # Requires:
3
3
  #
4
4
  # @project => Montage::Project
@@ -1,4 +1,4 @@
1
- describe 'saving a sprite', :shared => true do
1
+ shared_examples_for 'saving a sprite' do
2
2
  # Requires:
3
3
  #
4
4
  # @sprite => Montage::Sprite
@@ -76,6 +76,30 @@ end
76
76
 
77
77
  # ----------------------------------------------------------------------------
78
78
 
79
+ context 'Generating a single sprite with zero padding' do
80
+ before(:all) do
81
+ @runner = Montage::Spec::CommandRunner.new('montage')
82
+ @runner.write_config <<-CONFIG
83
+ ---
84
+ config.padding: 0
85
+
86
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
87
+ to: "public/images/:name.png"
88
+
89
+ CONFIG
90
+ @runner.write_source('sprite_one/one')
91
+ @runner.write_source('sprite_one/two')
92
+ @runner.run!
93
+ end
94
+
95
+ it { @runner.should be_success }
96
+ it { @runner.stdout.should =~ /Generating "sprite_one": Done/ }
97
+ it { @runner.path_to_sprite('sprite_one').should be_file }
98
+ it { @runner.dimensions_of('sprite_one').should == [50, 40] }
99
+ end
100
+
101
+ # ----------------------------------------------------------------------------
102
+
79
103
  context 'Trying to generate sprites in a non-project directory' do
80
104
  before(:all) do
81
105
  @runner = Montage::Spec::CommandRunner.new('montage').run!
@@ -130,14 +130,14 @@ describe Montage::Project do
130
130
 
131
131
  it 'should raise an error' do
132
132
  running = lambda { Montage::Project.find(@helper.project_dir) }
133
- running.should raise_exception(Montage::MissingProject)
133
+ running.should raise_error(Montage::MissingProject)
134
134
  end
135
135
  end # when given an empty directory
136
136
 
137
137
  describe 'when given an invalid path' do
138
138
  it 'should raise an error' do
139
139
  running = lambda { Montage::Project.find('__invalid__') }
140
- running.should raise_exception(Montage::MissingProject)
140
+ running.should raise_error(Montage::MissingProject)
141
141
  end
142
142
  end # when given an invalid path
143
143
  end
@@ -2,30 +2,30 @@ require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
3
  describe 'have_public_method_defined matcher' do
4
4
  before(:all) do
5
- @exception = Spec::Expectations::ExpectationNotMetError
5
+ @exception = RSpec::Expectations::ExpectationNotMetError
6
6
  end
7
7
 
8
8
  describe 'with should' do
9
9
  it 'should pass when the method is defined' do
10
10
  running = lambda { String.should have_public_method_defined(:length) }
11
- running.should_not raise_exception(@exception)
11
+ running.should_not raise_error(@exception)
12
12
  end
13
13
 
14
14
  it 'should fail when the method is not defined' do
15
15
  running = lambda { String.should have_public_method_defined(:__invalid__) }
16
- running.should raise_exception(@exception)
16
+ running.should raise_error(@exception)
17
17
  end
18
18
  end
19
19
 
20
20
  describe 'with should_not' do
21
21
  it 'should fail when the method is defined' do
22
22
  running = lambda { String.should_not have_public_method_defined(:length) }
23
- running.should raise_exception(@exception)
23
+ running.should raise_error(@exception)
24
24
  end
25
25
 
26
26
  it 'should pass when the method is not defined' do
27
27
  running = lambda { String.should_not have_public_method_defined(:__invalid__) }
28
- running.should_not raise_exception(@exception)
28
+ running.should_not raise_error(@exception)
29
29
  end
30
30
  end
31
31
  end
@@ -338,12 +338,17 @@ describe Montage::SpriteDefinition do
338
338
 
339
339
  # --------------------------------------------------------------------------
340
340
 
341
- context 'with a no :name capture, and and no "name" option' do
342
- it 'should raise an error' do
343
- running = lambda { Montage::SpriteDefinition.new(
344
- @helper.project, '/__invalid__/*', "to" => "_") }
341
+ context 'with a full file name, and no :name capture or option' do
342
+ it 'should infer the sprite name from the filename' do
343
+ @helper.touch('src/source')
345
344
 
346
- running.should raise_error(Montage::MissingName)
345
+ definition = Montage::SpriteDefinition.new(
346
+ @helper.project, 'src/*', 'to' => 'lurrr.png')
347
+
348
+ @return = definition.to_sprites
349
+
350
+ @return.length.should == 1
351
+ @return[0].name.should == 'lurrr'
347
352
  end
348
353
  end
349
354
 
@@ -4,16 +4,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'tmpdir'
5
5
 
6
6
  require 'rubygems'
7
- require 'spec'
8
- require 'spec/autorun'
7
+ require 'rspec/core'
8
+ require 'rspec/autorun'
9
9
 
10
10
  require 'montage'
11
11
  require 'sass'
12
12
 
13
13
  # Spec libraries.
14
- spec_libs = Dir.glob(File.expand_path(File.dirname(__FILE__)) + '/lib/**/*.rb')
15
- spec_libs.each { |file| require file }
14
+ Dir["#{File.dirname(__FILE__)}/lib/**/*.rb"].each { |f| require f }
16
15
 
17
- Spec::Runner.configure do |config|
16
+ RSpec.configure do |config|
18
17
  config.after(:suite) { Montage::Spec::ProjectHelper.cleanup! }
19
18
  end
@@ -1,13 +1,10 @@
1
1
  begin
2
- require 'spec/rake/spectask'
3
2
 
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
3
+ require 'rspec/core/rake_task'
9
4
 
10
- desc "Run the specs, followed by the Cucumber features (if specs pass)"
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = 'spec/**/*_spec.rb'
7
+ end
11
8
 
12
9
  rescue LoadError
13
10
  task :spec do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: montage
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 15
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 3
8
+ - 4
8
9
  - 0
9
- version: 0.3.0
10
+ version: 0.4.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Anthony Williams
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-12 00:00:00 +01:00
18
+ date: 2010-07-14 00:00:00 +01:00
18
19
  default_executable: montage
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rmagick
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 27
27
30
  segments:
28
31
  - 2
29
32
  - 12
@@ -34,9 +37,11 @@ dependencies:
34
37
  name: highline
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
44
+ hash: 5
40
45
  segments:
41
46
  - 1
42
47
  - 5
@@ -44,39 +49,83 @@ dependencies:
44
49
  type: :runtime
45
50
  version_requirements: *id002
46
51
  - !ruby/object:Gem::Dependency
47
- name: rspec
52
+ name: rspec-core
48
53
  prerelease: false
49
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
50
56
  requirements:
51
57
  - - ">="
52
58
  - !ruby/object:Gem::Version
59
+ hash: 62196475
53
60
  segments:
54
- - 1
55
- - 3
61
+ - 2
56
62
  - 0
57
- version: 1.3.0
63
+ - 0
64
+ - beta
65
+ - 12
66
+ version: 2.0.0.beta.12
58
67
  type: :development
59
68
  version_requirements: *id003
60
69
  - !ruby/object:Gem::Dependency
61
- name: open4
70
+ name: rspec-expectations
62
71
  prerelease: false
63
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 62196475
78
+ segments:
79
+ - 2
80
+ - 0
81
+ - 0
82
+ - beta
83
+ - 12
84
+ version: 2.0.0.beta.12
85
+ type: :development
86
+ version_requirements: *id004
87
+ - !ruby/object:Gem::Dependency
88
+ name: rspec-mocks
89
+ prerelease: false
90
+ requirement: &id005 !ruby/object:Gem::Requirement
91
+ none: false
64
92
  requirements:
65
93
  - - ">="
66
94
  - !ruby/object:Gem::Version
95
+ hash: 62196475
96
+ segments:
97
+ - 2
98
+ - 0
99
+ - 0
100
+ - beta
101
+ - 12
102
+ version: 2.0.0.beta.12
103
+ type: :development
104
+ version_requirements: *id005
105
+ - !ruby/object:Gem::Dependency
106
+ name: open4
107
+ prerelease: false
108
+ requirement: &id006 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 15
67
114
  segments:
68
115
  - 1
69
116
  - 0
70
117
  version: "1.0"
71
118
  type: :development
72
- version_requirements: *id004
119
+ version_requirements: *id006
73
120
  - !ruby/object:Gem::Dependency
74
121
  name: haml
75
122
  prerelease: false
76
- requirement: &id005 !ruby/object:Gem::Requirement
123
+ requirement: &id007 !ruby/object:Gem::Requirement
124
+ none: false
77
125
  requirements:
78
126
  - - ">="
79
127
  - !ruby/object:Gem::Version
128
+ hash: 62196417
80
129
  segments:
81
130
  - 3
82
131
  - 0
@@ -85,20 +134,22 @@ dependencies:
85
134
  - 1
86
135
  version: 3.0.0.beta.1
87
136
  type: :development
88
- version_requirements: *id005
137
+ version_requirements: *id007
89
138
  - !ruby/object:Gem::Dependency
90
139
  name: yard
91
140
  prerelease: false
92
- requirement: &id006 !ruby/object:Gem::Requirement
141
+ requirement: &id008 !ruby/object:Gem::Requirement
142
+ none: false
93
143
  requirements:
94
144
  - - ">="
95
145
  - !ruby/object:Gem::Version
146
+ hash: 1
96
147
  segments:
97
148
  - 0
98
149
  - 5
99
150
  version: "0.5"
100
151
  type: :development
101
- version_requirements: *id006
152
+ version_requirements: *id008
102
153
  description: Even Rocky had a montage.
103
154
  email: hi@antw.me
104
155
  executables:
@@ -158,7 +209,6 @@ files:
158
209
  - spec/montage/sprite_definition_spec.rb
159
210
  - spec/montage/sprite_spec.rb
160
211
  - spec/rcov.opts
161
- - spec/spec.opts
162
212
  - spec/spec_helper.rb
163
213
  - tasks/spec.rake
164
214
  - tasks/yard.rake
@@ -172,23 +222,27 @@ rdoc_options:
172
222
  require_paths:
173
223
  - lib
174
224
  required_ruby_version: !ruby/object:Gem::Requirement
225
+ none: false
175
226
  requirements:
176
227
  - - ">="
177
228
  - !ruby/object:Gem::Version
229
+ hash: 3
178
230
  segments:
179
231
  - 0
180
232
  version: "0"
181
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
+ none: false
182
235
  requirements:
183
236
  - - ">="
184
237
  - !ruby/object:Gem::Version
238
+ hash: 3
185
239
  segments:
186
240
  - 0
187
241
  version: "0"
188
242
  requirements: []
189
243
 
190
244
  rubyforge_project:
191
- rubygems_version: 1.3.6
245
+ rubygems_version: 1.3.7
192
246
  signing_key:
193
247
  specification_version: 3
194
248
  summary: Montage
@@ -1,4 +0,0 @@
1
- --colour
2
- --loadby random
3
- --format progress
4
- --backtrace