mynatra 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +107 -0
- data/README.md +35 -0
- data/Rakefile +4 -0
- data/bin/aruba +29 -0
- data/bin/bundle +114 -0
- data/bin/console +15 -0
- data/bin/cucumber +29 -0
- data/bin/cucumber-html-formatter +29 -0
- data/bin/gherkin +29 -0
- data/bin/gherkin-ruby +29 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/mynatra +29 -0
- data/bin/protoc-gen-ruby +29 -0
- data/bin/rake +29 -0
- data/bin/rpc_server +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/bin/thor +29 -0
- data/exe/mynatra +5 -0
- data/lib/generators/Gemfile +8 -0
- data/lib/generators/app.erb +6 -0
- data/lib/generators/controllers/base_controller.erb +22 -0
- data/lib/generators/controllers/resource_controller.erb +52 -0
- data/lib/generators/models/model.erb +61 -0
- data/lib/generators/public/scripts/main.js +0 -0
- data/lib/generators/public/styles/main.css +56 -0
- data/lib/generators/resource.rb +50 -0
- data/lib/generators/scaffolding.rb +46 -0
- data/lib/generators/views/footer.erb +3 -0
- data/lib/generators/views/getting_started.erb +12 -0
- data/lib/generators/views/header.erb +15 -0
- data/lib/generators/views/resource/edit.erb +17 -0
- data/lib/generators/views/resource/index.erb +14 -0
- data/lib/generators/views/resource/new.erb +14 -0
- data/lib/mynatra.rb +7 -0
- data/lib/mynatra/cli.rb +25 -0
- data/lib/mynatra/mynatra.rb +44 -0
- data/lib/mynatra/version.rb +5 -0
- data/mynatra.gemspec +41 -0
- data/pkg/mynatra-0.1.0.gem +0 -0
- metadata +159 -0
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/mynatra
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'mynatra' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("mynatra", "mynatra")
|
data/bin/protoc-gen-ruby
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'protoc-gen-ruby' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("protobuf-cucumber", "protoc-gen-ruby")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rpc_server
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rpc_server' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("protobuf-cucumber", "rpc_server")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/setup
ADDED
data/bin/thor
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'thor' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("thor", "thor")
|
data/exe/mynatra
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
|
3
|
+
# require and use controllers from within the `./controller` directory
|
4
|
+
controller_paths = Dir["./controllers/*.rb"].each { |file| require_relative file }
|
5
|
+
controllers = controller_paths.map { |controller_path| controller_path[/controllers\/(.*?)_controller/m, 1] }
|
6
|
+
controllers.each { |controller| use Object.const_get("#{controller.capitalize}Controller") }
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
|
3
|
+
class BaseController < Sinatra::Base
|
4
|
+
set :views, File.dirname('.') + '/views'
|
5
|
+
set :public_folder, File.dirname('.') + '/public'
|
6
|
+
|
7
|
+
get '/' do
|
8
|
+
erb :"getting_started"
|
9
|
+
end
|
10
|
+
|
11
|
+
get '/create' do
|
12
|
+
"<h1><%= name %> Create...</h1>"
|
13
|
+
end
|
14
|
+
|
15
|
+
get '/delete' do
|
16
|
+
"<h1><%= name %> Delete...</h1>"
|
17
|
+
end
|
18
|
+
|
19
|
+
get '/edit' do
|
20
|
+
"<h1><%= name %> Edit...</h1>"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require './models/<%= @name_singular %>'
|
2
|
+
|
3
|
+
class <%= @name_singular.capitalize %>Controller < Sinatra::Base
|
4
|
+
set :views, File.dirname('.') + '/views'
|
5
|
+
set :public_folder, File.dirname('.') + '/public'
|
6
|
+
|
7
|
+
# Create new (GET)
|
8
|
+
get '/<%= @name_plural %>/new' do
|
9
|
+
@<%= @name_singular %> = <%= @name_singular.capitalize %>.new
|
10
|
+
erb :"<%= @name_plural %>/new"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Create new (POST)
|
14
|
+
post '/<%= @name_plural %>/create' do
|
15
|
+
<%= @name_singular %> = <%= @name_singular.capitalize %>.new
|
16
|
+
<% @attributes.each do |attribute| %>
|
17
|
+
<%= @name_singular %>.<%= attribute %> = params[:<%= attribute %>]
|
18
|
+
<% end-%>
|
19
|
+
<%= @name_singular %>.save
|
20
|
+
redirect :"<%= @name_plural %>"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Update record (POST)
|
24
|
+
post '/<%= @name_plural %>/update/:id' do
|
25
|
+
<%= @name_singular %> = <%= @name_singular.capitalize %>.new
|
26
|
+
<%= @name_singular %>.id = params[:id].to_i
|
27
|
+
<% @attributes.each do |attribute| %>
|
28
|
+
<%= @name_singular %>.<%= attribute %> = params[:<%= attribute %>]
|
29
|
+
<% end-%>
|
30
|
+
<%= @name_singular %>.save
|
31
|
+
redirect :"<%= @name_plural %>/#{<%= @name_singular %>.id}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Find record (GET)
|
35
|
+
get '/<%= @name_plural %>/:id' do
|
36
|
+
@<%= @name_singular %> = <%= @name_singular.capitalize %>.find_by_id(params[:id].to_i)
|
37
|
+
erb :"<%= @name_plural %>/edit"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Delete record (POST)
|
41
|
+
post '/<%= @name_plural %>/delete/:id' do
|
42
|
+
@<%= name %> = <%= @name_singular.capitalize %>.find_by_id(params[:id].to_i)
|
43
|
+
@<%= name %>.delete
|
44
|
+
redirect :<%= @name_plural %>
|
45
|
+
end
|
46
|
+
|
47
|
+
# Index records (GET)
|
48
|
+
get '/<%= @name_plural %>' do
|
49
|
+
@<%= @name_plural %> = <%= @name_singular.capitalize %>.all
|
50
|
+
erb :"<%= @name_plural %>/index"
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class <%= @name_singular.capitalize %>
|
2
|
+
attr_accessor :id
|
3
|
+
<% @attributes.each do |attribute| %>
|
4
|
+
attr_accessor :<%= attribute %>
|
5
|
+
<% end -%>
|
6
|
+
|
7
|
+
@@<%= @name_plural.capitalize %> = []
|
8
|
+
@@count = 0
|
9
|
+
|
10
|
+
def delete
|
11
|
+
@@<%= @name_plural.capitalize %>.each_with_index do |<%= @name_singular%>, index|
|
12
|
+
if self.id == <%= @name_singular%>.id
|
13
|
+
@@<%= @name_plural.capitalize %>.delete_at(index)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.create(id)
|
19
|
+
<%= @name_singular%> = <%= name.capitalize %>.new
|
20
|
+
<%= @name_singular%>.id = id
|
21
|
+
@@<%= @name_plural.capitalize %> << <%= @name_singular%>
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_by_id(id)
|
25
|
+
@@<%= @name_plural.capitalize %>.each do |<%= @name_singular%>|
|
26
|
+
if <%= @name_singular%>.id == id
|
27
|
+
return <%= @name_singular%>
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
if self.id.nil?
|
34
|
+
self.id = new_id
|
35
|
+
@@<%= @name_plural.capitalize %>.push(self)
|
36
|
+
else
|
37
|
+
self.id = self.id.to_i
|
38
|
+
@@<%= @name_plural.capitalize %>.each_with_index do |<%= @name_singular %>, index|
|
39
|
+
if self.id == <%= @name_singular %>.id
|
40
|
+
@@<%= @name_plural.capitalize %>[index] = self
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.create_many
|
47
|
+
@@<%= @name_plural.capitalize %> = (1..25).map do |num|
|
48
|
+
<%= @name_singular%> = <%= name.capitalize %>.new
|
49
|
+
<%= @name_singular%>.id = "<%= @name_singular%>#{num}"
|
50
|
+
<%= @name_singular%>
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.all
|
55
|
+
@@<%= @name_plural.capitalize %>
|
56
|
+
end
|
57
|
+
|
58
|
+
def new_id
|
59
|
+
@@count += 1
|
60
|
+
end
|
61
|
+
end
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
* {
|
2
|
+
font-family: helvetica;
|
3
|
+
background-color: #eaeae1;
|
4
|
+
}
|
5
|
+
|
6
|
+
nav {
|
7
|
+
display: inline-flexbox;
|
8
|
+
list-style-type: circle;
|
9
|
+
margin: 1px;
|
10
|
+
padding: 1px;
|
11
|
+
overflow: hidden;
|
12
|
+
}
|
13
|
+
|
14
|
+
h2 {
|
15
|
+
color: Tomato;
|
16
|
+
margin: auto;
|
17
|
+
text-align: center;
|
18
|
+
padding-bottom: 30px;
|
19
|
+
}
|
20
|
+
|
21
|
+
form {
|
22
|
+
text-align: center;
|
23
|
+
padding: 20px 10px;
|
24
|
+
width: 100%;
|
25
|
+
height: 40px;
|
26
|
+
}
|
27
|
+
|
28
|
+
table {
|
29
|
+
font-size: 12px;
|
30
|
+
margin: auto;
|
31
|
+
}
|
32
|
+
|
33
|
+
th {
|
34
|
+
color: white;
|
35
|
+
background-color: Tomato;
|
36
|
+
opacity: 0.5;
|
37
|
+
}
|
38
|
+
|
39
|
+
td {
|
40
|
+
padding: 05px;
|
41
|
+
}
|
42
|
+
|
43
|
+
div {
|
44
|
+
background-color: #eaeae1;
|
45
|
+
margin-left: auto;
|
46
|
+
margin-right: auto;
|
47
|
+
padding: 10px;
|
48
|
+
color: #558000;
|
49
|
+
text-align: center;
|
50
|
+
width: 50%;
|
51
|
+
}
|
52
|
+
|
53
|
+
div:nth-child(odd) {
|
54
|
+
border-style: dotted;
|
55
|
+
border-radius: 5px;
|
56
|
+
}
|