sphere 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", ">= 3.0.0"
4
+ group :test do
5
+ gem "rspec", "~> 2.0.0.beta"
6
+ gem "fakeweb"
7
+ end
@@ -0,0 +1,85 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0)
6
+ actionpack (= 3.0.0)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0)
9
+ activemodel (= 3.0.0)
10
+ activesupport (= 3.0.0)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.12)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.0)
19
+ activesupport (= 3.0.0)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0)
23
+ activemodel (= 3.0.0)
24
+ activesupport (= 3.0.0)
25
+ arel (~> 1.0.0)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.0)
28
+ activemodel (= 3.0.0)
29
+ activesupport (= 3.0.0)
30
+ activesupport (3.0.0)
31
+ arel (1.0.1)
32
+ activesupport (~> 3.0.0)
33
+ builder (2.1.2)
34
+ diff-lcs (1.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ fakeweb (1.3.0)
38
+ i18n (0.4.1)
39
+ mail (2.2.6.1)
40
+ activesupport (>= 2.3.6)
41
+ mime-types
42
+ treetop (>= 1.4.5)
43
+ mime-types (1.16)
44
+ polyglot (0.3.1)
45
+ rack (1.2.1)
46
+ rack-mount (0.6.13)
47
+ rack (>= 1.0.0)
48
+ rack-test (0.5.5)
49
+ rack (>= 1.0)
50
+ rails (3.0.0)
51
+ actionmailer (= 3.0.0)
52
+ actionpack (= 3.0.0)
53
+ activerecord (= 3.0.0)
54
+ activeresource (= 3.0.0)
55
+ activesupport (= 3.0.0)
56
+ bundler (~> 1.0.0)
57
+ railties (= 3.0.0)
58
+ railties (3.0.0)
59
+ actionpack (= 3.0.0)
60
+ activesupport (= 3.0.0)
61
+ rake (>= 0.8.4)
62
+ thor (~> 0.14.0)
63
+ rake (0.8.7)
64
+ rspec (2.0.0.beta.22)
65
+ rspec-core (= 2.0.0.beta.22)
66
+ rspec-expectations (= 2.0.0.beta.22)
67
+ rspec-mocks (= 2.0.0.beta.22)
68
+ rspec-core (2.0.0.beta.22)
69
+ rspec-expectations (2.0.0.beta.22)
70
+ diff-lcs (>= 1.1.2)
71
+ rspec-mocks (2.0.0.beta.22)
72
+ rspec-core (= 2.0.0.beta.22)
73
+ rspec-expectations (= 2.0.0.beta.22)
74
+ thor (0.14.1)
75
+ treetop (1.4.8)
76
+ polyglot (>= 0.3.1)
77
+ tzinfo (0.3.23)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ fakeweb
84
+ rails (>= 3.0.0)
85
+ rspec (~> 2.0.0.beta)
data/Rakefile CHANGED
@@ -1,15 +1,13 @@
1
1
  require 'rubygems'
2
- require 'spec/rake/spectask'
3
- require 'spec/version'
2
+ require 'rake'
3
+ require 'rspec/mocks/version'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
4
7
 
5
8
  desc 'Default: run specs.'
6
9
  task :default => :spec
7
10
 
8
- Spec::Rake::SpecTask.new do |t|
9
- t.spec_files = FileList['spec/**/*_spec.rb']
10
- t.spec_opts = ['--colour', '--format', 'profile', '--timeout', '20']
11
- end
12
-
13
11
  begin
14
12
  require 'jeweler'
15
13
  Jeweler::Tasks.new do |gemspec|
@@ -19,6 +17,7 @@ begin
19
17
  gemspec.email = "dimitrij@blacksquaremedia.com"
20
18
  gemspec.homepage = "http://github.com/dim/sphere"
21
19
  gemspec.authors = ["Dimitrij Denissenko"]
20
+ gemspec.add_runtime_dependency "rails", ">= 3.0.0"
22
21
  end
23
22
  Jeweler::GemcutterTasks.new
24
23
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.2.0
@@ -31,4 +31,4 @@ module Sphere
31
31
  end
32
32
  end
33
33
 
34
- ActionController::Base.helper(Sphere::Helper) if Object.const_defined?(:ActionController)
34
+ ActionView::Base.send(:include, Sphere::Helper) if Object.const_defined?(:ActionView)
@@ -41,6 +41,10 @@ module Sphere
41
41
  defined?(@compress) ? !!@compress : (definitions.key?('compress') ? !!definitions['compress'] : (self.env == 'production'))
42
42
  end
43
43
 
44
+ def compass?
45
+ definitions.key?('compass') ? !!definitions['compass'] : false
46
+ end
47
+
44
48
  def package?
45
49
  defined?(@package) ? !!@package : (definitions.key?('package') ? !!definitions['package'] : (self.env == 'production'))
46
50
  end
@@ -1,7 +1,6 @@
1
1
  module Sphere
2
2
  class CSSMinifier < String
3
3
 
4
-
5
4
  def initialize(css)
6
5
  super(css.dup)
7
6
  end
@@ -15,7 +14,7 @@ module Sphere
15
14
  end
16
15
  gsub!(/\{(.+?)\}/m) do |m|
17
16
  styles = $1.split(';').map do |style|
18
- key, values = style.split(':')
17
+ key, values = style.scan(/^([^:]+)\:(.*)$/).flatten
19
18
  next nil unless key && values
20
19
  "#{key.strip}:#{values.split(',').map(&:strip).reject(&:blank?).join(',')}"
21
20
  end.compact.join(';')
@@ -1,15 +1,20 @@
1
1
  namespace :sphere do
2
2
  namespace :compass do
3
3
 
4
- task :base => 'sphere:base' do
4
+ desc "Compile compass assets"
5
+ task :compile => 'sphere:base' do
5
6
  require 'compass'
6
7
  require 'compass/exec'
7
- Compass.add_project_configuration(Sphere.config.root.join("config", "compass.config"))
8
- end
9
8
 
10
- desc "Compile compass assets"
11
- task :compile => 'sphere:compass:base' do
9
+ config = Sphere.config.send(:definitions)['compass']
10
+ config = {} unless config.is_a?(Hash)
11
+
12
12
  project = Compass::Commands::UpdateProject.new(Sphere.config.root.to_s, :quiet => false, :force => false)
13
+ Compass.configuration do |c|
14
+ c.environment = :production
15
+ c.css_dir = config['css_dir'] || 'public/stylesheets/compact'
16
+ c.output_style = config['output_style'] || :compact
17
+ end
13
18
  project.perform
14
19
  end
15
20
 
@@ -0,0 +1 @@
1
+ # Just a dummy file to identify Rails.root
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module Scenario
10
+ class Application < Rails::Application
11
+ end
12
+ end
13
+
@@ -1,110 +1,13 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ gemfile = File.expand_path("../../../../Gemfile", __FILE__)
5
+ begin
6
+ ENV['BUNDLE_GEMFILE'] = gemfile
7
+ require 'bundler'
8
+ Bundler.setup
9
+ rescue Bundler::GemNotFound => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Try running `bundle install`."
12
+ exit!
13
+ end if File.exist?(gemfile)
@@ -0,0 +1,12 @@
1
+ # Require any additional compass plugins here.
2
+ project_type = :rails
3
+ project_path = Rails.root if defined?(Rails)
4
+ # Set this to the root of your project when deployed:
5
+ http_path = "/"
6
+ css_dir = "public/stylesheets/compiled"
7
+ sass_dir = "app/stylesheets"
8
+ images_dir = "public/images"
9
+ javascripts_dir = "public/javascripts"
10
+ http_images_path = "/images"
11
+ http_stylesheets_path = "/stylesheets"
12
+ http_javascripts_path = "/javascripts"
@@ -38,3 +38,5 @@ div hr {
38
38
 
39
39
  h1,h2,h3,h4, h5,h6 { font-family: "Helvetica Neue", Arial, "Lucida Grande", sans-serif; }
40
40
  code { font:.9em "Courier New", Monaco, Courier, monospace; }
41
+ .remote-a { background: url(http://example.com/remote/image/?a=1&b=2&c=3|0|0|100) repeat-x scroll 50% 50%; }
42
+ .remote-b { background: url(http://example.com/remote/image/?a=1&b=2&c=3|0|0|100) repeat-x scroll 50% 50%; }
@@ -1,14 +1,8 @@
1
1
  ENV["RAILS_ENV"] ||= 'test'
2
2
  $: << File.join(File.dirname(__FILE__),'..', 'lib')
3
3
 
4
- require File.join(File.dirname(__FILE__), 'scenario', 'config', 'boot')
5
- require 'active_record'
6
- require 'action_controller'
7
-
4
+ require File.join(File.dirname(__FILE__), 'scenario', 'config', 'application')
8
5
  require File.join(File.dirname(__FILE__),'..', 'rails', 'init.rb')
9
- require 'spec/autorun'
10
- require 'spec/mocks'
11
- ActiveRecord::Base.stub(:establish_connection)
12
6
 
13
7
  require 'fakeweb'
14
8
  FakeWeb.allow_net_connect = false
@@ -18,7 +12,21 @@ FakeWeb.register_uri :get, "http://www.blueprintcss.org/blueprint/src/typography
18
12
  FakeWeb.register_uri :get, "http://www.blueprintcss.org/blueprint/src/print.css", :body => "a img { border:none; }"
19
13
  FakeWeb.register_uri :post, "http://closure-compiler.appspot.com/compile", :body => "(function(){})(window);(function(a){a.ui=a.ui||{}})(jQuery);(function(a){a.extend({blank:function(b){return!b||!/\S/.test(b)}})})(JQuery)(function(a){a.extend({present:function(b){return b||/\S/.test(b)}})})(JQuery)(function(a){a.extend({square:function(b){return b*b}})})(JQuery);"
20
14
 
21
- class Spec::Example::ExampleGroup
15
+ module Sphere::ExampleGroup
16
+ extend ActiveSupport::Concern
17
+
18
+ included do
19
+ before do
20
+ ActiveRecord::Base.stub!(:establish_connection)
21
+ Sphere.reset!
22
+ end
23
+
24
+ after do
25
+ (js_files + css_files).each do |file|
26
+ FileUtils.rm file, :force => true
27
+ end
28
+ end
29
+ end
22
30
 
23
31
  def javascripts
24
32
  Sphere.packager.packages(:js)
@@ -36,15 +44,11 @@ class Spec::Example::ExampleGroup
36
44
  stylesheets.values.map(&:file)
37
45
  end
38
46
 
39
- before do
40
- Sphere.reset!
41
- end
42
-
43
- after do
44
- (js_files + css_files).each do |file|
45
- FileUtils.rm file, :force => true
46
- end
47
- end
47
+ end
48
48
 
49
+ require 'rspec'
50
+ RSpec.configure do |c|
51
+ c.mock_with :rspec
52
+ c.include(Sphere::ExampleGroup)
49
53
  end
50
54
 
@@ -8,9 +8,9 @@ describe Sphere::CSSMinifier do
8
8
 
9
9
  it "should minify CSS" do
10
10
  minifier = Sphere::CSSMinifier.new(css_content)
11
- minifier.size.should == 881
11
+ minifier.size.should == 1099
12
12
  minifier.minify!
13
- minifier.size.should == 279
13
+ minifier.size.should == 487
14
14
  end
15
15
 
16
16
  end
@@ -5,7 +5,9 @@ describe Sphere::Helper do
5
5
  end
6
6
 
7
7
  def helper
8
- @helper ||= SphereDummyHelper.new
8
+ @helper ||= SphereDummyHelper.new.tap do |h|
9
+ h.config['assets_dir'] = Rails.root.join('public')
10
+ end
9
11
  end
10
12
 
11
13
  it 'should have method to load javascript packages' do
@@ -11,7 +11,7 @@ describe Sphere::Package::Stylesheet do
11
11
  stylesheets['screen'].file.exist?.should be(false)
12
12
  stylesheets['screen'].compile
13
13
  stylesheets['screen'].file.exist?.should be(true)
14
- stylesheets['screen'].file.size.should == 322
14
+ stylesheets['screen'].file.size.should == 530
15
15
  stylesheets['screen'].should_not be_out_of_date
16
16
  end
17
17
 
@@ -34,7 +34,7 @@ describe Sphere::Packager do
34
34
  css_files.last.exist?.should be(false)
35
35
  Sphere::Packager.instance.compile(:css)
36
36
  css_files[0].exist?.should be(true)
37
- css_files[0].size.should == 933
37
+ css_files[0].size.should == 1151
38
38
  css_files[1].exist?.should be(true)
39
39
  css_files[1].size.should == 22
40
40
  css_files[2].exist?.should be(true)
@@ -5,18 +5,21 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sphere}
8
- s.version = "0.1.6"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dimitrij Denissenko"]
12
- s.date = %q{2010-08-17}
12
+ s.date = %q{2010-09-24}
13
13
  s.description = %q{Rails asset packer and compressor. Supports Compass, built (primarily) to be used with Heroku & AWS/S3}
14
14
  s.email = %q{dimitrij@blacksquaremedia.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.markdown"
17
17
  ]
18
18
  s.files = [
19
- ".gitignore",
19
+ ".bundle/config",
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "Gemfile.lock",
20
23
  "README.markdown",
21
24
  "Rakefile",
22
25
  "VERSION",
@@ -36,7 +39,10 @@ Gem::Specification.new do |s|
36
39
  "lib/sphere/tasks/sphere.rake",
37
40
  "lib/sphere/tasks/upload.rake",
38
41
  "rails/init.rb",
42
+ "spec/scenario/config.ru",
43
+ "spec/scenario/config/application.rb",
39
44
  "spec/scenario/config/boot.rb",
45
+ "spec/scenario/config/compass.config",
40
46
  "spec/scenario/config/database.yml",
41
47
  "spec/scenario/config/environment.rb",
42
48
  "spec/scenario/config/sphere.yml",
@@ -74,6 +80,7 @@ Gem::Specification.new do |s|
74
80
  "spec/sphere/css_minifier_spec.rb",
75
81
  "spec/sphere_spec.rb",
76
82
  "spec/spec_helper.rb",
83
+ "spec/scenario/config/application.rb",
77
84
  "spec/scenario/config/environment.rb",
78
85
  "spec/scenario/config/boot.rb"
79
86
  ]
@@ -83,9 +90,12 @@ Gem::Specification.new do |s|
83
90
  s.specification_version = 3
84
91
 
85
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
+ s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
86
94
  else
95
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
87
96
  end
88
97
  else
98
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
89
99
  end
90
100
  end
91
101
 
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 6
10
- version: 0.1.6
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dimitrij Denissenko
@@ -15,10 +15,25 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-17 00:00:00 +01:00
18
+ date: 2010-09-24 00:00:00 +01:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 0
34
+ version: 3.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
22
37
  description: Rails asset packer and compressor. Supports Compass, built (primarily) to be used with Heroku & AWS/S3
23
38
  email: dimitrij@blacksquaremedia.com
24
39
  executables: []
@@ -28,7 +43,10 @@ extensions: []
28
43
  extra_rdoc_files:
29
44
  - README.markdown
30
45
  files:
46
+ - .bundle/config
31
47
  - .gitignore
48
+ - Gemfile
49
+ - Gemfile.lock
32
50
  - README.markdown
33
51
  - Rakefile
34
52
  - VERSION
@@ -48,7 +66,10 @@ files:
48
66
  - lib/sphere/tasks/sphere.rake
49
67
  - lib/sphere/tasks/upload.rake
50
68
  - rails/init.rb
69
+ - spec/scenario/config.ru
70
+ - spec/scenario/config/application.rb
51
71
  - spec/scenario/config/boot.rb
72
+ - spec/scenario/config/compass.config
52
73
  - spec/scenario/config/database.yml
53
74
  - spec/scenario/config/environment.rb
54
75
  - spec/scenario/config/sphere.yml
@@ -114,5 +135,6 @@ test_files:
114
135
  - spec/sphere/css_minifier_spec.rb
115
136
  - spec/sphere_spec.rb
116
137
  - spec/spec_helper.rb
138
+ - spec/scenario/config/application.rb
117
139
  - spec/scenario/config/environment.rb
118
140
  - spec/scenario/config/boot.rb