Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 4375 Bytes
1 | ENV["RAILS_ENV"] = 'test' |
2 | RAILS_ENV = 'test' |
3 | BASE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '../../')) |
4 | require 'fileutils' |
5 | require 'tempfile' |
6 | require 'spec' |
7 | require File.join(BASE_ROOT, 'spec/matchers/generator_matchers') |
8 | require File.join(BASE_ROOT, 'lib/plugins/string_extensions/lib/string_extensions') |
9 | |
10 | unless defined?(::GENERATOR_SUPPORT_LOADED) && ::GENERATOR_SUPPORT_LOADED |
11 | # this is so we can require ActiveSupport |
12 | $:.unshift File.join(BASE_ROOT, 'vendor/rails/activesupport/lib') |
13 | # This is so the initializer and Rails::Generator is properly found |
14 | $:.unshift File.join(BASE_ROOT, 'vendor/rails/railties/lib') |
15 | require 'active_support' |
16 | |
17 | # Mock out what we need from AR::Base |
18 | module ActiveRecord |
19 | class Base |
20 | class << self |
21 | attr_accessor :pluralize_table_names, :timestamped_migrations |
22 | end |
23 | self.pluralize_table_names = true |
24 | self.timestamped_migrations = true |
25 | end |
26 | |
27 | module ConnectionAdapters |
28 | class Column |
29 | attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale |
30 | |
31 | def initialize(name, default, sql_type = nil) |
32 | @name = name |
33 | @default = default |
34 | @type = @sql_type = sql_type |
35 | end |
36 | |
37 | def human_name |
38 | @name.humanize |
39 | end |
40 | end |
41 | end |
42 | end |
43 | |
44 | # Mock up necessities from ActionView |
45 | module ActionView |
46 | module Helpers |
47 | module ActionRecordHelper; end |
48 | class InstanceTag; end |
49 | end |
50 | end |
51 | |
52 | # Set RAILS_ROOT appropriately fixture generation |
53 | tmp_dir = File.expand_path(File.join(Dir.tmpdir, 'radiant')) |
54 | $stdout << "#{tmp_dir}\n\n" |
55 | FileUtils.mkdir_p tmp_dir |
56 | |
57 | if defined? RADIANT_ROOT |
58 | RADIANT_ROOT.replace tmp_dir.dup |
59 | else |
60 | RADIANT_ROOT = tmp_dir.dup |
61 | end |
62 | |
63 | if defined? RAILS_ROOT |
64 | RAILS_ROOT.replace tmp_dir.dup |
65 | else |
66 | RAILS_ROOT = tmp_dir.dup |
67 | end |
68 | |
69 | require 'initializer' |
70 | |
71 | # Mocks out the configuration |
72 | module Rails |
73 | def self.configuration |
74 | Rails::Configuration.new |
75 | end |
76 | end |
77 | |
78 | require 'rails_generator' |
79 | |
80 | module GeneratorSpecHelperMethods |
81 | # Instantiates the Generator. |
82 | def build_generator(name, params) |
83 | Rails::Generator::Base.instance(name, params) |
84 | end |
85 | |
86 | # Runs the +create+ command (like the command line does). |
87 | def run_generator(name, params) |
88 | silence_generator do |
89 | build_generator(name, params).command(:create).invoke! |
90 | end |
91 | end |
92 | |
93 | # Silences the logger temporarily and returns the output as a String. |
94 | def silence_generator |
95 | logger_original = Rails::Generator::Base.logger |
96 | myout = StringIO.new |
97 | Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(myout) |
98 | yield if block_given? |
99 | Rails::Generator::Base.logger = logger_original |
100 | myout.string |
101 | end |
102 | |
103 | # Run the block with RADIANT_ROOT replaced with BASE_ROOT |
104 | def with_radiant_root_as_base_root |
105 | prev_radiant_root = RADIANT_ROOT.dup |
106 | RADIANT_ROOT.replace BASE_ROOT.dup |
107 | begin |
108 | yield |
109 | ensure |
110 | RADIANT_ROOT.replace prev_radiant_root |
111 | end |
112 | end |
113 | |
114 | # Run the block with $stdout suppressed |
115 | def suppress_stdout |
116 | original_stdout = $stdout |
117 | $stdout = fake = StringIO.new |
118 | begin |
119 | yield |
120 | ensure |
121 | $stdout = original_stdout |
122 | end |
123 | fake.string |
124 | end |
125 | end |
126 | |
127 | share_as :AllGenerators do |
128 | include FileUtils |
129 | include GeneratorSpecHelperMethods |
130 | |
131 | before(:all) do |
132 | ActiveRecord::Base.pluralize_table_names = true |
133 | |
134 | mkdir_p "#{RADIANT_ROOT}/app" |
135 | mkdir_p "#{RADIANT_ROOT}/config" |
136 | mkdir_p "#{RADIANT_ROOT}/db" |
137 | mkdir_p "#{RADIANT_ROOT}/vendor/generators" |
138 | mkdir_p "#{RADIANT_ROOT}/vendor/extensions" |
139 | |
140 | File.open("#{RADIANT_ROOT}/config/routes.rb", 'w') do |f| |
141 | f << "ActionController::Routing::Routes.draw do |map|\n\nend" |
142 | end |
143 | end |
144 | |
145 | after(:all) do |
146 | %w(app db config vendor).each do |dir| |
147 | rm_rf File.join(RADIANT_ROOT, dir) |
148 | end |
149 | end |
150 | end |
151 | |
152 | share_as :AllExtensionGenerators do |
153 | before(:all) do |
154 | cp_r File.join(BASE_ROOT, 'spec/fixtures/example_extension'), File.join(RADIANT_ROOT, 'vendor/extensions/example') |
155 | end |
156 | end |
157 | |
158 | GENERATOR_SUPPORT_LOADED = true |
159 | end |
160 | |
161 | Git = Module.new unless defined?(::Git) |
162 | |
163 | Spec::Runner.configure do |config| |
164 | config.include(Spec::Matchers::GeneratorMatchers) |
165 | end |
166 |