jsmestad-stale_fish 1.0.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/.document +5 -0
 - data/.gitignore +6 -0
 - data/LICENSE +20 -0
 - data/README.rdoc +50 -0
 - data/Rakefile +52 -0
 - data/VERSION +1 -0
 - data/lib/stale_fish.rb +95 -0
 - data/spec/fixtures/google.html +0 -0
 - data/spec/fixtures/malformed_stale_fish.yml +5 -0
 - data/spec/fixtures/stale_fish.yml +12 -0
 - data/spec/fixtures/yahoo.html +0 -0
 - data/spec/spec_helper.rb +9 -0
 - data/spec/stale_fish_spec.rb +55 -0
 - data/tmp/.gitignore +0 -0
 - metadata +97 -0
 
    
        data/.document
    ADDED
    
    
    
        data/.gitignore
    ADDED
    
    
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2009 Justin Smestad
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.rdoc
    ADDED
    
    | 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = Stale Fish
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This gem provides a method for keeping your fixtures in sync with their sources. This will prevent the scenario where your build is broken in production, but CI has a green build to do outdated fixture data.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            == How To
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Simply drop in a YAML file in your application (for rails, RAILS_ROOT/config/stale_fish.yml is preferred) and issue the following commands.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            A sample YAML file:
         
     | 
| 
      
 10 
     | 
    
         
            +
              --- 
         
     | 
| 
      
 11 
     | 
    
         
            +
              stale: 
         
     | 
| 
      
 12 
     | 
    
         
            +
                yahoo: 
         
     | 
| 
      
 13 
     | 
    
         
            +
                  filepath: ./tmp/yahoo.html
         
     | 
| 
      
 14 
     | 
    
         
            +
                  source: http://www.yahoo.com
         
     | 
| 
      
 15 
     | 
    
         
            +
                  updated: 
         
     | 
| 
      
 16 
     | 
    
         
            +
                  frequency: 1.day
         
     | 
| 
      
 17 
     | 
    
         
            +
                google: 
         
     | 
| 
      
 18 
     | 
    
         
            +
                  filepath: git_commit.json
         
     | 
| 
      
 19 
     | 
    
         
            +
                  source: http://api.github.com/post_commit/
         
     | 
| 
      
 20 
     | 
    
         
            +
                  updated: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                  frequency: 2.weeks
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Specify one block for every fixture you would like to update. The frequency field takes any relative date included in the ActiveSupport library.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            === RSpec
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            For a single test:
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              describe UsersController do
         
     | 
| 
      
 30 
     | 
    
         
            +
                before do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  StaleFish.load_config = "#{RAILS_ROOT}/config/stale_fish.yml"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  StaleFish.update_stale
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                ....
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            For all tests:
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              Spec::Runner.configure do |config|
         
     | 
| 
      
 40 
     | 
    
         
            +
                ...
         
     | 
| 
      
 41 
     | 
    
         
            +
                before do
         
     | 
| 
      
 42 
     | 
    
         
            +
                  StaleFish.load_config = "#{RAILS_ROOT}/config/stale_fish.yml"
         
     | 
| 
      
 43 
     | 
    
         
            +
                  StaleFish.update_stale
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                ....
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            == Copyright
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            Copyright (c) 2009 Justin Smestad. See LICENSE for details.
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            begin
         
     | 
| 
      
 5 
     | 
    
         
            +
              require 'jeweler'
         
     | 
| 
      
 6 
     | 
    
         
            +
              Jeweler::Tasks.new do |gem|
         
     | 
| 
      
 7 
     | 
    
         
            +
                gem.name = "stale_fish"
         
     | 
| 
      
 8 
     | 
    
         
            +
                gem.summary = %Q{keeps fixtures synchronized with sources to prevent outdated fixtures going undetected. }
         
     | 
| 
      
 9 
     | 
    
         
            +
                gem.email = "justin.smestad@gmail.com"
         
     | 
| 
      
 10 
     | 
    
         
            +
                gem.homepage = "http://github.com/jsmestad/stale_fish"
         
     | 
| 
      
 11 
     | 
    
         
            +
                gem.authors = ["Justin Smestad"]
         
     | 
| 
      
 12 
     | 
    
         
            +
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                gem.add_dependency "fakeweb", ">= 1.2.4"
         
     | 
| 
      
 15 
     | 
    
         
            +
                gem.add_dependency "rio", ">= 0.4.2"
         
     | 
| 
      
 16 
     | 
    
         
            +
                gem.add_dependency "activesupport", ">= 2.1.2"
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 20 
     | 
    
         
            +
              puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            require 'spec/rake/spectask'
         
     | 
| 
      
 24 
     | 
    
         
            +
            Spec::Rake::SpecTask.new(:spec) do |spec|
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.libs << 'lib' << 'spec'
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.spec_files = FileList['spec/**/*_spec.rb']
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Spec::Rake::SpecTask.new(:rcov) do |spec|
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.libs << 'lib' << 'spec'
         
     | 
| 
      
 31 
     | 
    
         
            +
              spec.pattern = 'spec/**/*_spec.rb'
         
     | 
| 
      
 32 
     | 
    
         
            +
              spec.rcov = true
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            task :default => :spec
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            require 'rake/rdoctask'
         
     | 
| 
      
 39 
     | 
    
         
            +
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
      
 40 
     | 
    
         
            +
              if File.exist?('VERSION.yml')
         
     | 
| 
      
 41 
     | 
    
         
            +
                config = YAML.load(File.read('VERSION.yml'))
         
     | 
| 
      
 42 
     | 
    
         
            +
                version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
         
     | 
| 
      
 43 
     | 
    
         
            +
              else
         
     | 
| 
      
 44 
     | 
    
         
            +
                version = ""
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 48 
     | 
    
         
            +
              rdoc.title = "stale_popcorn #{version}"
         
     | 
| 
      
 49 
     | 
    
         
            +
              rdoc.rdoc_files.include('README*')
         
     | 
| 
      
 50 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            1.0.0
         
     | 
    
        data/lib/stale_fish.rb
    ADDED
    
    | 
         @@ -0,0 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'singleton'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'ftools'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'activesupport' # only used for time helpers
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'rio'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module StaleFish
         
     | 
| 
      
 9 
     | 
    
         
            +
              # no one likes stale fish.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              def self.config_path=(path)
         
     | 
| 
      
 12 
     | 
    
         
            +
                @config_path = path
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              def self.config_path
         
     | 
| 
      
 16 
     | 
    
         
            +
                @config_path
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def self.valid_path?
         
     | 
| 
      
 20 
     | 
    
         
            +
                return false if @config_path.nil?
         
     | 
| 
      
 21 
     | 
    
         
            +
                File.exist?(@config_path)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              def self.update_stale(*args)
         
     | 
| 
      
 25 
     | 
    
         
            +
                # check each file for update
         
     | 
| 
      
 26 
     | 
    
         
            +
                load_yaml unless @yaml
         
     | 
| 
      
 27 
     | 
    
         
            +
                stale = flag_stale(args)
         
     | 
| 
      
 28 
     | 
    
         
            +
                process(stale)
         
     | 
| 
      
 29 
     | 
    
         
            +
                write_yaml
         
     | 
| 
      
 30 
     | 
    
         
            +
                return stale.size
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def self.load_yaml
         
     | 
| 
      
 34 
     | 
    
         
            +
                if valid_path?
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @yaml = YAML.load_file(@config_path)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  check_syntax
         
     | 
| 
      
 37 
     | 
    
         
            +
                else
         
     | 
| 
      
 38 
     | 
    
         
            +
                  raise Errno::ENOENT, 'invalid path, please set StaleFish.config_path than ensure StaleFish.valid_path? is true'
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            protected
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def self.check_syntax
         
     | 
| 
      
 45 
     | 
    
         
            +
                raise YAML::Error, 'missing stale root element' unless @yaml['stale']
         
     | 
| 
      
 46 
     | 
    
         
            +
                @yaml['stale'].each do |key, value|
         
     | 
| 
      
 47 
     | 
    
         
            +
                  %w{ filepath frequency source }.each do |field|
         
     | 
| 
      
 48 
     | 
    
         
            +
                    raise YAML::Error, "missing #{field} node for #{key}" unless @yaml['stale'][key][field]
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              def self.flag_stale(args)
         
     | 
| 
      
 54 
     | 
    
         
            +
                force = args.pop[:force] if args.last.is_a?(Hash)
         
     | 
| 
      
 55 
     | 
    
         
            +
                stale, scope = {}, @yaml['stale']
         
     | 
| 
      
 56 
     | 
    
         
            +
                scope.each do |key, value|
         
     | 
| 
      
 57 
     | 
    
         
            +
                  if args.empty?
         
     | 
| 
      
 58 
     | 
    
         
            +
                    if scope[key]['updated'].blank?
         
     | 
| 
      
 59 
     | 
    
         
            +
                      stale.merge!({key => scope[key]}) 
         
     | 
| 
      
 60 
     | 
    
         
            +
                    else
         
     | 
| 
      
 61 
     | 
    
         
            +
                      last_modified = scope[key]['updated']
         
     | 
| 
      
 62 
     | 
    
         
            +
                      update_on = DateTime.now + eval(scope[key]['frequency'])
         
     | 
| 
      
 63 
     | 
    
         
            +
                      stale.merge!({key => scope[key]}) if last_modified > update_on
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
      
 65 
     | 
    
         
            +
                  else
         
     | 
| 
      
 66 
     | 
    
         
            +
                    last_modified = scope[key]['updated']
         
     | 
| 
      
 67 
     | 
    
         
            +
                    update_on = DateTime.now + eval(scope[key]['frequency'])
         
     | 
| 
      
 68 
     | 
    
         
            +
                    if force == true
         
     | 
| 
      
 69 
     | 
    
         
            +
                      stale.merge!({key => scope[key]}) if args.include?(key)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    else
         
     | 
| 
      
 71 
     | 
    
         
            +
                      stale.merge!({key => scope[key]}) if args.include?(key) && (scope[key]['updated'].blank? || last_modified > update_on)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
                return stale
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              def self.process(fixtures)
         
     | 
| 
      
 79 
     | 
    
         
            +
                fixtures.each do |key, value|
         
     | 
| 
      
 80 
     | 
    
         
            +
                  rio(fixtures[key]['source']) > rio(fixtures[key]['filepath'])
         
     | 
| 
      
 81 
     | 
    
         
            +
                  update_fixture(key)
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def self.update_fixture(key)
         
     | 
| 
      
 86 
     | 
    
         
            +
                @yaml['stale'][key]['updated'] = DateTime.now
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              def self.write_yaml
         
     | 
| 
      
 90 
     | 
    
         
            +
                File.open(@config_path, "w+") do |f|
         
     | 
| 
      
 91 
     | 
    
         
            +
                  f.write(@yaml.to_yaml)
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "StaleFish" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @valid_yaml = File.dirname(__FILE__) + "/fixtures/stale_fish.yml"
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it "should assign the config file" do
         
     | 
| 
      
 9 
     | 
    
         
            +
                StaleFish.config_path = @valid_yaml
         
     | 
| 
      
 10 
     | 
    
         
            +
                StaleFish.config_path.should == @valid_yaml
         
     | 
| 
      
 11 
     | 
    
         
            +
                StaleFish.valid_path?.should == true
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              context "when loading the yaml file" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                it "should raise errors on malformed yaml" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  StaleFish.config_path = File.dirname(__FILE__) + "/fixtures/malformed_stale_fish.yml"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  lambda { StaleFish.load_yaml }.should_not raise_error(Errno::ENOENT)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  lambda { StaleFish.load_yaml }.should raise_error(YAML::Error)
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                it "should pass on valid yaml" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  StaleFish.config_path = @valid_yaml
         
     | 
| 
      
 23 
     | 
    
         
            +
                  lambda { StaleFish.load_yaml }.should_not raise_error(YAML::Error)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              context "after loading the config" do
         
     | 
| 
      
 28 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  FileUtils.cp(@valid_yaml, File.dirname(__FILE__)+"/fixtures/stale_fish.orig.yml")
         
     | 
| 
      
 30 
     | 
    
         
            +
                  StaleFish.config_path = @valid_yaml
         
     | 
| 
      
 31 
     | 
    
         
            +
                  StaleFish.valid_path?.should == true
         
     | 
| 
      
 32 
     | 
    
         
            +
                  StaleFish.load_yaml      
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                it "should update all stale fixtures" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  StaleFish.update_stale.should == 2
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                it "should update only the passed fixtures, if stale" do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  StaleFish.update_stale('google').should == 1
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                it "should update all passed fixtures, when passed the :force flag" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  StaleFish.update_stale('google').should == 1
         
     | 
| 
      
 45 
     | 
    
         
            +
                  StaleFish.update_stale('google', :force => true).should == 1
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                #it "should notify user, and rollback, if source is no longer valid"
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                after(:each) do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  FileUtils.mv(@valid_yaml, File.dirname(__FILE__)+"/../tmp/stale_fish.test.yml")
         
     | 
| 
      
 52 
     | 
    
         
            +
                  FileUtils.mv(File.dirname(__FILE__)+"/fixtures/stale_fish.orig.yml", @valid_yaml)      
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
    
        data/tmp/.gitignore
    ADDED
    
    | 
         
            File without changes
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: jsmestad-stale_fish
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Justin Smestad
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-07-01 00:00:00 -07:00
         
     | 
| 
      
 13 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: fakeweb
         
     | 
| 
      
 17 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 18 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 19 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 20 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 23 
     | 
    
         
            +
                    version: 1.2.4
         
     | 
| 
      
 24 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: rio
         
     | 
| 
      
 27 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 28 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 29 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 0.4.2
         
     | 
| 
      
 34 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 35 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 36 
     | 
    
         
            +
              name: activesupport
         
     | 
| 
      
 37 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 39 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 40 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 41 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 42 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 43 
     | 
    
         
            +
                    version: 2.1.2
         
     | 
| 
      
 44 
     | 
    
         
            +
                version: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 46 
     | 
    
         
            +
            email: justin.smestad@gmail.com
         
     | 
| 
      
 47 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 52 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 53 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 54 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 55 
     | 
    
         
            +
            - .document
         
     | 
| 
      
 56 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 57 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 58 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 59 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 60 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 61 
     | 
    
         
            +
            - lib/stale_fish.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - spec/fixtures/google.html
         
     | 
| 
      
 63 
     | 
    
         
            +
            - spec/fixtures/malformed_stale_fish.yml
         
     | 
| 
      
 64 
     | 
    
         
            +
            - spec/fixtures/stale_fish.yml
         
     | 
| 
      
 65 
     | 
    
         
            +
            - spec/fixtures/yahoo.html
         
     | 
| 
      
 66 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - spec/stale_fish_spec.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - tmp/.gitignore
         
     | 
| 
      
 69 
     | 
    
         
            +
            has_rdoc: false
         
     | 
| 
      
 70 
     | 
    
         
            +
            homepage: http://github.com/jsmestad/stale_fish
         
     | 
| 
      
 71 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 72 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 73 
     | 
    
         
            +
            - --charset=UTF-8
         
     | 
| 
      
 74 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 76 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 77 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 78 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 79 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 80 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 81 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 82 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 83 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 84 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 85 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 86 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 87 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 88 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 91 
     | 
    
         
            +
            rubygems_version: 1.2.0
         
     | 
| 
      
 92 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 93 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 94 
     | 
    
         
            +
            summary: keeps fixtures synchronized with sources to prevent outdated fixtures going undetected.
         
     | 
| 
      
 95 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 96 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - spec/stale_fish_spec.rb
         
     |