arfy 0.1.5 → 0.2

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/Changelog.md ADDED
@@ -0,0 +1,24 @@
1
+ ## 0.2
2
+
3
+ Features:
4
+
5
+ - Support to all tasks
6
+ - LICENSE file created
7
+
8
+ ## 0.1.5
9
+
10
+ Features:
11
+
12
+ - Support to tasks:
13
+
14
+ * db:drop
15
+ * db:migrate:status
16
+ * db:rollback
17
+ * db:schema:dump
18
+ * db:schema:load
19
+ * db:version
20
+
21
+
22
+ Bugfixes:
23
+
24
+ - No one until now
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright [2011] [Ricardo Valeriano ricardo.valeriano@gmail.com |
2
+ ricardo@backslashes.net]
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
@@ -13,5 +13,10 @@ module RailsFaker
13
13
  def paths
14
14
  configured_paths
15
15
  end
16
+
17
+ def load_seed
18
+ seed_file = paths["db/seeds"]
19
+ load(seed_file) if File.exist?(seed_file)
20
+ end
16
21
  end
17
22
  end
@@ -6,7 +6,8 @@ module RailsFaker
6
6
  end
7
7
 
8
8
  def database_configuration
9
- YAML::load(ERB.new(IO.read(paths["config/database"])).result)
9
+ @configuration ||= YAML::load(ERB.new(IO.read(paths["config/database"])).result)
10
+ @configuration
10
11
  end
11
12
  end
12
13
  end
@@ -36,8 +36,14 @@ module Arfy
36
36
  File.open(migration_path, "w") do |file|
37
37
  file << code_for_migration(migration_name)
38
38
  end
39
- return nil unless File.exists? migration_path
40
- migration_path
39
+
40
+ if migration_path
41
+ puts "migration generated on: #{file}"
42
+ else
43
+ puts "FAIL. Migration not generated."
44
+ end
45
+
46
+ File.exists? migration_path
41
47
  end
42
48
 
43
49
  private
data/lib/arfy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arfy
2
- VERSION = "0.1.5" unless defined?(::Arfy::VERSION)
2
+ VERSION = "0.2" unless defined?(::Arfy::VERSION)
3
3
  end
data/lib/arfy.rb CHANGED
@@ -10,6 +10,7 @@ require 'arfy/generator'
10
10
  def configured_paths
11
11
  paths = {}
12
12
  paths["config/database"] = "config/database.yml"
13
+ paths["db/seeds"] = "db/seeds.rb"
13
14
  migrate_path = String.new("db/migrate")
14
15
  def migrate_path.to_a
15
16
  [self]
data/lib/tasks/all.rb CHANGED
@@ -1,38 +1,41 @@
1
1
  task :environment do
2
2
  # requiring config/environment
3
+
3
4
  ActiveRecord::Base.establish_connection(Rails.application.config.database_configuration[Rails.env])
5
+
6
+ module ActiveRecord
7
+ class Base
8
+ def self.establish_connection(configuration = nil)
9
+ #forget about it, we already have a connection XD
10
+ end
11
+
12
+ def self.configurations
13
+ Rails.application.config.database_configuration
14
+ end
15
+ end
16
+ end
17
+
4
18
  end
5
19
 
6
20
  desc "Changes the environment (options TARGET=development) - use your's configuration name on database.yml"
7
21
  task :rails_env do
8
- ENV['RAILS_ENV'] = ENV["TARGET"] || "development"
22
+ ENV['RAILS_ENV'] = (ENV["TARGET"] || ENV["RAILS_ENV"]) || "development"
9
23
  unless defined? RAILS_ENV
10
24
  RAILS_ENV = ENV['RAILS_ENV']
11
25
  end
12
-
13
- # TODO: waiting for a better way of doing this
14
- # create a new connection on pool for ActiveRecord::Base class name
15
- # TODO: just do it on the first time
26
+ puts "working on environment: #{ENV['RAILS_ENV']}" if ENV["RAILS_ENV"]
16
27
  end
17
28
 
18
29
  namespace :generate do
19
30
  desc "Generate migration (options NAME=migration_file_name, OUTDIR=db/migrate, TARGET=environment)"
20
- task :migration do
31
+ task :migration => :rails_env do
21
32
  raise "missing migration name, use the option NAME=migration_file_name" unless ENV["NAME"]
22
33
 
23
34
  name = ENV["NAME"]
24
35
  outdir = ENV["OUTDIR"] || Rails.application.config.paths['db/migrate']
25
- ENV["RAILS_ENV"] = ENV["TARGET"] || ENV["RAILS_ENV"]
26
-
27
- puts "working on environment: #{ENV['RAILS_ENV']}" if ENV["RAILS_ENV"]
28
36
 
29
37
  generator = Arfy::Generator.new
30
38
  file = generator.generate_migration_file ENV["NAME"], outdir
31
- if file
32
- puts "migration generated on: #{file}"
33
- else
34
- puts "FAIL. Migration not generated."
35
- end
36
39
  end
37
40
  end
38
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-21 00:00:00.000000000Z
12
+ date: 2011-09-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70324994312800 !ruby/object:Gem::Requirement
16
+ requirement: &70304467191940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70324994312800
24
+ version_requirements: *70304467191940
25
25
  description: ! 'Arfy is just a snippet: some rake tasks and environment configuration
26
26
  to allow you use Rails migrations, without all the rails stack.'
27
27
  email:
@@ -40,6 +40,8 @@ files:
40
40
  - lib/arfy.rb
41
41
  - lib/tasks/all.rb
42
42
  - README.md
43
+ - LICENSE
44
+ - Changelog.md
43
45
  homepage: http://github.com/ricardovaleriano/arfy
44
46
  licenses: []
45
47
  post_install_message: