ruby-app 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,6 +12,6 @@ Supports bundler, environments, rails dirs tree.
12
12
 
13
13
  Run like:
14
14
 
15
- $ ./bin/dummy
16
- $ APP_ENV=production ./bin/dummy
15
+ $ ./bin/example
16
+ $ APP_ENV=production ./bin/example
17
17
 
data/bin/ruby-app CHANGED
@@ -16,7 +16,8 @@ class RubyAppGenerator < Thor::Group
16
16
  end
17
17
 
18
18
  def chmod_example_bin
19
- chmod "#{name}/bin/dummy", 0755
19
+ chmod "#{name}/bin/example", 0755
20
+ chmod "#{name}/bin/console", 0755
20
21
  end
21
22
 
22
23
  private
data/generator/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'rake', :require => false
3
4
  gem 'ruby-app'
4
- gem 'rake', :require => false
5
+
5
6
 
6
7
 
7
8
 
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), %w{.. config environment})
3
+
4
+ require 'irb'
5
+ require 'irb/completion'
6
+
7
+ IRB.start
File without changes
@@ -6,7 +6,7 @@ require 'bundler/setup'
6
6
  class Application
7
7
  class << self
8
8
  def root
9
- @root ||= File.join(File.dirname(__FILE__), %w(..))
9
+ @root ||= File.expand_path('../..', __FILE__)
10
10
  end
11
11
  end
12
12
  end
@@ -26,6 +26,18 @@ class Application
26
26
  def config
27
27
  CommonConfig
28
28
  end
29
+
30
+ def identifier
31
+ "ruby-app"
32
+ end
33
+
34
+ def rake_paths
35
+ @rake_paths ||= []
36
+ end
37
+
38
+ def initializer_paths
39
+ @initializer_paths ||= []
40
+ end
29
41
  end
30
42
  end
31
43
 
@@ -19,14 +19,12 @@ class CommonConfig
19
19
  private
20
20
 
21
21
  def method_missing(name, *params, &block)
22
- params = block.call if block
23
-
24
22
  if name.to_s =~ /_address$/i
25
23
  require 'ostruct'
26
- @configs[name] = OpenStruct.new(:host => params[0], :port => params[1].to_i)
24
+ @configs[name] = block || OpenStruct.new(:host => params[0], :port => params[1].to_i)
27
25
  else
28
26
  params = params[0] if params.size == 1
29
- @configs[name] = params
27
+ @configs[name] = block || params
30
28
  end
31
29
  end
32
30
  end
@@ -37,7 +35,8 @@ class CommonConfig
37
35
 
38
36
  def self.[](option)
39
37
  if @@configs.key?(option)
40
- @@configs[option]
38
+ res = @@configs[option]
39
+ res.is_a?(Proc) ? res.call : res
41
40
  else
42
41
  super
43
42
  end
@@ -45,7 +44,8 @@ class CommonConfig
45
44
 
46
45
  def self.method_missing(*args)
47
46
  if @@configs.key?(args[0])
48
- @@configs[args[0]]
47
+ res = @@configs[args[0]]
48
+ res.is_a?(Proc) ? res.call : res
49
49
  else
50
50
  super
51
51
  end
@@ -36,6 +36,13 @@ end
36
36
  # default config from app
37
37
  require File.join(App.root, %w{config config})
38
38
 
39
+ # load initializers from other gems
40
+ unless App.initializer_paths.empty?
41
+ App.initializer_paths.flatten.each do |path|
42
+ require File.expand_path(path)
43
+ end
44
+ end
45
+
39
46
  # configs from app for env
40
47
  begin
41
48
  require File.join(App.root, %W( config environments #{App.env}))
@@ -1,6 +1,6 @@
1
1
 
2
2
  task :environment do
3
- require File.join(App.root, %w{config environment})
3
+ require File.join(App.root, %w{ config environment })
4
4
  end
5
5
 
6
6
  # load gem rakes
@@ -8,6 +8,13 @@ Dir["#{File.dirname(__FILE__)}/tasks/*.{rb,rake}"].each do |f|
8
8
  load f
9
9
  end
10
10
 
11
+ # load other gems rakes
12
+ if defined?(App) && !App.rake_paths.empty?
13
+ App.rake_paths.each do |path|
14
+ load File.expand_path(path)
15
+ end
16
+ end
17
+
11
18
  # load app rakes
12
19
  if defined?(App)
13
20
  Dir["#{App.root}/lib/rake_tasks/*.{rb,rake}"].each do |f|
@@ -1,3 +1,3 @@
1
1
  module RubyApp
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/spec/app_spec.rb CHANGED
@@ -24,6 +24,14 @@ describe "RubyApp" do
24
24
  App::BLA.should == 1
25
25
  end
26
26
 
27
+ it "proc in config" do
28
+ App.config.proc_test.should == "bbbccc"
29
+ end
30
+
31
+ it "should load extensions" do
32
+ App.some_gem_method.should == "some gem method"
33
+ end
34
+
27
35
  it "force set env" do
28
36
  App.env.should == 'test3'
29
37
  App.config.apps.size.should == 4
@@ -0,0 +1,6 @@
1
+
2
+ class Application
3
+ def self.some_gem_method
4
+ "some gem method"
5
+ end
6
+ end
@@ -4,6 +4,10 @@ require File.join(File.dirname(__FILE__), %w{ boot })
4
4
  ENV['APP_ENV'] = 'test3'
5
5
 
6
6
  $:.unshift(File.join(File.dirname(__FILE__), %w{.. .. .. lib}))
7
+
8
+ # gem extension
9
+ App.initializer_paths << File.join(File.dirname(__FILE__), %w{.. .. gem_app gem})
10
+
7
11
  require 'ruby-app/environment'
8
12
 
9
13
  App.config.test_thing << 3
@@ -5,5 +5,9 @@ App.config.define :test3 do
5
5
  some2 "bbb"
6
6
 
7
7
  bla 12
8
+
9
+ proc_test do
10
+ App.config.some2 + "ccc"
11
+ end
8
12
 
9
13
  end
metadata CHANGED
@@ -1,120 +1,115 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-app
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 4
10
+ version: 0.1.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Makarchev Konstantin
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-06-22 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-06-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: activesupport
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: thor
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: thor
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: bundler
64
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
65
52
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
70
60
  type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
73
66
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :runtime
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
79
77
  name: rspec
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
78
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
79
+ requirement: &id005 !ruby/object:Gem::Requirement
89
80
  none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rake
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
102
88
  type: :development
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: rake
103
92
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
93
+ requirement: &id006 !ruby/object:Gem::Requirement
105
94
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- description: Little ruby application template. For creates light ruby apps (daemons,
111
- EventMachine-apps, ...). Supports bundler, environments, rails dirs tree.
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ type: :development
103
+ version_requirements: *id006
104
+ description: Little ruby application template. For creates light ruby apps (daemons, EventMachine-apps, ...). Supports bundler, environments, rails dirs tree.
112
105
  email: kostya27@gmail.com
113
- executables:
106
+ executables:
114
107
  - ruby-app
115
108
  extensions: []
109
+
116
110
  extra_rdoc_files: []
117
- files:
111
+
112
+ files:
118
113
  - .gitignore
119
114
  - Gemfile
120
115
  - LICENSE
@@ -125,7 +120,8 @@ files:
125
120
  - generator/Gemfile
126
121
  - generator/Rakefile
127
122
  - generator/app/models/.gitkeep
128
- - generator/bin/dummy
123
+ - generator/bin/console
124
+ - generator/bin/example
129
125
  - generator/config/boot.rb
130
126
  - generator/config/config.rb
131
127
  - generator/config/environment.rb
@@ -148,6 +144,7 @@ files:
148
144
  - lib/ruby-app/version.rb
149
145
  - ruby-app.gemspec
150
146
  - spec/app_spec.rb
147
+ - spec/gem_app/gem.rb
151
148
  - spec/spec_helper.rb
152
149
  - spec/test_app/.gitignore
153
150
  - spec/test_app/app/models/.gitkeep
@@ -168,26 +165,36 @@ files:
168
165
  - spec/test_app/lib/application.rb
169
166
  homepage: http://github.com/kostya/ruby-app
170
167
  licenses: []
168
+
171
169
  post_install_message:
172
170
  rdoc_options: []
173
- require_paths:
171
+
172
+ require_paths:
174
173
  - lib
175
- required_ruby_version: !ruby/object:Gem::Requirement
174
+ required_ruby_version: !ruby/object:Gem::Requirement
176
175
  none: false
177
- requirements:
178
- - - ! '>='
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 0
182
+ version: "0"
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
184
  none: false
183
- requirements:
184
- - - ! '>='
185
- - !ruby/object:Gem::Version
186
- version: '0'
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 3
189
+ segments:
190
+ - 0
191
+ version: "0"
187
192
  requirements: []
193
+
188
194
  rubyforge_project:
189
195
  rubygems_version: 1.8.24
190
196
  signing_key:
191
197
  specification_version: 3
192
198
  summary: Ruby application template
193
199
  test_files: []
200
+