rapp 0.0.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11a87ccab2e7220ca6d71df878d4efdcbf69a19f
4
- data.tar.gz: 130d918a4b2b4efc33fbdc2bbc5ff8ea06abce0d
3
+ metadata.gz: 41d0cf6c0f28404a0ff147a8410d0839fa829be2
4
+ data.tar.gz: 19000ad06894dcf3cf151f285e1db8faad7730bf
5
5
  SHA512:
6
- metadata.gz: c7d944219f5345e026053d27f12ca3543b1ef1e5fdfd063b24544f4829efba5b8302ca51910545e483a06a760d7378911da697f7d659096b5bf4eb760184bd98
7
- data.tar.gz: bdd3ede7bb48ce39573e21598ef779f0486504f7ab83d747329496634c4550eac1c44f14a4da4216e790ffb0b80ff7f4009b1f41f375fca060692aa20a850f55
6
+ metadata.gz: f75920e664cf117ad3e6ac442321e09820f41ad79b03179f4b0c1e59b1944dc76c2db74751b5e013ae3d17a3b69b84def24b67169dbfed3756d0a093f8191d2e
7
+ data.tar.gz: b8b6533125946fda5d95d00c9ee83e46c7f8680c0beed694f18532768de33fa3c4b7ab550dd4dd7a663db84e415865687763862d2ec963dc2f4b93aa3dc7e482
data/README.md CHANGED
@@ -64,12 +64,17 @@ Rapp application structure looks like the following:
64
64
  * lib/tasks/
65
65
  * spec/
66
66
  * {app_name}.rb
67
+ * {app_name}_base.rb
67
68
  * Gemfile
68
69
  * Rakefile
69
70
 
70
71
  ### {app_name}.rb
71
72
 
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
+ This is the primary entry point for you application. It includes {app_name}_base to handle booting and requiring all the dependencies. The class itself is empty, and the only code that specifically resides in this file is adding the current directory to the load path, so it can more easily locate {app_name}_base. All other code for additions to the load path, requiring bundler dependencies, etc etc resides in {app_name}_base.
74
+
75
+ ### {app_name}_base.rb
76
+
77
+ Most of the generated code that Rapp creates lives here, such as:
73
78
 
74
79
  * Defining the environment
75
80
  * Providing an application level logger
@@ -80,8 +85,6 @@ Most of the generated code that Rapp creates lives here. This is the primary ent
80
85
 
81
86
  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
87
 
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
88
  ### App directory
86
89
 
87
90
  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.
data/lib/rapp/builder.rb CHANGED
@@ -42,7 +42,10 @@ module Rapp
42
42
  template_data = File.read(template)
43
43
  relative_name = template.split("templates/")[1][0..-5]
44
44
  # Hack to make the entry point ruby file share the same name as the app
45
+ # Need to clean this up, make it more extensible...
45
46
  relative_name = "#{app_name}.rb" if relative_name == "app.rb"
47
+ relative_name = "#{app_name}_base.rb" if relative_name == "app_base.rb"
48
+
46
49
  result = ERB.new(template_data).result(template_binding.instance_eval {binding})
47
50
  File.write("#{root_dir}/#{relative_name}", result)
48
51
  end
@@ -1,61 +1,6 @@
1
+ $:.unshift File.dirname("./")
2
+ require '<%= app_name %>_base'
1
3
  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
4
+ include <%=class_name%>Base
19
5
 
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
6
  end
@@ -0,0 +1,55 @@
1
+ require 'env'
2
+
3
+ module <%= class_name %>Base
4
+
5
+ def self.included(base) #:nodoc:
6
+ base.extend(ClassMethods)
7
+ <%= class_name%>Base.boot!
8
+ end
9
+
10
+ module ClassMethods
11
+ def env
12
+ @env ||= <%=class_name%>::Env.new(ENV['APP_ENV'] ||= 'development')
13
+ end
14
+
15
+ def logger
16
+ @logger ||= Logger.new(ENV['APP_LOG_PATH'] || "./log/app.log").tap do |l|
17
+ l.level = Logger::DEBUG
18
+ l.formatter = lambda do |severity, datetime, progname, msg|
19
+ "[#{datetime} (#{Process.pid})] #{severity} : #{msg}\n"
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def self.boot!
26
+ # Load all dependent gems
27
+ require 'bundler'
28
+ Bundler.require(:default, <%=class_name %>.env.to_s)
29
+
30
+ # Set up additional load paths
31
+
32
+ $:.unshift File.dirname("./")
33
+ $:.unshift File.dirname("./lib")
34
+ $:.unshift File.dirname("./config")
35
+ $:.unshift File.dirname("./app")
36
+
37
+ # Load the right environment initializer
38
+
39
+ require "config/environments/#{<%=class_name %>.env.to_s}"
40
+
41
+ # Load initializers
42
+
43
+ Dir["./config/initializers/*"].reject { |p| File.directory? p }.each {|file| require file }
44
+
45
+ # Load config
46
+
47
+ Dir["./config/**/*"].reject { |p| File.directory? p }.each {|file| require file}
48
+
49
+ # Load job files
50
+
51
+ Dir["./app/models/**/*"].reject { |p| File.directory? p }.each {|file| require file }
52
+ Dir["./app/services/**/*"].reject { |p| File.directory? p }.each {|file| require file }
53
+ Dir["./app/jobs/**/*"].reject { |p| File.directory? p }.each {|file| require file }
54
+ end
55
+ end
@@ -0,0 +1,19 @@
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
+ end
data/lib/rapp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rapp
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - StabbyCutyou
@@ -59,9 +59,11 @@ files:
59
59
  - lib/rapp/templates/Gemfile.erb
60
60
  - lib/rapp/templates/Rakefile.erb
61
61
  - lib/rapp/templates/app.rb.erb
62
+ - lib/rapp/templates/app_base.rb.erb
62
63
  - lib/rapp/templates/config/environments/development.rb.erb
63
64
  - lib/rapp/templates/config/environments/production.rb.erb
64
65
  - lib/rapp/templates/config/environments/test.rb.erb
66
+ - lib/rapp/templates/env.rb.erb
65
67
  - lib/rapp/templates/lib/tasks/console.rake.erb
66
68
  - lib/rapp/version.rb
67
69
  - rapp.gemspec