versionist 0.2.4 → 0.3.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.
| 
         @@ -14,25 +14,6 @@ module Versionist 
     | 
|
| 
       14 
14 
     | 
    
         
             
                argument :new_version, :type => :string
         
     | 
| 
       15 
15 
     | 
    
         
             
                argument :new_module_name, :type => :string
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                def validate_old_version
         
     | 
| 
       18 
     | 
    
         
            -
                  in_root do
         
     | 
| 
       19 
     | 
    
         
            -
                    api_version_block = /api_version.*:module\s*(=>|:)\s*("|')#{module_name_for_route(old_module_name)}("|').*do/
         
     | 
| 
       20 
     | 
    
         
            -
                    matching_version_blocks = File.readlines("config/routes.rb").grep(api_version_block)
         
     | 
| 
       21 
     | 
    
         
            -
                    raise "old API version #{old_module_name} not found in config/routes.rb" if matching_version_blocks.empty?
         
     | 
| 
       22 
     | 
    
         
            -
                    raise "old API version module namespace #{old_module_name} not found in app/controllers" if !File.exists?("app/controllers/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       23 
     | 
    
         
            -
                    raise "old API version module namespace #{old_module_name} not found in app/presenters" if !File.exists?("app/presenters/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       24 
     | 
    
         
            -
                    case Versionist.configuration.configured_test_framework
         
     | 
| 
       25 
     | 
    
         
            -
                    when :test_unit
         
     | 
| 
       26 
     | 
    
         
            -
                      raise "old API version module namespace #{old_module_name} not found in test/functional/#{module_name_for_path(old_module_name)}" if !File.exists?("test/functional/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       27 
     | 
    
         
            -
                      raise "old API version module namespace #{old_module_name} not found in test/presenters/#{module_name_for_path(old_module_name)}" if !File.exists?("test/presenters/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       28 
     | 
    
         
            -
                    when :rspec
         
     | 
| 
       29 
     | 
    
         
            -
                      raise "old API version module namespace #{old_module_name} not found in spec/controllers/#{module_name_for_path(old_module_name)}" if !File.exists?("spec/controllers/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       30 
     | 
    
         
            -
                      raise "old API version module namespace #{old_module_name} not found in spec/presenters/#{module_name_for_path(old_module_name)}" if !File.exists?("spec/presenters/#{module_name_for_path(old_module_name)}")
         
     | 
| 
       31 
     | 
    
         
            -
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                    raise "old API version #{old_version} not found in public/docs" if !File.exists?("public/docs/#{old_version}")
         
     | 
| 
       33 
     | 
    
         
            -
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
17 
     | 
    
         
             
                def copy_routes
         
     | 
| 
       37 
18 
     | 
    
         
             
                  in_root do
         
     | 
| 
       38 
19 
     | 
    
         
             
                    if RUBY_VERSION =~ /1.8/ || !defined?(RUBY_ENGINE) || RUBY_ENGINE != "ruby"
         
     | 
| 
         @@ -44,20 +25,28 @@ module Versionist 
     | 
|
| 
       44 
25 
     | 
    
         
             
                    parser.enumerator.first.traverse do |node|
         
     | 
| 
       45 
26 
     | 
    
         
             
                      existing_routes = node.source if node.type == :fcall && node.source =~ /api_version.*:module\s*(=>|:)\s*("|')#{module_name_for_route(old_module_name)}("|')/
         
     | 
| 
       46 
27 
     | 
    
         
             
                    end
         
     | 
| 
       47 
     | 
    
         
            -
                     
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                    if !existing_routes.nil?
         
     | 
| 
      
 29 
     | 
    
         
            +
                      copied_routes = String.new(existing_routes)
         
     | 
| 
      
 30 
     | 
    
         
            +
                      copied_routes.gsub!(/"#{module_name_for_route(old_module_name)}"/, "\"#{module_name_for_route(new_module_name)}\"")
         
     | 
| 
      
 31 
     | 
    
         
            +
                      copied_routes.gsub!(/#{old_version}/, new_version)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      route copied_routes
         
     | 
| 
      
 33 
     | 
    
         
            +
                    else
         
     | 
| 
      
 34 
     | 
    
         
            +
                      say "No routes found in config/routes.rb for #{old_version}"
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
       51 
36 
     | 
    
         
             
                  end
         
     | 
| 
       52 
37 
     | 
    
         
             
                end
         
     | 
| 
       53 
38 
     | 
    
         | 
| 
       54 
39 
     | 
    
         
             
                def copy_controllers
         
     | 
| 
       55 
40 
     | 
    
         
             
                  in_root do
         
     | 
| 
       56 
     | 
    
         
            -
                     
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                       
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
                    if File.exists? "app/controllers/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                      log "Copying all files from app/controllers/#{module_name_for_path(old_module_name)} to app/controllers/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 43 
     | 
    
         
            +
                      FileUtils.cp_r "app/controllers/#{module_name_for_path(old_module_name)}", "app/controllers/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                      Dir.glob("app/controllers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 45 
     | 
    
         
            +
                        text = File.read(f)
         
     | 
| 
      
 46 
     | 
    
         
            +
                        File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 47 
     | 
    
         
            +
                      end
         
     | 
| 
      
 48 
     | 
    
         
            +
                    else
         
     | 
| 
      
 49 
     | 
    
         
            +
                      say "No controllers found in app/controllers for #{old_version}"
         
     | 
| 
       61 
50 
     | 
    
         
             
                    end
         
     | 
| 
       62 
51 
     | 
    
         
             
                  end
         
     | 
| 
       63 
52 
     | 
    
         
             
                end
         
     | 
| 
         @@ -67,18 +56,26 @@ module Versionist 
     | 
|
| 
       67 
56 
     | 
    
         
             
                  in_root do
         
     | 
| 
       68 
57 
     | 
    
         
             
                    case Versionist.configuration.configured_test_framework
         
     | 
| 
       69 
58 
     | 
    
         
             
                    when :test_unit
         
     | 
| 
       70 
     | 
    
         
            -
                       
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
                      if File.exists? "test/functional/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 60 
     | 
    
         
            +
                        log "Copying all files from test/functional/#{module_name_for_path(old_module_name)} to test/functional/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 61 
     | 
    
         
            +
                        FileUtils.cp_r "test/functional/#{module_name_for_path(old_module_name)}", "test/functional/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 62 
     | 
    
         
            +
                        Dir.glob("test/functional/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 63 
     | 
    
         
            +
                          text = File.read(f)
         
     | 
| 
      
 64 
     | 
    
         
            +
                          File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 65 
     | 
    
         
            +
                        end
         
     | 
| 
      
 66 
     | 
    
         
            +
                      else
         
     | 
| 
      
 67 
     | 
    
         
            +
                        say "No controller tests found in test/functional for #{old_version}"
         
     | 
| 
       75 
68 
     | 
    
         
             
                      end
         
     | 
| 
       76 
69 
     | 
    
         
             
                    when :rspec
         
     | 
| 
       77 
     | 
    
         
            -
                       
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                      if File.exists? "spec/controllers/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 71 
     | 
    
         
            +
                        log "Copying all files from spec/controllers/#{module_name_for_path(old_module_name)} to spec/controllers/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 72 
     | 
    
         
            +
                        FileUtils.cp_r "spec/controllers/#{module_name_for_path(old_module_name)}", "spec/controllers/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 73 
     | 
    
         
            +
                        Dir.glob("spec/controllers/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 74 
     | 
    
         
            +
                          text = File.read(f)
         
     | 
| 
      
 75 
     | 
    
         
            +
                          File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 76 
     | 
    
         
            +
                        end
         
     | 
| 
      
 77 
     | 
    
         
            +
                      else
         
     | 
| 
      
 78 
     | 
    
         
            +
                        say "No controller specs found in spec/controllers for #{old_version}"
         
     | 
| 
       82 
79 
     | 
    
         
             
                      end
         
     | 
| 
       83 
80 
     | 
    
         
             
                    else
         
     | 
| 
       84 
81 
     | 
    
         
             
                      say "Unsupported test_framework: #{Versionist.configuration.configured_test_framework}"
         
     | 
| 
         @@ -88,11 +85,15 @@ module Versionist 
     | 
|
| 
       88 
85 
     | 
    
         | 
| 
       89 
86 
     | 
    
         
             
                def copy_presenters
         
     | 
| 
       90 
87 
     | 
    
         
             
                  in_root do
         
     | 
| 
       91 
     | 
    
         
            -
                     
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                       
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
                    if File.exists? "app/presenters/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 89 
     | 
    
         
            +
                      log "Copying all files from app/presenters/#{module_name_for_path(old_module_name)} to app/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 90 
     | 
    
         
            +
                      FileUtils.cp_r "app/presenters/#{module_name_for_path(old_module_name)}", "app/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 91 
     | 
    
         
            +
                      Dir.glob("app/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 92 
     | 
    
         
            +
                        text = File.read(f)
         
     | 
| 
      
 93 
     | 
    
         
            +
                        File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 94 
     | 
    
         
            +
                      end
         
     | 
| 
      
 95 
     | 
    
         
            +
                    else
         
     | 
| 
      
 96 
     | 
    
         
            +
                      say "No presenters found in app/presenters for #{old_version}"
         
     | 
| 
       96 
97 
     | 
    
         
             
                    end
         
     | 
| 
       97 
98 
     | 
    
         
             
                  end
         
     | 
| 
       98 
99 
     | 
    
         
             
                end
         
     | 
| 
         @@ -101,18 +102,26 @@ module Versionist 
     | 
|
| 
       101 
102 
     | 
    
         
             
                  in_root do
         
     | 
| 
       102 
103 
     | 
    
         
             
                    case Versionist.configuration.configured_test_framework
         
     | 
| 
       103 
104 
     | 
    
         
             
                    when :test_unit
         
     | 
| 
       104 
     | 
    
         
            -
                       
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
                         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 105 
     | 
    
         
            +
                      if File.exists? "test/presenters/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 106 
     | 
    
         
            +
                        log "Copying all files from test/presenters/#{module_name_for_path(old_module_name)} to test/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 107 
     | 
    
         
            +
                        FileUtils.cp_r "test/presenters/#{module_name_for_path(old_module_name)}", "test/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 108 
     | 
    
         
            +
                        Dir.glob("test/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 109 
     | 
    
         
            +
                          text = File.read(f)
         
     | 
| 
      
 110 
     | 
    
         
            +
                          File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 111 
     | 
    
         
            +
                        end
         
     | 
| 
      
 112 
     | 
    
         
            +
                      else
         
     | 
| 
      
 113 
     | 
    
         
            +
                        say "No presenter tests found in test/presenters for #{old_version}"
         
     | 
| 
       109 
114 
     | 
    
         
             
                      end
         
     | 
| 
       110 
115 
     | 
    
         
             
                    when :rspec
         
     | 
| 
       111 
     | 
    
         
            -
                       
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
                      if File.exists? "spec/presenters/#{module_name_for_path(old_module_name)}"
         
     | 
| 
      
 117 
     | 
    
         
            +
                        log "Copying all files from spec/presenters/#{module_name_for_path(old_module_name)} to spec/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 118 
     | 
    
         
            +
                        FileUtils.cp_r "spec/presenters/#{module_name_for_path(old_module_name)}", "spec/presenters/#{module_name_for_path(new_module_name)}"
         
     | 
| 
      
 119 
     | 
    
         
            +
                        Dir.glob("spec/presenters/#{module_name_for_path(new_module_name)}/*.rb").each do |f|
         
     | 
| 
      
 120 
     | 
    
         
            +
                          text = File.read(f)
         
     | 
| 
      
 121 
     | 
    
         
            +
                          File.open(f, 'w') {|f| f << text.gsub(/#{old_module_name}/, new_module_name)}
         
     | 
| 
      
 122 
     | 
    
         
            +
                        end
         
     | 
| 
      
 123 
     | 
    
         
            +
                      else
         
     | 
| 
      
 124 
     | 
    
         
            +
                        say "No presenter specs found in spec/presenters for #{old_version}"
         
     | 
| 
       116 
125 
     | 
    
         
             
                      end
         
     | 
| 
       117 
126 
     | 
    
         
             
                    else
         
     | 
| 
       118 
127 
     | 
    
         
             
                      say "Unsupported test_framework: #{Versionist.configuration.configured_test_framework}"
         
     | 
| 
         @@ -122,11 +131,11 @@ module Versionist 
     | 
|
| 
       122 
131 
     | 
    
         | 
| 
       123 
132 
     | 
    
         
             
                def copy_documentation
         
     | 
| 
       124 
133 
     | 
    
         
             
                  in_root do
         
     | 
| 
       125 
     | 
    
         
            -
                     
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                       
     | 
| 
      
 134 
     | 
    
         
            +
                    if File.exists? "public/docs/#{old_version}"
         
     | 
| 
      
 135 
     | 
    
         
            +
                      log "Copying all files from public/docs/#{old_version} to public/docs/#{new_version}"
         
     | 
| 
      
 136 
     | 
    
         
            +
                      FileUtils.cp_r "public/docs/#{old_version}/.", "public/docs/#{new_version}"
         
     | 
| 
      
 137 
     | 
    
         
            +
                    else
         
     | 
| 
      
 138 
     | 
    
         
            +
                      say "No documentation found in public/docs for #{old_version}"
         
     | 
| 
       130 
139 
     | 
    
         
             
                    end
         
     | 
| 
       131 
140 
     | 
    
         
             
                  end
         
     | 
| 
       132 
141 
     | 
    
         
             
                end
         
     | 
    
        data/lib/versionist/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            name: versionist
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 5 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors: 
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Brian Ploetz
         
     | 
| 
         @@ -10,7 +10,7 @@ autorequire: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            date: 2012-07- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2012-07-27 00:00:00 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -105,7 +105,7 @@ rubyforge_project: 
     | 
|
| 
       105 
105 
     | 
    
         
             
            rubygems_version: 1.8.17
         
     | 
| 
       106 
106 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       107 
107 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       108 
     | 
    
         
            -
            summary: versionist-0. 
     | 
| 
      
 108 
     | 
    
         
            +
            summary: versionist-0.3.0
         
     | 
| 
       109 
109 
     | 
    
         
             
            test_files: []
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
            has_rdoc: 
         
     |