genki 0.1.0.beta1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00a55d670e65a428c6e1c35b237585bfda9b3ab6
4
+ data.tar.gz: 9c651d223273e9d3ea783f0731aff5a7fea0e643
5
+ SHA512:
6
+ metadata.gz: 7781178a2c90815a311eb742ac31b402fe85dc542acdd4198f117c347cccf2bb773159c8e509a6ddb6123810609ff0d56b01f7a8a1d7c2da8cba9e4bafb563c8
7
+ data.tar.gz: 93434de97688da2d78482d1c7b8810792d468593582d1542dc43fcb954b1328733dce24067dd7ea45929c691c9fbf0c43e60bfdf0c53566147a7a451c6d76b98
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
2
+ # URISchemes: http, https
3
+ Metrics/LineLength:
4
+ Max: 90
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - './genki.gemspec'
8
+
9
+ Lint/Eval:
10
+ Exclude:
11
+ - 'spec/support/capture.rb'
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - 2.2.4
5
+ - 2.3.0
6
+ - ruby-head
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: ruby-head
10
+ fast_finish: true
11
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at diego.silva@live.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in genki.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Diego Silva
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Genki
2
+
3
+ [![Build Status](https://travis-ci.org/genkirb/genki.svg?branch=master)](https://travis-ci.org/genkirb/genki)
4
+ [![Code Climate](https://codeclimate.com/github/genkirb/genki/badges/gpa.svg)](https://codeclimate.com/github/genkirb/genki)
5
+ [![Test Coverage](https://codeclimate.com/github/genkirb/genki/badges/coverage.svg)](https://codeclimate.com/github/genkirb/genki/coverage)
6
+
7
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/genki`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+
9
+ TODO: Delete this and the text above, and describe your gem
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'genki'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install genki
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/genki. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'genki'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
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/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require 'genki'
2
+ app = Genki::Server.new
3
+ run app
data/exe/genki ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'genki/cli'
4
+ Genki::Cli.start
data/genki.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'genki/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'genki'
8
+ s.version = Genki::VERSION
9
+ s.authors = ['Diego Silva', 'Leonardo Siqueira']
10
+ s.email = ['diego.silva@live.com', 'leonardo.prg@gmail.com']
11
+
12
+ s.summary = 'Fast and minimalist framework to generate API\'s in ruby.'
13
+ s.description = 'Genki is a full-stack framework optimized to create API\'s, quicly, easy and beatiful.'
14
+ s.homepage = 'https://github.com/genkirb/genki'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ s.bindir = 'exe'
19
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ s.require_paths = ['lib']
21
+
22
+ s.required_ruby_version = '>= 2.2.2'
23
+
24
+ s.add_dependency 'rack', '~> 2.x'
25
+ s.add_dependency 'thor', '~> 0.19.1'
26
+
27
+ s.add_development_dependency 'bundler', '~> 1.11'
28
+ s.add_development_dependency 'rake', '~> 10.0'
29
+ s.add_development_dependency 'rspec', '~> 3.0'
30
+ s.add_development_dependency 'rubocop', '~> 0.37'
31
+ s.add_development_dependency 'codeclimate-test-reporter'
32
+ s.add_development_dependency 'fakefs'
33
+ end
data/lib/genki/cli.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'thor'
2
+ require 'genki/generators/app'
3
+
4
+ module Genki
5
+ #--
6
+ # Genki::Cli
7
+ #
8
+ # CLI CLASS
9
+ #++
10
+ class Cli < Thor
11
+ include Thor::Actions
12
+
13
+ check_unknown_options!
14
+
15
+ def self.exit_on_failure?
16
+ true
17
+ end
18
+
19
+ desc 'version', 'Display Genki version'
20
+ map %w(-v --version) => :version
21
+ def version
22
+ say "Genki #{Genki::VERSION}"
23
+ end
24
+
25
+ register Generators::App, 'new', 'new APP_NAME', 'Create a new Genki application.'
26
+ tasks['new'].options = Generators::App.class_options
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'genki', '<%= Genki::VERSION %>'
@@ -0,0 +1,4 @@
1
+ require 'genki'
2
+ Dir['./**/*.rb'].each { |file| require file }
3
+ app = Genki::Server.new
4
+ run app
@@ -0,0 +1,46 @@
1
+ require 'genki/version'
2
+ require 'bundler'
3
+
4
+ module Genki
5
+ module Generators
6
+ #--
7
+ # Genki::Generators::App
8
+ #
9
+ # APP GENERATOR CLASS
10
+ #++
11
+ class App < Thor::Group
12
+ include Thor::Actions
13
+
14
+ argument :app_name
15
+ class_option :force, aliases: '-f', default: false, type: :boolean
16
+
17
+ def self.source_root
18
+ File.expand_path('../app/files', __FILE__)
19
+ end
20
+
21
+ def set_directory
22
+ self.destination_root = app_name
23
+ end
24
+
25
+ def create_directory
26
+ message = set_color("Directory #{app_name} already exists", :red)
27
+ raise Thor::Error, message if Dir.exist?(app_name) && !options[:force]
28
+ empty_directory ''
29
+ end
30
+
31
+ def create_config_ru
32
+ copy_file 'config.ru'
33
+ end
34
+
35
+ def create_gemfile
36
+ template 'Gemfile'
37
+ end
38
+
39
+ def run_bundle
40
+ inside do
41
+ Bundler.with_clean_env { run 'bundle' }
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ module Genki
2
+ #--
3
+ # Genki::Controller
4
+ #
5
+ # CONTROLLER CLASS
6
+ #++
7
+ class Controller
8
+ def self.get(path, &block)
9
+ Router.instance.route(Route.new(:GET, path), &block)
10
+ end
11
+
12
+ def self.post(path, &block)
13
+ Router.instance.route(Route.new(:POST, path), &block)
14
+ end
15
+
16
+ def self.put(path, &block)
17
+ Router.instance.route(Route.new(:PUT, path), &block)
18
+ end
19
+
20
+ def self.delete(path, &block)
21
+ Router.instance.route(Route.new(:DELETE, path), &block)
22
+ end
23
+
24
+ def self.render(body, status = 200, header = [])
25
+ Response.new(body, status, header)
26
+ end
27
+
28
+ def self.request
29
+ Thread.current[:request]
30
+ end
31
+
32
+ def self.params
33
+ request.params
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ module Genki
2
+ #--
3
+ # Genki::Request
4
+ #
5
+ # REQUEST CLASS
6
+ #++
7
+ class Request < Rack::Request
8
+ attr_reader :route
9
+
10
+ def initialize(env)
11
+ super(env)
12
+ @route = Route.new(env['REQUEST_METHOD'], env['PATH_INFO'])
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Genki
2
+ #--
3
+ # Genki::Response
4
+ #
5
+ # RESPONSE CLASS
6
+ #++
7
+ class Response < Rack::Response
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Genki
2
+ #--
3
+ # Genki::Route
4
+ #
5
+ # ROUTE CLASS
6
+ #++
7
+ class Route
8
+ attr_reader :signature
9
+
10
+ def initialize(verb, path)
11
+ @signature = "#{verb}#{path}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ require 'singleton'
2
+
3
+ module Genki
4
+ #--
5
+ # Genki::Route
6
+ #
7
+ # ROUTER CLASS
8
+ #++
9
+ class Router
10
+ include Singleton
11
+
12
+ def initialize
13
+ @routes = {}
14
+ end
15
+
16
+ def route(route, &block)
17
+ @routes[route.signature] = block
18
+ end
19
+
20
+ def process(request)
21
+ Thread.current[:request] = request
22
+
23
+ action = @routes[request.route.signature]
24
+ return Response.new 'Not Found', 404 unless action
25
+ action.call
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ module Genki
2
+ #--
3
+ # Genki::Server
4
+ #
5
+ # SERVER CLASS
6
+ #++
7
+ class Server
8
+ def call(env)
9
+ response = Router.instance.process(Request.new(env))
10
+
11
+ response.finish
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Genki
2
+ VERSION = '0.1.0.beta1'.freeze
3
+ end
data/lib/genki.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'rack'
2
+ require 'genki/version'
3
+ require 'genki/cli'
4
+ require 'genki/http/server'
5
+ require 'genki/http/router'
6
+ require 'genki/http/route'
7
+ require 'genki/http/controller'
8
+ require 'genki/http/request'
9
+ require 'genki/http/response'
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - Diego Silva
8
+ - Leonardo Siqueira
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 2.x
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 2.x
28
+ - !ruby/object:Gem::Dependency
29
+ name: thor
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.19.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.19.1
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.11'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.11'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.37'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.37'
98
+ - !ruby/object:Gem::Dependency
99
+ name: codeclimate-test-reporter
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: fakefs
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Genki is a full-stack framework optimized to create API's, quicly, easy
127
+ and beatiful.
128
+ email:
129
+ - diego.silva@live.com
130
+ - leonardo.prg@gmail.com
131
+ executables:
132
+ - genki
133
+ extensions: []
134
+ extra_rdoc_files: []
135
+ files:
136
+ - ".gitignore"
137
+ - ".rspec"
138
+ - ".rubocop.yml"
139
+ - ".travis.yml"
140
+ - CODE_OF_CONDUCT.md
141
+ - Gemfile
142
+ - LICENSE.txt
143
+ - README.md
144
+ - Rakefile
145
+ - bin/console
146
+ - bin/setup
147
+ - config.ru
148
+ - exe/genki
149
+ - genki.gemspec
150
+ - lib/genki.rb
151
+ - lib/genki/cli.rb
152
+ - lib/genki/generators/app.rb
153
+ - lib/genki/generators/app/files/Gemfile.tt
154
+ - lib/genki/generators/app/files/config.ru
155
+ - lib/genki/http/controller.rb
156
+ - lib/genki/http/request.rb
157
+ - lib/genki/http/response.rb
158
+ - lib/genki/http/route.rb
159
+ - lib/genki/http/router.rb
160
+ - lib/genki/http/server.rb
161
+ - lib/genki/version.rb
162
+ homepage: https://github.com/genkirb/genki
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 2.2.2
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">"
178
+ - !ruby/object:Gem::Version
179
+ version: 1.3.1
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.4.8
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Fast and minimalist framework to generate API's in ruby.
186
+ test_files: []