weapon 0.1.7 → 0.1.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc7e28ff1fea07cafd0d6ffd36117240aca7bf3c
4
- data.tar.gz: 2356b00a9925161560a62402000fb3f981f6f6fc
3
+ metadata.gz: c17d5aa92f11ab117c8f72f1711a9d54170a05b1
4
+ data.tar.gz: f8029457742912dcb175d1b8338c73b6f4f43b12
5
5
  SHA512:
6
- metadata.gz: 16e57a0bbeedb990eca6d58b87d20639e348a1b534e8fc99640baa1049cd0796ee0116ac62d1e2653470eae7c2386446c560d5dfdea2259081e6c8d0a3c65ac2
7
- data.tar.gz: f3394b5d1621eef724bd01dd36c8405f96e5ddcb8993e4561c34b8fe46e41386df044bf838b3ec0848080da1c0984cd6855a0ea37fa01803f509407675143d30
6
+ metadata.gz: b90fd5b2a576d6ec6afa5781b82d5c79f1aceec00c21bd32731610e87a7a18c09ec3a44e81bc7dfdc6a3af8bdf678f417cfa8f7d6420c23abd0adc522226d9bc
7
+ data.tar.gz: fddfccbe41fa614423de3f4d45251707976cfe6aadba6916c8cb8b4f2002817095e78426f560fd5a27571c7caea2024bcf10a88493fd8dbe108ac4fd3699df29
@@ -0,0 +1,17 @@
1
+ class ModelFromSqlGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+
4
+ def build_models
5
+ tables = ActiveRecord::Base.connection.tables
6
+ tables.each do |table_name|
7
+ generate "model #{table_name} --skip-migration" # or whatever you want here
8
+ model_file = "app/models/#{table_name.singularize}.rb"
9
+ inject_into_file model_file, before: "end\n" do <<-'RUBY'
10
+ self.table_name = table_name_replace
11
+ RUBY
12
+ end
13
+ gsub_file model_file, 'table_name_replace', table_name
14
+ end
15
+
16
+ end
17
+ end
data/lib/weapon.rb CHANGED
@@ -117,6 +117,17 @@ class Weapon < Thor
117
117
  puts "staging branch missing, you need create staging branch, then exec mina setup, mina deploy".colorize(:red) unless staging.present?
118
118
  end
119
119
 
120
+ desc "model_from_sql", "build model from sql"
121
+ def model_from_sql
122
+ makesure_in_git
123
+ FileUtils.mkdir_p "lib/generators/model_from_sql"
124
+ copy_file 'support/model_from_sql/model_from_sql_generator.rb', 'lib/generators/model_from_sql/model_from_sql_generator.rb'
125
+ run 'git add lib/'
126
+ run 'rails g model_from_sql'
127
+ run 'git add app/ test/ lib/'
128
+ run 'git commit -a -m "add model_from_sql generator and build models from sql"'
129
+ end
130
+
120
131
  desc "setup_settings_ui", "setup settings ui"
121
132
  def setup_settings_ui
122
133
  makesure_in_git
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weapon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - seaify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-28 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -109,6 +109,7 @@ files:
109
109
  - lib/support/mina_unicorn/unicorn.rb
110
110
  - lib/support/mina_unicorn/unicorn_production.rb
111
111
  - lib/support/mina_unicorn/unicorn_staging.rb
112
+ - lib/support/model_from_sql/model_from_sql_generator.rb
112
113
  - lib/support/rails_settings_ui/rails_settings_ui.rb
113
114
  - lib/support/rails_settings_ui/setting.rb
114
115
  - lib/weapon.rb