mynatra 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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")
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
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,5 @@
1
+ #!/user/bin/env ruby
2
+ puts "I am here, with my exe/mynatra script!"
3
+ require "mynatra/cli"
4
+
5
+ Mynatra::CLI.start
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mynatra.gemspec
4
+ gemspec
5
+
6
+ gem "sinatra"
7
+ gem "activesupport"
8
+ gem "thor"
@@ -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
+ }