rapp 0.0.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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +131 -0
- data/Rakefile +2 -0
- data/bin/rapp +6 -0
- data/lib/rapp/builder.rb +61 -0
- data/lib/rapp/templates/Gemfile.erb +4 -0
- data/lib/rapp/templates/Rakefile.erb +5 -0
- data/lib/rapp/templates/app.rb.erb +61 -0
- data/lib/rapp/templates/config/environments/development.rb.erb +0 -0
- data/lib/rapp/templates/config/environments/production.rb.erb +0 -0
- data/lib/rapp/templates/config/environments/test.rb.erb +0 -0
- data/lib/rapp/templates/lib/tasks/console.rake.erb +5 -0
- data/lib/rapp/version.rb +3 -0
- data/lib/rapp.rb +5 -0
- data/rapp.gemspec +23 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ab80ffe08547a212b884149d0499ac841d9001e
|
4
|
+
data.tar.gz: c82ba799ec59598319f7e16c02f135174205e530
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b2741fb99e4990e5aa894c9619a97df35e090a7802f463abca0fe87e9656bd4878a70294778237b0c0ef92fade3bdfc763cabeeba1d49d40de474cdc4d3280c
|
7
|
+
data.tar.gz: c7825966622ea7595df78a8f8893959b064e79127d1d24ab4b6c10521c922fac25144f52ff6da7367e8f832abc1697122644294168d916fd76a37151b4bc49bb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 StabbyCutyou
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# Rapp
|
2
|
+
|
3
|
+
Rapp - The Ruby App Scaffolder
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rapp'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rapp
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Using Rapp is incredibly simple. It's designed to work like familiar scaffolders / builders in the ruby community (think `rails new`).
|
24
|
+
|
25
|
+
Currently, Rapp is in early development, and additional features are forthcoming. There is a Roadmap at the bottom of the Readme to highlight some of the work I feel is important to prioritize before a full v1 release. In addition to features, this includes the internal organization of the code as well, as the current state is more prototypical than it is final release quality.
|
26
|
+
|
27
|
+
### Ethos
|
28
|
+
|
29
|
+
Rapp is not a framework for running an app or building an app from pieces-parts. In the future, there may be additional helpers to configure very common components in the ruby community, but the overall goal is to hand you a working application with a few common niceities, then get out of your way. Once you've generated the Rapp, the project is yours to do with as you see fit - the gem itself is not a dependencty of the app you create.
|
30
|
+
|
31
|
+
Rapps are shells to house your app, in a familiar layout, to prevent you from having to write the same boring boilerplate time and time again.
|
32
|
+
|
33
|
+
Rapp is in no way shape or form meant for building web applications. You are free to attempt this if you wish, but if thats your goal, you're much better off with Rails, Sinatra, pure Rack, or any number of alternatives.
|
34
|
+
|
35
|
+
### Creating a new Rapp
|
36
|
+
|
37
|
+
Creating a new Rapp is simple
|
38
|
+
|
39
|
+
```shell
|
40
|
+
rapp new my_new_rapp
|
41
|
+
```
|
42
|
+
|
43
|
+
The only requirement is that the directory must not exist / be empty, as a safegaurd against accidentally overwriting any existing projects or Rapps. Otherwise, thats it!
|
44
|
+
|
45
|
+
If the command executed successuflly, you should see a report displaying the folders and files that Rapp created for you. After that, you're ready to start building your app!
|
46
|
+
|
47
|
+
### Dependencies
|
48
|
+
|
49
|
+
Rapp only installs 2 dependencies into your application - bundler and rake. Eventually, It will also include rspec, as well as a suite of specs for you to run to validate that the core underpinnings of Rapp are working as expected, in addition to your own custom specs.
|
50
|
+
|
51
|
+
### Layout
|
52
|
+
|
53
|
+
Rapp application structure looks like the following:
|
54
|
+
|
55
|
+
* app/
|
56
|
+
* app/models/
|
57
|
+
* app/services/
|
58
|
+
* app/jobs/
|
59
|
+
* bin/
|
60
|
+
* config/
|
61
|
+
* config/environments/
|
62
|
+
* config/initializers/
|
63
|
+
* lib/
|
64
|
+
* lib/tasks/
|
65
|
+
* spec/
|
66
|
+
* {app_name}.rb
|
67
|
+
* Gemfile
|
68
|
+
* Rakefile
|
69
|
+
|
70
|
+
### {app_name}.rb
|
71
|
+
|
72
|
+
Most of the generated code that Rapp creates lives here. This is the primary entry point for you application, and handles things such as:
|
73
|
+
|
74
|
+
* Defining the environment
|
75
|
+
* Providing an application level logger
|
76
|
+
* Loading dependencies via Bundler
|
77
|
+
* Adding core directories to the load path
|
78
|
+
* Requiring configuration, initializers, and environment-specific settings
|
79
|
+
* Requiring the contents of the app/ directory
|
80
|
+
|
81
|
+
You're free to modify any of this code however you see fit - however, most of the code in your core app file is meant to be added to (and not removed) for the convenience of you, the developer. Be that as it may, you are still free to do whatever you want inside of this file.
|
82
|
+
|
83
|
+
A future revision will be breaking this behavior out into an application base, so that everything isn't dumped into a single ruby class.
|
84
|
+
|
85
|
+
### App directory
|
86
|
+
|
87
|
+
This is likely a familiar concept to any Rails developer, with a few twists. Rails famously eschews the notion of keeping business logic in services - I do not eschew this practice, and believe it is the right way to keep a distinction between the logic of the application, and the data with which the application is modeled. You are free to use, ignore, remove, or otherwise throw out this directory as you see fit.
|
88
|
+
|
89
|
+
Additionally, there is a directory for "jobs", a place for daemonized background or out of band work to go, to make working with things like Chore or Sidekiq easier out of the box.
|
90
|
+
|
91
|
+
### Bin directory
|
92
|
+
|
93
|
+
If your application were to require an executable binary, it would be placed here. Otherwise, you may feel free to remove this directory
|
94
|
+
|
95
|
+
### Config directory
|
96
|
+
|
97
|
+
Another familiar convention for Rails developers, this directory and it's structure is meant to work in the same fashion as Rails. Dependency specific configuration needs can be placed into config/, initializers for your apps boot-up can be placed into config/initializers/, and any code specific to an environment (production / development / test) can be placed into config/environments. The load order is as follows:
|
98
|
+
|
99
|
+
1. The correct environment.rb (defaults to development)
|
100
|
+
2. The contents of config/initializers/, in alphabetical order
|
101
|
+
3. The contents of config/, in alphabetical order
|
102
|
+
|
103
|
+
These are loaded after Bundler, but before anything in app/
|
104
|
+
|
105
|
+
### Lib directory
|
106
|
+
|
107
|
+
Used for the same purpose as a Rails app or Ruby gem. Any code that falls outside of the norms of app/ would be placed here. Additionally, you may place tasks in lib/tasks/, and they will be registered via the Rake integration
|
108
|
+
|
109
|
+
### Spec directory
|
110
|
+
|
111
|
+
Mostly reserved for future use, this is where both Rapp specific specs to ensure the well-being of your core application will reside, as well as application specific specs that you write to ensure your custom logic and behaviors are working correctly (You are writing tests... right?)
|
112
|
+
|
113
|
+
### Rake
|
114
|
+
|
115
|
+
Currently, Rapp comes with 1 predefined rake task, which is "console". This will boot up irb while loading your {app_name}.rb, which will load the rest of your app. This is aliased to "c" for convenience.
|
116
|
+
|
117
|
+
## Roadmap
|
118
|
+
|
119
|
+
At the moment, this gem serves to fit a need that I found myself having and figured others might be as well. To that end, my main goals are to provide a simple, stable core ruby app intended to be run as a simple cli program, daemonized process, or otherwise. Currently, my primary roadmap for development is:
|
120
|
+
|
121
|
+
1. Generate specs for the users application
|
122
|
+
2. Provide proper CLI for the binary, to make future command line functionality easier to implement
|
123
|
+
3. Test ease of use integrating Chore / Sidekiq like job systems
|
124
|
+
|
125
|
+
## Contributing
|
126
|
+
|
127
|
+
1. Fork it ( https://github.com/StabbyCutyou/rapp/fork )
|
128
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
129
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
130
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
131
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/rapp
ADDED
data/lib/rapp/builder.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module Rapp
|
6
|
+
DirectoryStructure = [
|
7
|
+
"app",
|
8
|
+
"app/models",
|
9
|
+
"app/services",
|
10
|
+
"app/jobs",
|
11
|
+
"bin",
|
12
|
+
"config",
|
13
|
+
"config/environments",
|
14
|
+
"config/initializers",
|
15
|
+
"lib",
|
16
|
+
"lib/tasks",
|
17
|
+
"spec"
|
18
|
+
]
|
19
|
+
class Builder
|
20
|
+
class << self
|
21
|
+
def new_app(opts={})
|
22
|
+
# Get name
|
23
|
+
raise ArgumentError.new("You must provide a name") unless app_name = opts.delete("name")
|
24
|
+
# Check if folder exists
|
25
|
+
root_dir = "#{`pwd`.strip}/#{app_name}"
|
26
|
+
raise ArgumentError.new("Directory #{root_dir} already exists") if File.directory?(root_dir)
|
27
|
+
# Check if it's empty
|
28
|
+
raise ArgumentError.new("Directory #{root_dir} not empty") unless Dir["#{root_dir}/*"].empty?
|
29
|
+
|
30
|
+
# Build the directory structure first
|
31
|
+
Dir.mkdir(root_dir)
|
32
|
+
|
33
|
+
DirectoryStructure.each do |dir|
|
34
|
+
dir_name = "#{root_dir}/#{dir}"
|
35
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
# For each template, render it, place it in the folder structure it corresponds to
|
39
|
+
template_root = File.join(File.dirname(__FILE__), 'templates')
|
40
|
+
|
41
|
+
# Construct the data object
|
42
|
+
template_binding = OpenStruct.new({:name=>app_name, :class_name=>classify(app_name)})
|
43
|
+
Dir["#{template_root}/**/*"].reject { |p| File.directory? p }.each do |template|
|
44
|
+
template_data = File.read(template)
|
45
|
+
relative_name = template.split("templates/")[1][0..-5]
|
46
|
+
# Hack to make the entry point ruby file share the same name as the app
|
47
|
+
relative_name = "#{app_name}.rb" if relative_name == "app.rb"
|
48
|
+
result = ERB.new(template_data).result(template_binding.instance_eval {binding})
|
49
|
+
File.write("#{root_dir}/#{relative_name}", result)
|
50
|
+
end
|
51
|
+
|
52
|
+
puts "Finished creating #{app_name}"
|
53
|
+
puts "#{`find ./#{app_name}`}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def classify(string)
|
57
|
+
string.gsub(/(?<=_|^)(\w)/){$1.upcase}.gsub(/(?:_)(\w)/,'\1')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class <%= class_name %>
|
2
|
+
class Env
|
3
|
+
def initialize(env)
|
4
|
+
@env = env
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
@env.downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def production?
|
12
|
+
@env == 'production'
|
13
|
+
end
|
14
|
+
|
15
|
+
def development?
|
16
|
+
@env == 'development'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.env
|
21
|
+
@env ||= Env.new(ENV['APP_ENV'] ||= 'development')
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.logger
|
25
|
+
@logger ||= Logger.new(ENV['APP_LOG_PATH'] || "./log/app.log").tap do |l|
|
26
|
+
l.level = Logger::DEBUG
|
27
|
+
l.formatter = lambda do |severity, datetime, progname, msg|
|
28
|
+
"[#{datetime} (#{Process.pid})] #{severity} : #{msg}\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Load all dependent gems
|
34
|
+
require 'bundler'
|
35
|
+
Bundler.require(:default, self.env.to_s)
|
36
|
+
|
37
|
+
# Set up additional load paths
|
38
|
+
|
39
|
+
$:.unshift File.dirname("./")
|
40
|
+
$:.unshift File.dirname("./lib")
|
41
|
+
$:.unshift File.dirname("./config")
|
42
|
+
$:.unshift File.dirname("./app")
|
43
|
+
|
44
|
+
# Load the right environment initializer
|
45
|
+
|
46
|
+
require "config/environments/#{self.env.to_s}"
|
47
|
+
|
48
|
+
# Load initializers
|
49
|
+
|
50
|
+
Dir["./config/initializers/*"].reject { |p| File.directory? p }.each {|file| require file }
|
51
|
+
|
52
|
+
# Load config
|
53
|
+
|
54
|
+
Dir["./config/**/*"].reject { |p| File.directory? p }.each {|file| require file}
|
55
|
+
|
56
|
+
# Load job files
|
57
|
+
|
58
|
+
Dir["./app/models/**/*"].reject { |p| File.directory? p }.each {|file| require file }
|
59
|
+
Dir["./app/services/**/*"].reject { |p| File.directory? p }.each {|file| require file }
|
60
|
+
Dir["./app/jobs/**/*"].reject { |p| File.directory? p }.each {|file| require file }
|
61
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/rapp/version.rb
ADDED
data/rapp.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rapp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rapp"
|
8
|
+
spec.version = Rapp::VERSION
|
9
|
+
spec.authors = ["StabbyCutyou"]
|
10
|
+
spec.email = ["sean.kelly@tapjoy.com"]
|
11
|
+
spec.summary = %q{rapp - A gem for building Ruby Apps}
|
12
|
+
spec.description = %q{tapp helps you build native ruby apps with a familiar structure and a handful of familiar conventions. Perfect for writing console apps or even daemons in Ruby!}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- StabbyCutyou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: tapp helps you build native ruby apps with a familiar structure and a
|
42
|
+
handful of familiar conventions. Perfect for writing console apps or even daemons
|
43
|
+
in Ruby!
|
44
|
+
email:
|
45
|
+
- sean.kelly@tapjoy.com
|
46
|
+
executables:
|
47
|
+
- rapp
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/rapp
|
57
|
+
- lib/rapp.rb
|
58
|
+
- lib/rapp/builder.rb
|
59
|
+
- lib/rapp/templates/Gemfile.erb
|
60
|
+
- lib/rapp/templates/Rakefile.erb
|
61
|
+
- lib/rapp/templates/app.rb.erb
|
62
|
+
- lib/rapp/templates/config/environments/development.rb.erb
|
63
|
+
- lib/rapp/templates/config/environments/production.rb.erb
|
64
|
+
- lib/rapp/templates/config/environments/test.rb.erb
|
65
|
+
- lib/rapp/templates/lib/tasks/console.rake.erb
|
66
|
+
- lib/rapp/version.rb
|
67
|
+
- rapp.gemspec
|
68
|
+
homepage: ''
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.5
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: rapp - A gem for building Ruby Apps
|
92
|
+
test_files: []
|