wagons 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
- <%= app_root_initializer %>
1
+ require File.expand_path('../app_root', __FILE__)
2
2
 
3
- source "http://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Declare your gem's dependencies in <%= singular_name %>.gemspec.
6
6
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -7,6 +7,6 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  ENGINE_PATH = File.expand_path('..', __FILE__)
10
- <%= app_root_initializer %>
10
+ require File.expand_path('../app_root', __FILE__)
11
11
 
12
12
  load 'wagons/wagon_tasks.rake'
@@ -0,0 +1,2 @@
1
+ # define the root directory of the main application
2
+ ENV['APP_ROOT'] ||= File.expand_path(__FILE__).split("vendor#{File::SEPARATOR}wagons").first
@@ -6,6 +6,6 @@ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
6
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', ENGINE_ROOT)
7
7
  ENGINE_PATH = File.expand_path('lib/<%= singular_name %>/engine', ENGINE_ROOT)
8
8
 
9
- <%= app_root_initializer %>
9
+ require File.expand_path('../../app_root', __FILE__)
10
10
 
11
11
  load File.expand_path('script/rails', ENV["APP_ROOT"])
@@ -1,8 +1,8 @@
1
1
  # Configure Rails Environment
2
- <%= app_root_initializer %>
2
+ require File.expand_path('../../app_root', __FILE__)
3
3
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
4
4
 
5
- require File.join(ENV["APP_ROOT"], 'test', 'test_helper.rb')
5
+ require File.expand_path('test/test_helper.rb', ENV['APP_ROOT'])
6
6
 
7
7
 
8
8
  class ActiveSupport::TestCase
@@ -1,20 +1,18 @@
1
1
  class WagonGenerator < Rails::Generators::NamedBase #:nodoc:
2
-
3
- attr_reader :wagon_name, :app_root_initializer
4
-
2
+
3
+ attr_reader :wagon_name
4
+
5
5
  source_root File.expand_path('../templates', __FILE__)
6
-
6
+
7
7
  def initialize(*args)
8
8
  super
9
9
  @wagon_name = name
10
- @app_root_initializer = "ENV['APP_ROOT'] ||= File.expand_path(__FILE__).split(\"vendor\#{File::SEPARATOR}wagons\").first"
11
-
12
10
  assign_names!("#{application_name}_#{name}")
13
11
  end
14
-
12
+
15
13
  def copy_templates
16
14
  self.destination_root = "vendor/wagons/#{wagon_name}"
17
-
15
+
18
16
  # do this whole manual traversal to be able to replace every single file
19
17
  # individually in the application.
20
18
  all_templates.each do |file|
@@ -26,9 +24,9 @@ class WagonGenerator < Rails::Generators::NamedBase #:nodoc:
26
24
  end
27
25
  end
28
26
  end
29
-
27
+
30
28
  private
31
-
29
+
32
30
  def all_templates
33
31
  source_paths.collect do |path|
34
32
  Dir[File.join(path, "**", "{*,.[a-z]*}")].
@@ -36,5 +34,5 @@ class WagonGenerator < Rails::Generators::NamedBase #:nodoc:
36
34
  collect {|f| f.sub(path + File::SEPARATOR, '') }
37
35
  end.flatten.uniq.sort
38
36
  end
39
-
37
+
40
38
  end
@@ -1,3 +1,3 @@
1
1
  module Wagons
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -16,6 +16,26 @@ rescue LoadError
16
16
  RDoc::Task = Rake::RDocTask
17
17
  end
18
18
 
19
+ APP_RAKEFILE = File.join(ENV['APP_ROOT'], "Rakefile")
20
+
21
+ def app_task(name)
22
+ task name => [:load_app, "app:db:#{name}"]
23
+ end
24
+
25
+ def find_engine_path(path)
26
+ return if path == "/"
27
+
28
+ if Rails::Engine.find(path)
29
+ path
30
+ else
31
+ find_engine_path(File.expand_path('..', path))
32
+ end
33
+ end
34
+
35
+ def wagon
36
+ @wagon ||= Rails::Engine.find(ENGINE_PATH)
37
+ end
38
+
19
39
 
20
40
  Rake::TestTask.new(:test) do |t|
21
41
  t.libs << 'lib'
@@ -37,26 +57,6 @@ end
37
57
  Bundler::GemHelper.install_tasks
38
58
 
39
59
 
40
- APP_RAKEFILE = File.join(ENV['APP_ROOT'], "Rakefile")
41
-
42
- def app_task(name)
43
- task name => [:load_app, "app:db:#{name}"]
44
- end
45
-
46
- def find_engine_path(path)
47
- return if path == "/"
48
-
49
- if Rails::Engine.find(path)
50
- path
51
- else
52
- find_engine_path(File.expand_path('..', path))
53
- end
54
- end
55
-
56
- def wagon
57
- @wagon ||= Rails::Engine.find(ENGINE_PATH)
58
- end
59
-
60
60
  task "load_app" do
61
61
  namespace :app do
62
62
  load APP_RAKEFILE
@@ -74,7 +74,7 @@ namespace :db do
74
74
  task :migrate => [:load_app, 'app:environment', 'app:db:load_config'] do
75
75
  wagon.migrate
76
76
  end
77
-
77
+
78
78
  desc "Revert the database (options: VERSION=x, VERBOSE=false)."
79
79
  task :revert => [:load_app, 'app:environment', 'app:db:load_config'] do
80
80
  wagon.revert
@@ -89,16 +89,16 @@ namespace :db do
89
89
  task "unseed" => [:load_app, 'app:db:abort_if_pending_migrations'] do
90
90
  wagon.unload_seed
91
91
  end
92
-
92
+
93
93
  desc "Run migrations and seed data (use db:reset to also revert the db first)"
94
94
  task :setup => [:migrate, :seed]
95
-
95
+
96
96
  desc "Revert the database and set it up again"
97
97
  task :reset => [:unseed, :revert, :setup]
98
-
98
+
99
99
  desc "Display status of migrations"
100
100
  app_task "migrate:status"
101
-
101
+
102
102
  app_task "test:prepare"
103
103
  end
104
104
 
@@ -112,10 +112,10 @@ namespace :app do
112
112
  # set migrations paths to core only to have db:test:prepare work as desired
113
113
  ActiveRecord::Migrator.migrations_paths = Rails.application.paths['db/migrate'].to_a
114
114
  end
115
-
115
+
116
116
  namespace :test do
117
117
  # for sqlite, make sure to delete the test.sqlite3 from the main application
118
- task :purge do
118
+ task :purge do
119
119
  abcs = ActiveRecord::Base.configurations
120
120
  case abcs['test']['adapter']
121
121
  when /sqlite/
@@ -123,16 +123,16 @@ namespace :app do
123
123
  File.delete(dbfile) if File.exist?(dbfile)
124
124
  end
125
125
  end
126
-
126
+
127
127
  # run wagon migrations and load seed data.
128
128
  # append this to the regular app:db:test:prepare task.
129
129
  task :prepare do
130
130
  Rails.env = 'test'
131
131
  dependencies = (wagon.all_dependencies + [wagon])
132
-
133
- # migrate
132
+
133
+ # migrate
134
134
  dependencies.each { |d| d.migrate }
135
-
135
+
136
136
  # seed
137
137
  SeedFu.quiet = true unless ENV['VERBOSE']
138
138
  SeedFu.seed([ Rails.root.join('db/fixtures').to_s,
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /home/pzumkehr/src/ruby/wagons
3
3
  specs:
4
- wagons (0.1.0)
4
+ wagons (0.1.1)
5
5
  bundler (>= 1.1)
6
6
  rails (>= 3.2)
7
7
  seed-fu-ndo (>= 0.0.2)
@@ -19,74 +19,73 @@ PATH
19
19
  GEM
20
20
  remote: http://rubygems.org/
21
21
  specs:
22
- actionmailer (3.2.9)
23
- actionpack (= 3.2.9)
24
- mail (~> 2.4.4)
25
- actionpack (3.2.9)
26
- activemodel (= 3.2.9)
27
- activesupport (= 3.2.9)
22
+ actionmailer (3.2.13)
23
+ actionpack (= 3.2.13)
24
+ mail (~> 2.5.3)
25
+ actionpack (3.2.13)
26
+ activemodel (= 3.2.13)
27
+ activesupport (= 3.2.13)
28
28
  builder (~> 3.0.0)
29
29
  erubis (~> 2.7.0)
30
30
  journey (~> 1.0.4)
31
- rack (~> 1.4.0)
31
+ rack (~> 1.4.5)
32
32
  rack-cache (~> 1.2)
33
33
  rack-test (~> 0.6.1)
34
34
  sprockets (~> 2.2.1)
35
- activemodel (3.2.9)
36
- activesupport (= 3.2.9)
35
+ activemodel (3.2.13)
36
+ activesupport (= 3.2.13)
37
37
  builder (~> 3.0.0)
38
- activerecord (3.2.9)
39
- activemodel (= 3.2.9)
40
- activesupport (= 3.2.9)
38
+ activerecord (3.2.13)
39
+ activemodel (= 3.2.13)
40
+ activesupport (= 3.2.13)
41
41
  arel (~> 3.0.2)
42
42
  tzinfo (~> 0.3.29)
43
- activeresource (3.2.9)
44
- activemodel (= 3.2.9)
45
- activesupport (= 3.2.9)
46
- activesupport (3.2.9)
47
- i18n (~> 0.6)
43
+ activeresource (3.2.13)
44
+ activemodel (= 3.2.13)
45
+ activesupport (= 3.2.13)
46
+ activesupport (3.2.13)
47
+ i18n (= 0.6.1)
48
48
  multi_json (~> 1.0)
49
49
  arel (3.0.2)
50
50
  builder (3.0.4)
51
51
  erubis (2.7.0)
52
- hike (1.2.1)
52
+ hike (1.2.2)
53
53
  i18n (0.6.1)
54
54
  journey (1.0.4)
55
- json (1.7.5)
56
- mail (2.4.4)
57
- i18n (>= 0.4.0)
55
+ json (1.8.0)
56
+ mail (2.5.4)
58
57
  mime-types (~> 1.16)
59
58
  treetop (~> 1.4.8)
60
59
  metaclass (0.0.1)
61
- mime-types (1.19)
62
- mocha (0.12.3)
60
+ mime-types (1.23)
61
+ mocha (0.14.0)
63
62
  metaclass (~> 0.0.1)
64
- multi_json (1.3.7)
63
+ multi_json (1.7.4)
65
64
  polyglot (0.3.3)
66
- rack (1.4.1)
65
+ rack (1.4.5)
67
66
  rack-cache (1.2)
68
67
  rack (>= 0.4)
69
- rack-ssl (1.3.2)
68
+ rack-ssl (1.3.3)
70
69
  rack
71
70
  rack-test (0.6.2)
72
71
  rack (>= 1.0)
73
- rails (3.2.9)
74
- actionmailer (= 3.2.9)
75
- actionpack (= 3.2.9)
76
- activerecord (= 3.2.9)
77
- activeresource (= 3.2.9)
78
- activesupport (= 3.2.9)
72
+ rails (3.2.13)
73
+ actionmailer (= 3.2.13)
74
+ actionpack (= 3.2.13)
75
+ activerecord (= 3.2.13)
76
+ activeresource (= 3.2.13)
77
+ activesupport (= 3.2.13)
79
78
  bundler (~> 1.0)
80
- railties (= 3.2.9)
81
- railties (3.2.9)
82
- actionpack (= 3.2.9)
83
- activesupport (= 3.2.9)
79
+ railties (= 3.2.13)
80
+ railties (3.2.13)
81
+ actionpack (= 3.2.13)
82
+ activesupport (= 3.2.13)
84
83
  rack-ssl (~> 1.3.2)
85
84
  rake (>= 0.8.7)
86
85
  rdoc (~> 3.4)
87
86
  thor (>= 0.14.6, < 2.0)
88
- rake (10.0.2)
89
- rdoc (3.12)
87
+ rake (10.0.4)
88
+ rdoc (3.12.2)
90
89
  json (~> 1.4)
91
90
  seed-fu (2.2.0)
92
91
  activerecord (~> 3.1)
@@ -98,13 +97,13 @@ GEM
98
97
  multi_json (~> 1.0)
99
98
  rack (~> 1.0)
100
99
  tilt (~> 1.1, != 1.3.0)
101
- sqlite3 (1.3.6)
102
- thor (0.16.0)
103
- tilt (1.3.3)
100
+ sqlite3 (1.3.7)
101
+ thor (0.18.1)
102
+ tilt (1.4.1)
104
103
  treetop (1.4.12)
105
104
  polyglot
106
105
  polyglot (>= 0.3.1)
107
- tzinfo (0.3.35)
106
+ tzinfo (0.3.37)
108
107
 
109
108
  PLATFORMS
110
109
  ruby
Binary file