lotusrb 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/FEATURES.md +17 -0
  4. data/README.md +16 -355
  5. data/lib/lotus.rb +0 -1
  6. data/lib/lotus/action/csrf_protection.rb +167 -0
  7. data/lib/lotus/application.rb +3 -1
  8. data/lib/lotus/cli.rb +14 -13
  9. data/lib/lotus/commands/console.rb +1 -1
  10. data/lib/lotus/commands/db.rb +102 -0
  11. data/lib/lotus/commands/db/abstract.rb +15 -0
  12. data/lib/lotus/commands/db/apply.rb +14 -0
  13. data/lib/lotus/commands/db/console.rb +1 -5
  14. data/lib/lotus/commands/db/create.rb +14 -0
  15. data/lib/lotus/commands/db/drop.rb +14 -0
  16. data/lib/lotus/commands/db/migrate.rb +19 -0
  17. data/lib/lotus/commands/db/prepare.rb +14 -0
  18. data/lib/lotus/commands/db/version.rb +14 -0
  19. data/lib/lotus/commands/generate.rb +20 -20
  20. data/lib/lotus/commands/new.rb +1 -0
  21. data/lib/lotus/commands/routes.rb +1 -2
  22. data/lib/lotus/configuration.rb +29 -0
  23. data/lib/lotus/container.rb +19 -3
  24. data/lib/lotus/environment.rb +62 -9
  25. data/lib/lotus/frameworks.rb +1 -0
  26. data/lib/lotus/generators/action.rb +46 -10
  27. data/lib/lotus/generators/action/action_spec.minitest.tt +1 -1
  28. data/lib/lotus/generators/action/action_spec.rspec.tt +1 -1
  29. data/lib/lotus/generators/action/view_spec.minitest.tt +2 -1
  30. data/lib/lotus/generators/action/view_spec.rspec.tt +2 -1
  31. data/lib/lotus/generators/app.rb +39 -0
  32. data/lib/lotus/generators/app/.gitkeep +1 -0
  33. data/lib/lotus/generators/application/app.rb +184 -0
  34. data/lib/lotus/generators/application/app/.env.development.tt +3 -0
  35. data/lib/lotus/generators/application/app/.env.test.tt +3 -0
  36. data/lib/lotus/generators/application/{container/config → app}/.env.tt +0 -0
  37. data/lib/lotus/generators/application/app/.gitkeep +1 -0
  38. data/lib/lotus/generators/application/app/Gemfile.tt +35 -0
  39. data/lib/lotus/generators/application/app/Rakefile.minitest.tt +10 -0
  40. data/lib/lotus/generators/application/app/Rakefile.rspec.tt +5 -0
  41. data/lib/lotus/generators/application/app/apps/.gitkeep.tt +1 -0
  42. data/lib/lotus/generators/application/app/capybara.rb.rspec.tt +8 -0
  43. data/lib/lotus/generators/application/app/config.ru.tt +3 -0
  44. data/lib/lotus/generators/application/app/config/application.rb.tt +227 -0
  45. data/lib/lotus/generators/application/app/config/environment.rb.tt +5 -0
  46. data/lib/lotus/generators/application/app/config/routes.rb.tt +2 -0
  47. data/lib/lotus/generators/application/app/db/.gitkeep +1 -0
  48. data/lib/lotus/generators/application/app/features_helper.rb.minitest.tt +11 -0
  49. data/lib/lotus/generators/application/app/features_helper.rb.rspec.tt +12 -0
  50. data/lib/lotus/generators/application/app/gitignore.tt +2 -0
  51. data/lib/lotus/generators/application/app/lib/app_name.rb.tt +47 -0
  52. data/lib/lotus/generators/application/app/lib/chirp/entities/.gitkeep +1 -0
  53. data/lib/lotus/generators/application/app/lib/chirp/repositories/.gitkeep +1 -0
  54. data/lib/lotus/generators/application/app/lib/config/mapping.rb.tt +7 -0
  55. data/lib/lotus/generators/application/app/lotusrc.tt +3 -0
  56. data/lib/lotus/generators/application/app/rspec.rspec.tt +2 -0
  57. data/lib/lotus/generators/application/app/schema.sql.tt +0 -0
  58. data/lib/lotus/generators/application/app/spec_helper.rb.minitest.tt +7 -0
  59. data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +100 -0
  60. data/lib/lotus/generators/application/app/templates/application.html.erb.tt +9 -0
  61. data/lib/lotus/generators/application/app/views/application_layout.rb.tt +7 -0
  62. data/lib/lotus/generators/application/container.rb +37 -13
  63. data/lib/lotus/generators/application/container/{config/.env.development.tt → .env.development.tt} +0 -0
  64. data/lib/lotus/generators/application/container/{config/.env.test.tt → .env.test.tt} +0 -0
  65. data/lib/lotus/generators/application/container/.env.tt +1 -0
  66. data/lib/lotus/generators/application/container/lib/app_name.rb.tt +9 -0
  67. data/lib/lotus/generators/application/container/schema.sql.tt +0 -0
  68. data/lib/lotus/generators/migration.rb +58 -0
  69. data/lib/lotus/generators/migration/migration.rb.tt +4 -0
  70. data/lib/lotus/generators/model.rb +10 -7
  71. data/lib/lotus/generators/slice.rb +4 -12
  72. data/lib/lotus/generators/slice/application.rb.tt +3 -19
  73. data/lib/lotus/generators/slice/config/routes.rb.tt +1 -7
  74. data/lib/lotus/loader.rb +15 -1
  75. data/lib/lotus/lotusrc.rb +8 -3
  76. data/lib/lotus/templates/{welcome.html → welcome.html.erb} +4 -3
  77. data/lib/lotus/version.rb +1 -1
  78. data/lib/lotus/welcome.rb +20 -1
  79. data/lotusrb.gemspec +5 -5
  80. metadata +67 -18
  81. data/lib/lotus/generators/slice/action.rb.tt +0 -8
  82. data/lib/lotus/generators/slice/config/mapping.rb.tt +0 -13
  83. data/lib/lotus/generators/slice/templates/template.html.erb.tt +0 -2
  84. data/lib/lotus/generators/slice/view.rb.tt +0 -5
  85. data/lib/lotus/logger.rb +0 -141
@@ -1,8 +0,0 @@
1
- module <%= config[:classified_slice_name] %>::Controllers::Home
2
- class Index
3
- include <%= config[:classified_slice_name] %>::Action
4
-
5
- def call(params)
6
- end
7
- end
8
- end
@@ -1,13 +0,0 @@
1
- # Configure your database mapping here.
2
- #
3
- # Intended for specifying specific slice mappings.
4
- #
5
- # See: http://www.rubydoc.info/gems/lotus-model/#Usage
6
- #
7
- # collection :users do
8
- # entity User
9
- # repository UserRepository
10
- #
11
- # attribute :id, Integer
12
- # attribute :name, String
13
- # end
@@ -1,2 +0,0 @@
1
- <h1>Welcome to Lotus!</h1>
2
- <h3>This template is rendered by <code><%= config[:classified_slice_name] %>::Views::Home::Index</code> and it's available at: <code>apps/<%= config[:slice_name] %>/templates/home/index.html.erb</code></h3>
@@ -1,5 +0,0 @@
1
- module <%= config[:classified_slice_name] %>::Views::Home
2
- class Index
3
- include <%= config[:classified_slice_name] %>::View
4
- end
5
- end
data/lib/lotus/logger.rb DELETED
@@ -1,141 +0,0 @@
1
- require 'logger'
2
- require 'lotus/utils/string'
3
-
4
- module Lotus
5
- # Lotus logger
6
- #
7
- # Implement with the same interface of Ruby std lib `Logger`.
8
- # It uses `STDOUT` as output device.
9
- #
10
- #
11
- #
12
- # When a Lotus application is initialized, it creates a logger for that specific application.
13
- # For instance for a `Bookshelf::Application` a `Bookshelf::Logger` will be available.
14
- #
15
- # This is useful for auto-tagging the output. Eg (`[Booshelf]`).
16
- #
17
- # When used stand alone (eg. `Lotus::Logger.info`), it tags lines with `[Shared]`.
18
- #
19
- #
20
- #
21
- # The available severity levels are the same of `Logger`:
22
- #
23
- # * debug
24
- # * error
25
- # * fatal
26
- # * info
27
- # * unknown
28
- # * warn
29
- #
30
- # Those levels are available both as class and instance methods.
31
- #
32
- # @since 0.2.1
33
- #
34
- # @see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html
35
- # @see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger/Severity.html
36
- #
37
- # @example Basic usage
38
- # require 'lotus'
39
- #
40
- # module Bookshelf
41
- # class Application < Lotus::Application
42
- # end
43
- # end
44
- #
45
- # # Initialize the application with the following code:
46
- # Bookshelf::Application.load!
47
- # # or
48
- # Bookshelf::Application.new
49
- #
50
- # Bookshelf::Logger.info('Hello')
51
- # # => I, [2015-01-10T21:55:12.727259 #80487] INFO -- [Bookshelf] : Hello
52
- #
53
- # Bookshelf::Logger.new.info('Hello')
54
- # # => I, [2015-01-10T21:55:12.727259 #80487] INFO -- [Bookshelf] : Hello
55
- #
56
- # @example Standalone usage
57
- # require 'lotus'
58
- #
59
- # Lotus::Logger.info('Hello')
60
- # # => I, [2015-01-10T21:55:12.727259 #80487] INFO -- [Lotus] : Hello
61
- #
62
- # Lotus::Logger.new.info('Hello')
63
- # # => I, [2015-01-10T21:55:12.727259 #80487] INFO -- [Lotus] : Hello
64
- #
65
- # @example Custom tagging
66
- # require 'lotus'
67
- #
68
- # Lotus::Logger.new('FOO').info('Hello')
69
- # # => I, [2015-01-10T21:55:12.727259 #80487] INFO -- [FOO] : Hello
70
- class Logger < ::Logger
71
- # Lotus::Logger default formatter
72
- #
73
- # @since 0.2.1
74
- # @api private
75
- #
76
- # @see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger/Formatter.html
77
- class Formatter < ::Logger::Formatter
78
- # @since 0.2.1
79
- # @api private
80
- attr_writer :application_name
81
-
82
- # @since 0.2.1
83
- # @api private
84
- #
85
- # @see http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger/Formatter.html#method-i-call
86
- def call(severity, time, progname, msg)
87
- progname = "[#{@application_name}] #{progname}"
88
- super(severity, time.utc, progname, msg)
89
- end
90
- end
91
-
92
- # Default application name.
93
- # This is used as a fallback for tagging purposes.
94
- #
95
- # @since 0.2.1
96
- # @api private
97
- DEFAULT_APPLICATION_NAME = 'Lotus'.freeze
98
-
99
- # @since 0.2.1
100
- # @api private
101
- attr_writer :application_name
102
-
103
- # Initialize a logger
104
- #
105
- # @param application_name [String] an optional application name used for
106
- # tagging purposes
107
- #
108
- # @since 0.2.1
109
- def initialize(application_name = nil)
110
- super(STDOUT)
111
-
112
- @application_name = application_name
113
- @formatter = Lotus::Logger::Formatter.new.tap { |f| f.application_name = self.application_name }
114
- end
115
-
116
- # Returns the current application name, this is used for tagging purposes
117
- #
118
- # @return [String] the application name
119
- #
120
- # @since 0.2.1
121
- def application_name
122
- @application_name || _application_name_from_namespace || _default_application_name
123
- end
124
-
125
- private
126
- # @since 0.2.1
127
- # @api private
128
- def _application_name_from_namespace
129
- class_name = self.class.name
130
- namespace = Utils::String.new(class_name).namespace
131
-
132
- class_name != namespace and return namespace
133
- end
134
-
135
- # @since 0.2.1
136
- # @api private
137
- def _default_application_name
138
- DEFAULT_APPLICATION_NAME
139
- end
140
- end
141
- end