rmvc 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/rmvc +7 -0
  3. data/lib/rmvc.rb +130 -0
  4. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d34e514f34ac5e720c39efdfce7f0dda351dcdba
4
+ data.tar.gz: 6ddb59eff0fec7bdbc6359d589ad7e8ca851221c
5
+ SHA512:
6
+ metadata.gz: a10eaed7d6731a064115508138b79545f5567e431ce08b024905987764014ef02b875c2b5d6d7ef39a8955fbad529326ceb6eb34c785e787596858f84067288a
7
+ data.tar.gz: 191e961c922a6e121bcd42facb81ffb5930fc7b31b2e388f655f32ddcbcc1617f509a550a83f5bd549eb349cf0c08c4610c1e4f309173e3ef1da11890d6b5fee
data/bin/rmvc ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rmvc'
3
+ if (ARGV.length == 0) then
4
+ RMVC::Interface.startup("none")
5
+ else
6
+ RMVC::Interface.startup(ARGV)
7
+ end
data/lib/rmvc.rb ADDED
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env ruby
2
+ require 'colorize'
3
+ module RMVC
4
+ # Interface
5
+ class Interface
6
+ # Startup
7
+ def self.startup(args)
8
+ if (args != "none") then
9
+ RMVC::Interface.run(args)
10
+ else
11
+ # No ARGS
12
+ RMVC::Interface.showHelp
13
+ end
14
+ end
15
+
16
+ # Run a command
17
+ def self.run(args)
18
+ fullArgs = args.join(" ")
19
+ # Validate first argument
20
+ if args[0] == "new" then
21
+ # Create a new project
22
+ if (args.length >= 2) then
23
+ RMVC::Core.create(args[1])
24
+ else
25
+ puts "Wrong syntax for 'new'!"
26
+ RMVC::Interface.showHelp
27
+ end
28
+ elsif args[0] == "generate"
29
+ # Generate code
30
+ RMVC::Core.generate(args)
31
+ else
32
+ # Unknown command
33
+ RMVC::Interface.showHelp
34
+ end
35
+ end
36
+
37
+ # Show help
38
+ def self.showHelp
39
+ puts "You introduced an invalid command, or you've ran rmvc without arguments."
40
+ puts "Syntax: rmvc [command] [arguments ...]"
41
+ puts "The following commands are available: "
42
+ puts ""
43
+ puts " new [ProjectName]"
44
+ puts " where [ProjectName] is the name of your new project"
45
+ puts " Creates a new project using the RMVC architecture."
46
+ puts ""
47
+ puts " generate [model|controller|view] [name]"
48
+ puts " where [name] is the name of the model/controller/view"
49
+ puts " Creates a new model/controller/view with the desired name."
50
+ puts ""
51
+ end
52
+ end
53
+
54
+ # Core (commands)
55
+ class Core
56
+ def self.generate(whatever)
57
+ puts "Placeholder"
58
+ end
59
+ # CMD: new [ProjectName]
60
+ def self.create(projectname)
61
+ puts "Creating new project: #{projectname}"
62
+ puts ""
63
+ # Check if directory exists
64
+ if (File.directory? projectname) then
65
+ puts "error".red + " Directory #{projectname} already exists."
66
+ exit
67
+ end
68
+ # Try to create it
69
+ if (!Dir.mkdir(projectname)) then
70
+ puts "error".red + " Error while creating the directory #{projectname}"
71
+ exit
72
+ else
73
+ puts "create".green + " Directory #{projectname}"
74
+ end
75
+ # Create file projectname.rb
76
+ File.open(projectname + "/" + projectname + ".rb", "w") do |f|
77
+ f.write("require './app/controllers/default_controller'\n")
78
+ f.write("DefaultController.main\n")
79
+ end
80
+ puts "create".green + " File #{projectname}.rb"
81
+
82
+ # Create directory app
83
+ Dir.mkdir(projectname + "/app")
84
+ puts "create".green + " Directory /app"
85
+ # Create directory app/controllers
86
+ Dir.mkdir(projectname + "/app/controllers")
87
+ puts "create".green + " Directory /app/controllers"
88
+ # Create default controller
89
+ File.open(projectname + "/app/controllers/default_controller.rb", "w") do |f|
90
+ f.write("require './app/models/default'\n")
91
+ f.write("require './app/views/main'\n")
92
+ f.write("class DefaultController\n")
93
+ f.write(" class << self\n")
94
+ f.write(" #Add your variables here!\n")
95
+ f.write(" attr_accessor :name\n")
96
+ f.write(" end\n")
97
+ f.write(" @name = \"James!\"\n")
98
+ f.write(" def self.main\n")
99
+ f.write(" MainView.load\n")
100
+ f.write(" end\n")
101
+ f.write("end\n")
102
+ end
103
+ puts "create".green + " File /app/controllers/default_controller.rb"
104
+ # Create directory app/views
105
+ Dir.mkdir(projectname + "/app/views")
106
+ puts "create".green + " Directory /app/views"
107
+ # Create /app/views/main.rb
108
+ File.open(projectname + "/app/views/main.rb", "w") do |f|
109
+ f.write("require './app/controllers/default_controller'\n")
110
+ f.write("class MainView\n")
111
+ f.write(" def self.load\n")
112
+ f.write(" puts \"Hello, hello \#{DefaultController.name}!\"\n")
113
+ f.write(" end\n")
114
+ f.write("end\n")
115
+ end
116
+ puts "create".green + " File /app/views/main.rb"
117
+
118
+ # Create /app/models
119
+ Dir.mkdir(projectname + "/app/models")
120
+ puts "create".green + " Directory /app/models"
121
+ # Create /app/models/default.rb
122
+ File.open(projectname + "/app/models/default.rb", "w") do |f|
123
+ f.write("require './app/controllers/default_controller'\n")
124
+ f.write("class DefaultModel\n")
125
+ f.write("end\n")
126
+ end
127
+ puts "create".green + " File /app/models/default.rb"
128
+ end
129
+ end
130
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmvc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Catbuntu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Use MVC in your Ruby apps!
28
+ email: catbuntu@catbuntu.me
29
+ executables:
30
+ - rmvc
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/rmvc.rb
35
+ - bin/rmvc
36
+ homepage: http://unrar.github.io/rmvc
37
+ licenses: []
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.0.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Ruby MVC
59
+ test_files: []