ruby_storm 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c7e6151c5ed4d97e2d7dc22b9b2f2d2878c91d0
4
- data.tar.gz: 350cf19b627ea46f0356b3f75add71d455ae0552
3
+ metadata.gz: 6e4c5622141af3b2783056a9e0d90e5973fbfc07
4
+ data.tar.gz: 0359c06c3cb32e9e0d28a83dd9324b9530882191
5
5
  SHA512:
6
- metadata.gz: 483ccedac53f7f5b6648d3c3e1b404f4dc63c38ecd29ac876247a14b77412d8d68056496cc290ea01b4c6dc36162d4f36005c25a5b93eceaa7cbe703b016b65f
7
- data.tar.gz: 8c4ead33b151c54b1652e70239cf59cc3b4731adc7edb3fc8149e577ba45ac19976189d0ef5be8c1483611011868978ba7710ff9c912f82f3b246b4f00ca0bad
6
+ metadata.gz: 6e6db8f8ca6af8c84a6efe7fca1d0e1e11763145987d83339a846749a0443ee762e520ce2559b083733174364fa8d7fbbc420a5c3c99dbe8e933810bc118de5b
7
+ data.tar.gz: 15f35ed80d0e1512bc79b112160a8d658e0c17d5096900dcda25c239f3237ed300b3bc899a8334109ea3f3476dc81bea51c162efa3d53aaff093ca54c7152c8b
@@ -3,13 +3,13 @@ require 'fileutils'
3
3
  require_relative '../generators/version'
4
4
 
5
5
  module Storm
6
- STORM_DIR = File.expand_path("#{File.dirname(__FILE__)}/../")
7
- STORM_ENV = ENV['DATABASE_ENV'] || 'development'
8
- DB_VERSION = ENV['DB_VERSION'] || nil
9
- DATABASE_DIR = ENV['DATABASE_DIR'] || './db'
10
- APP_NAME = ENV['APP_NAME'] || Inflector::classify(File.basename(FileUtils.pwd))
6
+ STORM_DIR = File.expand_path("#{File.dirname(__FILE__)}/../")
7
+ STORM_ENV = ENV['DATABASE_ENV'] || 'development'
8
+ DB_VERSION = ENV['DB_VERSION'] || nil
9
+ DATABASE_DIR = ENV['DATABASE_DIR'] || './db'
10
+ APP_NAME = ENV['APP_NAME'] || Inflector::classify(File.basename(FileUtils.pwd))
11
11
  MIGRATIONS_DIR = "#{DATABASE_DIR}/migrate"
12
- APP_DIR = File.expand_path("./")
12
+ APP_DIR = File.expand_path("./")
13
13
 
14
14
  def self.env
15
15
  STORM_ENV
data/bin/storm CHANGED
@@ -3,7 +3,7 @@ require 'thread_safe'
3
3
 
4
4
  module Storm
5
5
 
6
- require File.expand_path("./../../application/inflector", __FILE__)
6
+ require File.expand_path("./../../vendor/inflector", __FILE__)
7
7
  require File.expand_path("./../../application/application", __FILE__)
8
8
 
9
9
  def self.perform!(namespace, args=ARGV)
@@ -30,12 +30,21 @@ module Storm
30
30
  return 0
31
31
  end
32
32
 
33
+ def self.load_environment
34
+ require 'thread_safe'
35
+ require 'active_record'
36
+ require "awesome_print"
37
+ require 'bundler'
38
+ ::Bundler.require(:default, :development)
39
+ Dir["./**/*.rb"].each{|file| next if /db\/migrate/ =~ file; require file }
40
+ end
41
+
33
42
  def self.generator(names)
34
43
  generators_and_paths = names.map{|name|
35
44
  [name.capitalize,name.downcase]
36
45
  }
37
46
 
38
- klass = "::Storm::"+generators_and_paths.map(&:first).join("::")
47
+ klass = ["","Storm",generators_and_paths.flat_map(&:first)].flatten.join("::")
39
48
  path = File.expand_path("./../../generators/#{generators_and_paths.map(&:last).join("/")}.rb", __FILE__)
40
49
  if File.exists?(path)
41
50
  require path
@@ -7,20 +7,8 @@ module Storm
7
7
  end
8
8
 
9
9
  def self.start(*args)
10
- reload_proc = proc{ Storm::Console.start(*args) }
11
-
12
- require 'thread_safe'
13
- require 'active_record'
14
- require "awesome_print"
15
- require 'bundler'
16
-
17
- ::Bundler.require(:default, :development)
18
- Dir["./**/*.rb"].each{|file| next if /db\/migrate/ =~ file; require file }
19
-
20
- require File.expand_path("./../../application/inflector", __FILE__)
21
- require File.expand_path("./../../application/application", __FILE__)
22
-
23
- ActiveRecord::Base.establish_connection YAML.load_file('./db/databases.yml')[Storm::STORM_ENV] rescue nil
10
+ Storm.load_environment
11
+ ActiveRecord::Base.establish_connection YAML.load_file('./db/database.yml')[Storm::STORM_ENV]
24
12
  ARGV.clear
25
13
  begin
26
14
  require 'pry'
@@ -32,7 +20,6 @@ module Storm
32
20
  @@reload = false
33
21
  self.start(*args)
34
22
  else
35
- puts e
36
23
  require 'irb'
37
24
  ::IRB.start
38
25
  end
@@ -7,35 +7,20 @@ module Storm::Db
7
7
 
8
8
  create_db = lambda do |config|
9
9
  # drops and create need to be performed with a connection to the 'postgres' (system) database
10
- if config["adapter"] == 'postgres'
11
- ::ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
12
- end
10
+ ::ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) if self.postgres?
13
11
  # drop the old database (if it exists)
14
12
  ::ActiveRecord::Base.connection.drop_database config["database"] rescue nil
15
13
  # create new
16
- ::ActiveRecord::Base.connection.create_database(config["database"]) rescue nil
14
+ ::ActiveRecord::Base.connection.create_database(config["database"])
17
15
  ::ActiveRecord::Base.establish_connection(config)
18
16
  end
19
17
 
20
18
  begin
21
19
  create_db.call self.config
22
- rescue Exception => sqlerr
23
- if sqlerr.errno == 1405
24
- print "#{sqlerr.error}. \nPlease provide the root password for your mysql installation\n>"
25
- root_password = $stdin.gets.strip
26
-
27
- grant_statement = <<-SQL
28
- GRANT ALL PRIVILEGES ON #{config['database']}.*
29
- TO '#{config['username']}'@'localhost'
30
- IDENTIFIED BY '#{config['password']}' WITH GRANT OPTION;
31
- SQL
32
-
33
- create_db.call config.merge('database' => nil, 'username' => 'root', 'password' => root_password)
34
- else
35
- $stderr.puts sqlerr.error
36
- $stderr.puts "Couldn't create database for #{config.inspect}, charset: utf8, collation: utf8_unicode_ci"
37
- $stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config['charset']
38
- end
20
+ rescue Exception => create_exception
21
+ $stderr.puts create_exception
22
+ $stderr.puts "Couldn't create database for #{config.inspect}, charset: utf8, collation: utf8_unicode_ci"
23
+ $stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config['charset']
39
24
  end
40
25
  end
41
26
  end
@@ -1,8 +1,13 @@
1
1
  class Storm::DBCommand
2
2
  require 'active_record'
3
3
  require 'yaml'
4
+
4
5
  def self.config
5
- @config ||= ::YAML.load_file('./db/databases.yml')[Storm::STORM_ENV]
6
+ @config ||= ::YAML.load_file('./db/database.yml')[Storm::STORM_ENV]
7
+ end
8
+
9
+ def self.postgres?
10
+ config["adapter"] == 'postgresql'
6
11
  end
7
12
 
8
13
  def self.connect
@@ -3,11 +3,14 @@ require_relative "db_command"
3
3
  module Storm::Db
4
4
  class Drop < Storm::DBCommand
5
5
  def self.start(args)
6
- ::ActiveRecord::Base.connection.drop_database self.connect['database'] rescue
7
- if self.config['adapter'] == 'sqlite3'
6
+ case self.config['adapter']
7
+ when 'sqlite3'
8
8
  db_file = File.expand_path("./"+self.config['database'])
9
- File.delete(db_file)
9
+ return File.delete(db_file)
10
+ when 'postgresql'
11
+ ::ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
10
12
  end
13
+ ::ActiveRecord::Base.connection.drop_database self.config['database'] rescue nil
11
14
  end
12
15
  end
13
16
  end
data/generators/init.rb CHANGED
@@ -3,10 +3,11 @@ require 'fileutils'
3
3
  module Storm
4
4
  class Init
5
5
  def self.start(args)
6
- app_name = args[0]
6
+ app_name = args[0]
7
7
  class_name = Inflector::classify(app_name)
8
- file_name = "#{Inflector::underscore(app_name)}.rb"
9
- dir_name = "#{Inflector::underscore(app_name)}"
8
+ dir_name = Inflector::underscore(app_name)
9
+ file_name = "#{Inflector::underscore(app_name)}.rb"
10
+
10
11
  FileUtils.mkdir_p(dir_name)
11
12
  FileUtils.mkdir_p("./#{dir_name}/#{MIGRATIONS_DIR}") rescue nil
12
13
  gemfile(dir_name)
@@ -41,10 +42,10 @@ end
41
42
  end
42
43
 
43
44
  #
44
- # Write databases.yml
45
+ # Write database.yml
45
46
  #
46
47
  def self.dbfile(dir_name)
47
- File.open("./#{dir_name}/db/databases.yml", "w+") do |f|
48
+ File.open("./#{dir_name}/db/database.yml", "w+") do |f|
48
49
  f.puts "\
49
50
  default: &default
50
51
  adapter: sqlite3
data/generators/start.rb CHANGED
@@ -3,12 +3,7 @@ require 'fileutils'
3
3
  module Storm
4
4
  class Start
5
5
  def self.start(args)
6
- require 'thread_safe'
7
- require 'active_record'
8
- require "awesome_print"
9
- require 'bundler'
10
- ::Bundler.require(:default, :development)
11
- Dir["./**/*.rb"].each{|file| next if /db\/migrate/ =~ file; require file }
6
+ Storm.load_environment
12
7
  project_name = File.basename(Dir.pwd)
13
8
  class_name = Inflector::classify(project_name)
14
9
  Inflector::constantize(class_name).main(STORM_ENV, ARGV[1..-1])
@@ -1,7 +1,7 @@
1
1
  module Storm
2
2
  class Version
3
3
  def self.to_s(*args)
4
- "0.0.9"
4
+ "0.0.10"
5
5
  end
6
6
 
7
7
  def self.start(*args)
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_storm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
@@ -106,7 +106,6 @@ files:
106
106
  - Gemfile.lock
107
107
  - README.md
108
108
  - application/application.rb
109
- - application/inflector.rb
110
109
  - bin/storm
111
110
  - generators/app.rb
112
111
  - generators/console.rb
@@ -124,6 +123,7 @@ files:
124
123
  - generators/version.rb
125
124
  - ruby_storm.gemspec
126
125
  - rubystorm.todo
126
+ - vendor/inflector.rb
127
127
  homepage: http://rubygems.org/gems/ruby_storm
128
128
  licenses:
129
129
  - MIT