tgauge 0.1.0 → 0.1.1
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 +4 -4
- data/TGauge.gemspec +1 -0
- data/bin/console +4 -4
- data/bin/tgauge.rb +96 -96
- data/lib/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e92d80fc5f78eec18635d34feba8b5524ad18345
|
4
|
+
data.tar.gz: 6aefda7d7ff1b9bbf0641a647038799b83b775e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 827fbc23f29191d276fad9e97b9b6c8740def540ff520fa23d2e0ec84355627dcf8a80625772c5e7bd693a596a6bd2295bcf71242e554076414afa4b946d1459
|
7
|
+
data.tar.gz: 6eb0eaec197ee764dfa9cd654c09beffbd325d6feccf61b53dc46d908c5a0d33c4eb074de4844fed4b29028f39bbae7d42ce9e921ce234fe547917c4f635dfd4
|
data/TGauge.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
spec.add_runtime_dependency 'thor', '~> 0.19'
|
36
36
|
spec.add_runtime_dependency 'pg', '~> 0.18'
|
37
|
+
spec.add_runtime_dependency 'pry', '~> 0.10.3'
|
37
38
|
spec.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.5.1'
|
38
39
|
spec.add_runtime_dependency 'rack', '~> 1.6', '>=1.6.4'
|
39
40
|
spec.add_runtime_dependency 'fileutils', '~> 0.7'
|
data/bin/console
CHANGED
@@ -7,8 +7,8 @@ require "TGauge"
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
12
|
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
13
|
+
# require "irb"
|
14
|
+
# IRB.start
|
data/bin/tgauge.rb
CHANGED
@@ -1,119 +1,119 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'thor'
|
3
3
|
require 'active_support/inflector'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module TGauge
|
5
|
+
#Generates models, controllers, and migrations. Alias 'g'
|
6
|
+
class Generate < Thor
|
7
|
+
desc 'model <name>', 'generate a model.'
|
8
|
+
def model(name)
|
9
|
+
File.open('./app/models/#{name.downcase}.rb', 'w') do |f|
|
10
|
+
f.write("class #{name.capitalize} < TGauge::TRecordBase\n\n")
|
11
|
+
f.write("end\n")
|
12
|
+
f.write("#{name.capitalize}.finalize!")
|
13
|
+
end
|
14
|
+
|
15
|
+
migration("Create#{name.capitalize}}")
|
16
|
+
puts "#{name} model created"
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
desc 'controller <name>', 'generate a controller.'
|
20
|
+
def controller(name)
|
21
|
+
File.open('./app/controllers/#{name.downcase}.rb', 'w') do |f|
|
22
|
+
f.write("class #{name.capitalize}Controller < TGauge::TControllerBase\n\n")
|
23
|
+
f.write("end")
|
24
|
+
end
|
17
25
|
|
18
|
-
|
19
|
-
|
20
|
-
File.open('./app/controllers/#{name.downcase}.rb', 'w') do |f|
|
21
|
-
f.write("class #{name.capitalize}Controller < TGauge::TControllerBase\n\n")
|
22
|
-
f.write("end")
|
26
|
+
Dir.mkdir "./app/views/#{name.downcase}_controller"
|
27
|
+
puts "#{name} controller created"
|
23
28
|
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
f.write "CREATE TABLE IF NOT EXISTS #{name} (\n"
|
37
|
-
f.write "\tid SERIAL PRIMARY KEY,\n"
|
38
|
-
f.write ')'
|
30
|
+
desc 'migration <name>', 'generate an empty sql file.'
|
31
|
+
def migration(name)
|
32
|
+
#timestamp
|
33
|
+
ts = Time.now.to_i
|
34
|
+
filename = "#{ts}_#{name.underscore.downcase}"
|
35
|
+
|
36
|
+
File.open('./db/migrations/#{filename}.sql', 'w') do |f|
|
37
|
+
f.write "CREATE TABLE IF NOT EXISTS #{name} (\n"
|
38
|
+
f.write "\tid SERIAL PRIMARY KEY,\n"
|
39
|
+
f.write ')'
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
|
-
end
|
42
43
|
|
43
|
-
class Db < Thor
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
class Db < Thor
|
45
|
+
desc 'create', 'creates the DB'
|
46
|
+
def create
|
47
|
+
require_relative '../lib/db_connection'
|
48
|
+
TGauge::DBConnection.reset
|
49
|
+
puts 'db created!'
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
desc 'migrate', 'runs pending migrations'
|
53
|
+
def migrate
|
54
|
+
# Creates Version table if necessary,
|
55
|
+
# then runs needed migrations in order.
|
56
|
+
require_relative '../lib/db_connection'
|
57
|
+
TGauge::DBConnection.migrate
|
58
|
+
puts 'migrated!'
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
desc 'seed', 'seeds the DB'
|
62
|
+
def seed
|
63
|
+
require_relative '../lib/puffs'
|
64
|
+
TGauge::Seed.populate
|
65
|
+
puts 'db seeded!'
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
desc 'reset', 'resets the DB and seeds it'
|
69
|
+
def reset
|
70
|
+
create
|
71
|
+
migrate
|
72
|
+
seed
|
73
|
+
puts 'db reset!'
|
74
|
+
end
|
73
75
|
end
|
74
|
-
end
|
75
|
-
|
76
|
-
#top level commands
|
77
|
-
class CLI < Thor
|
78
|
-
register(Generate, 'generate', 'generate <command>', 'Generates a model, migration, or controller.')
|
79
|
-
register(Db, 'db', 'db <command>', 'Accesses commands for the DB.')
|
80
|
-
|
81
|
-
subcommand 'g', Generate
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
77
|
+
#top level commands
|
78
|
+
class CLI < Thor
|
79
|
+
register(Generate, 'generate', 'generate <command>', 'Generates a model, migration, or controller.')
|
80
|
+
register(Db, 'db', 'db <command>', 'Accesses commands for the DB.')
|
88
81
|
|
89
|
-
|
90
|
-
def new(name)
|
91
|
-
Dir.mkdir "./#{name}"
|
92
|
-
Dir.mkdir "./#{name}/config"
|
82
|
+
subcommand 'g', Generate
|
93
83
|
|
94
|
-
|
95
|
-
|
84
|
+
desc 'server', 'starts the WebBrick server'
|
85
|
+
def server
|
86
|
+
require_relative '../lib/tgauge.rb'
|
87
|
+
TGauge::Server.start
|
96
88
|
end
|
97
89
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
90
|
+
desc 'new', 'creates a new TGauge app'
|
91
|
+
def new(name)
|
92
|
+
Dir.mkdir "./#{name}"
|
93
|
+
Dir.mkdir "./#{name}/config"
|
94
|
+
|
95
|
+
File.open("./#{name}/config/database.yml", 'w') do |f|
|
96
|
+
f.write("database: #{name}")
|
97
|
+
end
|
98
|
+
|
99
|
+
Dir.mkdir "./#{name}/app"
|
100
|
+
Dir.mkdir "./#{name}/app/models"
|
101
|
+
Dir.mkdir "./#{name}/app/views"
|
102
|
+
Dir.mkdir "./#{name}/app/controllers"
|
103
|
+
File.open("./#{name}/app/controllers/application_controller.rb", 'w') do |f|
|
104
|
+
f.write File.read(File.expand_path('../../lib/template/app/controllers/application_controller.rb', __FILE__))
|
105
|
+
end
|
106
|
+
File.open("./#{name}/config/routes.rb", 'w') do |f|
|
107
|
+
f.write File.read(File.expand_path('../../lib/template/config/routes.rb', __FILE__))
|
108
|
+
end
|
109
|
+
Dir.mkdir "./#{name}/db"
|
110
|
+
Dir.mkdir "./#{name}/db/migrations"
|
111
|
+
File.open("./#{name}/db/seeds.rb", 'w') do |f|
|
112
|
+
f.write File.read(File.expand_path('../../lib/template/db/seeds.rb', __FILE__))
|
113
|
+
end
|
114
|
+
File.open("./#{name}/Gemfile", 'w') do |f|
|
115
|
+
f.write File.read(File.expand_path('../../lib/template/Gemfile', __FILE__))
|
116
|
+
end
|
115
117
|
end
|
116
118
|
end
|
117
119
|
end
|
118
|
-
|
119
|
-
CLI.start(ARGV)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tgauge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nam Kim
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.18'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.10.3
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: activesupport
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|