Class: FrameworkFixture
- Inherits:
-
Object
- Object
- FrameworkFixture
- Defined in:
- lib/framework_fixture.rb
Class Attribute Summary collapse
-
.app ⇒ Object
readonly
Returns the value of attribute app.
-
.build ⇒ Object
readonly
Returns the value of attribute build.
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.exact_version ⇒ Object
readonly
Returns the value of attribute exact_version.
-
.framework ⇒ Object
readonly
Returns the value of attribute framework.
-
.loose_version ⇒ Object
readonly
Returns the value of attribute loose_version.
-
.root ⇒ Object
Returns the value of attribute root.
Class Method Summary collapse
- .create_build ⇒ Object
- .generate(root) ⇒ Object
- .load_config ⇒ Object
- .require_gem ⇒ Object
- .set_vars ⇒ Object
Class Attribute Details
.app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def app @app end |
.build ⇒ Object (readonly)
Returns the value of attribute build.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def build @build end |
.config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def config @config end |
.exact_version ⇒ Object (readonly)
Returns the value of attribute exact_version.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def exact_version @exact_version end |
.framework ⇒ Object (readonly)
Returns the value of attribute framework.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def framework @framework end |
.loose_version ⇒ Object (readonly)
Returns the value of attribute loose_version.
13 14 15 |
# File 'lib/framework_fixture.rb', line 13 def loose_version @loose_version end |
.root ⇒ Object
Returns the value of attribute root.
12 13 14 |
# File 'lib/framework_fixture.rb', line 12 def root @root end |
Class Method Details
.create_build ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/framework_fixture.rb', line 15 def create_build FileUtils.mkdir_p @build = "#{@root}/builds" if rails case @exact_version[0..0] when '2' then @build += "/rails2" @app = lambda { ActionController::Dispatcher.new } cmd = "rails _#{@exact_version}_ #{@build}" when '3' then @build += "/rails3" @app = lambda { Rails3::Application } cmd = "rails _#{@exact_version}_ new #{@build}" end req = @build + "/config/environment.rb" elsif sinatra @build += "/sinatra#{@exact_version[0..0]}" @app = lambda { Application.new } req = @build + "/application.rb" elsif stasis @build += "/stasis#{@exact_version[0..0]}" @app = lambda do Stasis.new(@build, "#{@build}_output") end end unless File.exists?(@build) if cmd puts "Generating framework build: #{cmd}" puts `#{cmd}` else FileUtils.mkdir_p @build end end if @config[@framework] && config = @config[@framework][@loose_version] config.each do |dir, files| files.each do |f| if File.exists?(from = "#{@root}/#{dir}/#{File.basename(f)}") FileUtils.mkdir_p File.dirname("#{@build}/#{f}") FileUtils.cp from, "#{@build}/#{f}" end end end end require req if req end |
.generate(root) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/framework_fixture.rb', line 64 def generate(root) @root = root load_config require_gem create_build end |
.load_config ⇒ Object
72 73 74 75 |
# File 'lib/framework_fixture.rb', line 72 def load_config @config = File.read(@root + '/frameworks.yml') @config = YAML::load(@config) end |
.require_gem ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/framework_fixture.rb', line 77 def require_gem set_vars if @framework gem @framework, @loose_version @exact_version = Gem.loaded_specs[@framework].version.to_s end end |
.set_vars ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/framework_fixture.rb', line 86 def set_vars if ENV['RAILS'] @framework = 'rails' elsif ENV['SINATRA'] @framework = 'sinatra' elsif ENV['STASIS'] @framework = 'stasis' end if @framework @loose_version = ENV['RAILS'] || ENV['SINATRA'] || ENV['STASIS'] if @loose_version.match(/\d*/)[0].length == @loose_version.length @loose_version = "<#{@loose_version.to_i + 1}" end end end |