totem 0.0.4 → 0.0.5

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: 1642673b0d6a2651e9c4d5b6b92042d1ff2762da
4
- data.tar.gz: 005d524961253413c80a226d6cd7fbb19372886f
3
+ metadata.gz: a738bec72280ea0baf97f9860a2238ea0579f84a
4
+ data.tar.gz: 80ce4e412fed17d5184416406bc72d97165b067f
5
5
  SHA512:
6
- metadata.gz: 153b35b769aeafb208e237efb13efb6d5b1fed0692a168da4a77f607715c137fa27f28180fb206669f64d857e2d5e52a92b731e994394a4ce6bee1f6041a5b33
7
- data.tar.gz: ceac5fb168525595f9062d3a37f7c12100184c0b03fb25fbe3293796639e4bfb1b9349e8a04878964f65a40db82673652e3f916ec67a92b7bc312a2bf9071cf8
6
+ metadata.gz: 7a38f51673de6d90b89411cb151296f6a586caba29c8bac1e107d76b01cd4c1fa585828fed5ac929c5a3d8ee42abb43712059a5d608a49a89c49e9fd31d97503
7
+ data.tar.gz: 666ca16224d5a57a6e62c85ba1b82a07fbf2acdc43c189eb110f65944654f81ae6b517b85466cc051e6f9987233902cf1a4aa45fece8b0eb24d0971b1bd9a605
data/README.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # Totem
2
2
 
3
- Totem is a framework for creating Ruby projects.
3
+ Totem is a Ruby gem for creating Ruby projects.
4
4
  It's like having a Rails project folder without the Rails dependency.
5
5
 
6
- Features:
7
- - Ruby on Rails inspired folder structure.
8
- - Lightweight and simple code.
9
- - Integrated console.
10
- - Uses built in Ruby classes and avoids depending on 3rd party gems.
11
- - Designed for MRI and JRuby.
12
- - Easily extensible through gems or directly in your project (ActiveRecord gem coming soon).
13
- - Designed for multi-threaded applications.
6
+ ##### Goals:
7
+ - Use a Ruby on Rails inspired folder structure because many developers are familiar with it.
8
+ - Keep the gem lightweight with simple and easy to understand code.
9
+ - Prefer built in Ruby classes in order to avoid third party dependencies.
10
+ - Design from day one for MRI and JRuby.
11
+ - Make it easily extensible.
12
+ - Maintain thread safety so that it can be used with gems such as [Tribe](https://github.com/chadrem/tribe) or [Celluloid](https://github.com/celluloid/celluloid).
13
+
14
+ ##### Features:
15
+ - console
16
+ - logger
17
+ - environments (development, production, stage, etc).
14
18
 
15
19
  ## Installation
16
20
 
@@ -26,22 +30,51 @@ Or install it yourself as:
26
30
 
27
31
  $ gem install totem
28
32
 
29
- ## Usage
33
+ ## Create a project
30
34
 
31
- Create a new project called "my_app" in the current directory:
35
+ Create a new project called `my_app` in the current directory:
32
36
 
33
- $ totem new my_app
37
+ $ bundle exec totem new my_app
34
38
 
35
- You must now setup Bundler (and rvm, rbenv, etc) for your new project:
39
+ You must now setup Bundler (and rvm, rbenv, etc if you use them) for your new project:
36
40
 
37
41
  $ bundle
38
42
 
39
- You can now create your custom classes in the "app" directory.
40
- You will need to manually "require" your classes in "app/loader.rb" since there isn't an auto-loader.
43
+ You can now create your custom classes in the `app` directory.
44
+ You will need to manually `require` your classes in `app/loader.rb` since Tribe doesn't have an auto-loader.
41
45
 
42
46
  Totem comes with an IRB based console similar to Rails:
43
47
 
44
- $ totem console
48
+ $ bundle exec totem console
49
+
50
+ ## Totem API
51
+
52
+ Totem comes with some built in methods that should be familiar to any Rails developer.
53
+ Copy and paste the below code into `app/my_class.rb`.
54
+ You can then run this example in the console by entering `MyClass.new.run`.
55
+ Don't forget, you need to register this class in `app/loader.rb` with `require my_class`.
56
+
57
+ class MyClass
58
+ def run
59
+ puts 'Totem provides a few class variables to simplify programming...'
60
+ puts " Root: #{Totem.root}"
61
+ puts " Environment: #{Totem.env}"
62
+ puts
63
+
64
+ puts 'Totem includes a logger...'
65
+ Totem.logger.error('Example error log entry')
66
+ puts " Check your #{Totem.log_file_path} to see the entry."
67
+ puts
68
+
69
+ puts 'Enjoy!'
70
+ end
71
+ end
72
+
73
+ ## Add-ons
74
+
75
+ Below is a list of available add-ons that extend the functionality of a Totem project:
76
+
77
+ - [totem_activerecord](https://github.com/chadrem/totem_activerecord): The Rails database library
45
78
 
46
79
  ## Contributing
47
80
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
- desc 'Start a Totem interactive console'
3
+ desc 'Start an IRB session'
4
4
  task :console do
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
6
6
 
7
7
  require 'totem'
8
8
 
9
- Totem::Shell.new([:console]).run
9
+ ARGV.clear
10
+ IRB.start
10
11
  end
@@ -13,8 +13,10 @@ module Totem
13
13
  @setup = true
14
14
  @root = root
15
15
  Bundler.require(Totem.env.to_sym)
16
+ run_callbacks(:before_load_app)
16
17
  $LOAD_PATH.unshift(root + '/app')
17
18
  load_app
19
+ run_callbacks(:after_load_app)
18
20
 
19
21
  return true
20
22
  end
@@ -51,6 +53,15 @@ module Totem
51
53
  return @logger
52
54
  end
53
55
 
56
+ def self.register_callback(type, callback=nil, &block)
57
+ @callbacks ||= {}
58
+ (@callbacks[type] ||= []) << (callback || block)
59
+
60
+ return true
61
+ end
62
+
63
+ private
64
+
54
65
  def self.log_to_stdout
55
66
  init_logger($stdout)
56
67
 
@@ -82,4 +93,11 @@ module Totem
82
93
 
83
94
  return nil
84
95
  end
96
+
97
+ def self.run_callbacks(type)
98
+ @callbacks ||= {}
99
+ (@callbacks[type] || []).each { |cb| cb.call }
100
+
101
+ return nil
102
+ end
85
103
  end
@@ -13,6 +13,14 @@ module Totem
13
13
  end
14
14
 
15
15
  def run
16
+ env_path = 'config/environment.rb'
17
+ if File.exists?(env_path)
18
+ load(env_path)
19
+ else
20
+ puts "Unable to find #{env_path}. You must run this command from your project root directory."
21
+ exit
22
+ end
23
+
16
24
  if @args[0].nil?
17
25
  puts_usage
18
26
  return
@@ -42,7 +50,7 @@ module Totem
42
50
  private
43
51
 
44
52
  def puts_usage
45
- puts "Usage:\n totem <command>"
53
+ puts "Usage:\n bundle exec totem <command>"
46
54
  puts
47
55
  puts "Commands:\n #{self.class.cmds.keys.join(', ')}"
48
56
  end
@@ -4,14 +4,6 @@ module Totem
4
4
  module ShellCmds
5
5
  class Console < Totem::ShellCmds::Base
6
6
  def run
7
- env_path = 'config/environment.rb'
8
- if File.exists?(env_path)
9
- load(env_path)
10
- else
11
- puts "Unable to find #{env_path}. You must run this command from your project root directory."
12
- exit
13
- end
14
-
15
7
  ARGV.clear
16
8
  IRB.start
17
9
  end
@@ -1,3 +1,3 @@
1
1
  module Totem
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Totem::VERSION
9
9
  gem.authors = ['Chad Remesch']
10
10
  gem.email = ['chad@remesch.com']
11
- gem.description = %q{Totem is a framework for creating Ruby projects.}
11
+ gem.description = %q{Totem is a Ruby gem for creating Ruby projects.}
12
12
  gem.summary = %q{It's like having a Rails project folder without the Rails dependency.}
13
13
  gem.homepage = 'https://github.com/chadrem/totem'
14
14
 
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency("bundler", "~> 1.5")
21
+ gem.add_development_dependency("rake")
19
22
  end
metadata CHANGED
@@ -1,16 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Totem is a framework for creating Ruby projects.
11
+ date: 2014-03-13 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Totem is a Ruby gem for creating Ruby projects.
14
42
  email:
15
43
  - chad@remesch.com
16
44
  executables: