spontaneous 0.2.0.beta8 → 0.2.0.beta9
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/spontaneous/asset/environment.rb +19 -0
- data/lib/spontaneous/publishing/steps/copy_assets.rb +16 -0
- data/lib/spontaneous/version.rb +1 -1
- data/test/unit/test_assets.rb +0 -8
- data/test/unit/test_changesets.rb +1 -1
- data/test/unit/test_fields.rb +2 -2
- data/test/unit/test_publishing_pipeline.rb +22 -2
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c521e3b9b35cfba180daf3fcc24894af352ca2eb
         | 
| 4 | 
            +
              data.tar.gz: 5f3fb38da829759b10dd33a2b4224a7bae9dfbdc
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c82fea8cd02838425f8f20eb2b21eab9ae3084414dcce39c1d72351e5292d7c9d09483729a9610e2e66cabedeb8bf7afb70570110b0582515ba87ae27e8b2d82
         | 
| 7 | 
            +
              data.tar.gz: 2f1a515a14f373b3535c864084529894d12878d8601b5c2f86e99267342816a30989acf5b0dd479369c0301ee56134b7996eb286304029d509715876f93166fe
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
| @@ -219,10 +219,29 @@ module Spontaneous::Asset | |
| 219 219 | 
             
                      unless (args.all? { |key| assets.key?(key) })
         | 
| 220 220 | 
             
                        compile!(*args)
         | 
| 221 221 | 
             
                      end
         | 
| 222 | 
            +
                      copy_assets_to_revision(args)
         | 
| 222 223 | 
             
                    end
         | 
| 223 224 |  | 
| 224 225 | 
             
                    def compile!(*args)
         | 
| 225 226 | 
             
                      @manifest.compile(*args)
         | 
| 227 | 
            +
                      copy_assets_to_revision(args)
         | 
| 228 | 
            +
                    end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                    def copy_assets_to_revision(logical_paths)
         | 
| 231 | 
            +
                      assets = @manifest.assets
         | 
| 232 | 
            +
                      paths = logical_paths.map { |a| assets[a] }.compact
         | 
| 233 | 
            +
                      source, dest = shared_asset_dir, revision_asset_dir
         | 
| 234 | 
            +
                      paths.each do |asset|
         | 
| 235 | 
            +
                        copy_asset_to_revision(source, dest, asset)
         | 
| 236 | 
            +
                      end
         | 
| 237 | 
            +
                    end
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                    def copy_asset_to_revision(source, dest, asset)
         | 
| 240 | 
            +
                      to = dest + asset
         | 
| 241 | 
            +
                      return if to.exist?
         | 
| 242 | 
            +
                      from = source + asset
         | 
| 243 | 
            +
                      to.dirname.mkpath
         | 
| 244 | 
            +
                      FileUtils.cp(from, to)
         | 
| 226 245 | 
             
                    end
         | 
| 227 246 |  | 
| 228 247 | 
             
                    def asset_compilation_dir
         | 
| @@ -2,10 +2,26 @@ module Spontaneous::Publishing::Steps | |
| 2 2 | 
             
              class CopyAssets < BaseStep
         | 
| 3 3 |  | 
| 4 4 | 
             
                def count
         | 
| 5 | 
            +
                  return 0 if development?
         | 
| 5 6 | 
             
                  assets.length
         | 
| 6 7 | 
             
                end
         | 
| 7 8 |  | 
| 8 9 | 
             
                def call
         | 
| 10 | 
            +
                  case development?
         | 
| 11 | 
            +
                  when true
         | 
| 12 | 
            +
                    development_mode
         | 
| 13 | 
            +
                  when false
         | 
| 14 | 
            +
                    production_mode
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def development_mode
         | 
| 19 | 
            +
                  # In development the asset manifest isn't cached and the compilation
         | 
| 20 | 
            +
                  # done by the asset environment is sufficient to copy all the assets into
         | 
| 21 | 
            +
                  # place
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def production_mode
         | 
| 9 25 | 
             
                  @progress.stage("copying assets")
         | 
| 10 26 | 
             
                  ensure_asset_dir
         | 
| 11 27 | 
             
                  assets.each do |logical_path, asset|
         | 
    
        data/lib/spontaneous/version.rb
    CHANGED
    
    
    
        data/test/unit/test_assets.rb
    CHANGED
    
    | @@ -371,17 +371,10 @@ describe "Assets" do | |
| 371 371 | 
             
                let(:app) { Spontaneous::Rack::Front.application(site) }
         | 
| 372 372 | 
             
                let(:context) { live_context }
         | 
| 373 373 | 
             
                let(:revision) { site.revision(context.revision) }
         | 
| 374 | 
            -
                let(:progress) { Spontaneous::Publishing::Progress::Silent.new }
         | 
| 375 | 
            -
             | 
| 376 | 
            -
                def publish_assets(revision)
         | 
| 377 | 
            -
                  context.asset_environment.manifest.compile!
         | 
| 378 | 
            -
                  Spontaneous::Publishing::Steps::CopyAssets.new(site, revision, [], progress).call
         | 
| 379 | 
            -
                end
         | 
| 380 374 |  | 
| 381 375 | 
             
                before do
         | 
| 382 376 | 
             
                  FileUtils.rm_f(Spontaneous.revision_dir) if File.exist?(Spontaneous.revision_dir)
         | 
| 383 377 | 
             
                  system "ln -nfs #{revision.root} #{Spontaneous.revision_dir}"
         | 
| 384 | 
            -
                  publish_assets(context.revision)
         | 
| 385 378 | 
             
                end
         | 
| 386 379 |  | 
| 387 380 | 
             
                after do
         | 
| @@ -450,7 +443,6 @@ describe "Assets" do | |
| 450 443 | 
             
                      context = live_context
         | 
| 451 444 | 
             
                      def context.revision; 100 end
         | 
| 452 445 | 
             
                      revision = site.revision(context.revision)
         | 
| 453 | 
            -
                      publish_assets(context.revision)
         | 
| 454 446 | 
             
                      manifest = Spontaneous::JSON.parse File.read(site.path("assets/tmp") + "manifest.json")
         | 
| 455 447 | 
             
                      compiled = manifest[:assets][:"js/all.js"]
         | 
| 456 448 | 
             
                      ::File.open(site.path("assets/tmp")+compiled, 'w') do |file|
         | 
    
        data/test/unit/test_fields.rb
    CHANGED
    
    | @@ -976,7 +976,7 @@ describe "Fields" do | |
| 976 976 | 
             
                  @field.value(:lat).must_equal 52.2053370
         | 
| 977 977 | 
             
                  @field.value(:lng).must_equal 0.1218170
         | 
| 978 978 | 
             
                  @field.value(:country).must_equal "United Kingdom"
         | 
| 979 | 
            -
                  @field.value(:formatted_address).must_equal "Cambridge, UK"
         | 
| 979 | 
            +
                  @field.value(:formatted_address).must_equal "Cambridge, Cambridge, UK"
         | 
| 980 980 |  | 
| 981 981 | 
             
                  @field.latitude.must_equal 52.2053370
         | 
| 982 982 | 
             
                  @field.longitude.must_equal 0.1218170
         | 
| @@ -984,7 +984,7 @@ describe "Fields" do | |
| 984 984 | 
             
                  @field.lng.must_equal 0.1218170
         | 
| 985 985 |  | 
| 986 986 | 
             
                  @field.country.must_equal "United Kingdom"
         | 
| 987 | 
            -
                  @field.formatted_address.must_equal "Cambridge, UK"
         | 
| 987 | 
            +
                  @field.formatted_address.must_equal "Cambridge, Cambridge, UK"
         | 
| 988 988 | 
             
                end
         | 
| 989 989 | 
             
              end
         | 
| 990 990 |  | 
| @@ -474,7 +474,8 @@ describe "Publishing Pipeline" do | |
| 474 474 | 
             
                let(:application_path) { Pathname.new(File.expand_path("../../fixtures/example_application", __FILE__)) }
         | 
| 475 475 | 
             
                let(:fixtures_path) { application_path + "assets" }
         | 
| 476 476 | 
             
                let(:revision_root) { @site.revision_dir(revision) }
         | 
| 477 | 
            -
                let(: | 
| 477 | 
            +
                let(:development)   { false }
         | 
| 478 | 
            +
                let(:environment)   { Spontaneous::Asset::Environment.publishing(@site, revision, development) }
         | 
| 478 479 | 
             
                let(:manifest)      { environment.manifest }
         | 
| 479 480 | 
             
                let(:assets)        { environment.manifest.assets }
         | 
| 480 481 |  | 
| @@ -510,7 +511,7 @@ describe "Publishing Pipeline" do | |
| 510 511 | 
             
                  run_step(progress)
         | 
| 511 512 | 
             
                end
         | 
| 512 513 |  | 
| 513 | 
            -
                it "gives its step count as the number of  | 
| 514 | 
            +
                it "gives its step count as the number of assets" do
         | 
| 514 515 | 
             
                  step.count(@site, revision, nil).must_equal 3
         | 
| 515 516 | 
             
                end
         | 
| 516 517 |  | 
| @@ -541,6 +542,25 @@ describe "Publishing Pipeline" do | |
| 541 542 | 
             
                  lambda{ run_step }.must_raise(Exception)
         | 
| 542 543 | 
             
                end
         | 
| 543 544 |  | 
| 545 | 
            +
                describe 'development' do
         | 
| 546 | 
            +
                  let(:development) { true }
         | 
| 547 | 
            +
             | 
| 548 | 
            +
                  before do
         | 
| 549 | 
            +
                    Spontaneous.stubs(:development?).returns(true)
         | 
| 550 | 
            +
                  end
         | 
| 551 | 
            +
             | 
| 552 | 
            +
                  it "gives its step count as zero" do
         | 
| 553 | 
            +
                    step.count(@site, revision, nil).must_equal 0
         | 
| 554 | 
            +
                  end
         | 
| 555 | 
            +
             | 
| 556 | 
            +
                  it "never steps the progress" do
         | 
| 557 | 
            +
                    progress = mock
         | 
| 558 | 
            +
                    progress.stubs(:stage)
         | 
| 559 | 
            +
                    progress.expects(:step).with(1, instance_of(String)).never
         | 
| 560 | 
            +
                    run_step(progress)
         | 
| 561 | 
            +
                  end
         | 
| 562 | 
            +
                end
         | 
| 563 | 
            +
             | 
| 544 564 | 
             
              end
         | 
| 545 565 |  | 
| 546 566 | 
             
              describe "GenerateRackupFile" do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: spontaneous
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2.0. | 
| 4 | 
            +
              version: 0.2.0.beta9
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Garry Hill
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-10- | 
| 11 | 
            +
            date: 2014-10-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |