hobo 1.3.0.pre14 → 1.3.0.pre15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre14
1
+ 1.3.0.pre15
@@ -177,3 +177,4 @@ en:
177
177
 
178
178
  boolean_yes: "Yes"
179
179
  boolean_no: "No"
180
+ password_hidden: "[password hidden]"
@@ -183,3 +183,4 @@
183
183
 
184
184
  boolean_yes: "Si"
185
185
  boolean_no: "No"
186
+ password_hidden: "[contraseña]"
@@ -184,3 +184,4 @@ it:
184
184
 
185
185
  boolean_yes: "Si"
186
186
  boolean_no: "No"
187
+ password_hidden: "[parola chiave]"
@@ -178,3 +178,4 @@
178
178
 
179
179
  boolean_yes: "Sim"
180
180
  boolean_no: "Não"
181
+ password_hidden: "[palavra-chave]"
@@ -1,14 +1,25 @@
1
+ require 'generators/hobo_support/eval_template'
2
+
1
3
  module Hobo
2
4
  class RoutesGenerator < Rails::Generators::Base
3
5
  source_root File.expand_path('../templates', __FILE__)
4
6
 
7
+ include Generators::HoboSupport::EvalTemplate
8
+
5
9
  def self.banner
6
10
  "rails generate hobo:routes #{self.arguments.map(&:usage).join(' ')} [options]"
7
11
  end
8
12
 
9
13
  def generate_routes
10
14
  Hobo::Routes.reset_linkables
11
- template "hobo_routes.rb.erb", Hobo::Engine.config.hobo.routes_path
15
+ h = Hobo::Engine.config.hobo
16
+ template_name = 'hobo_routes.rb.erb'
17
+ if h.read_only_file_system
18
+ # just fill the @linkable_keys without writing any file
19
+ eval_template template_name
20
+ else
21
+ template template_name, h.routes_path
22
+ end
12
23
  end
13
24
 
14
25
  private
@@ -44,6 +44,9 @@ module Hobo
44
44
  class_option :git_repo, :type => :boolean,
45
45
  :desc => "Create the git repository with the initial commit"
46
46
 
47
+ class_option :gitignore_auto_generated_files, :type => :boolean,
48
+ :desc => "Add the auto-generated files to .gitignore", :default => true
49
+
47
50
 
48
51
  def startup
49
52
  if wizard?
@@ -205,16 +208,20 @@ EOI
205
208
  if wizard?
206
209
  say_title 'Git Repository'
207
210
  return unless yes_no?("Do you want to initialize a git repository now?")
211
+ gitignore_auto_generated = yes_no? "Do you want git to ignore the auto-generated files?\n(Choose 'n' only if you are planning to deploy on a read-only File System like Heroku)"
208
212
  say 'Initializing git repository...'
209
213
  else
210
214
  return unless options[:git_repo]
215
+ gitignore_auto_generated = options[:gitignore_auto_generated_files]
216
+ end
217
+ if gitignore_auto_generated
218
+ hobo_routes_rel_path = Hobo::Engine.config.hobo.routes_path.relative_path_from Rails.root
219
+ append_file '.gitignore', "app/views/taglibs/auto/**/*\n#{hobo_routes_rel_path}\n"
211
220
  end
212
- hobo_routes_rel_path = Hobo::Engine.config.hobo.routes_path.relative_path_from Rails.root
213
- append_file '.gitignore', "app/views/taglibs/auto/**/*\n#{hobo_routes_rel_path}\n"
214
221
  git :init
215
222
  git :add => '.'
216
223
  git :commit => '-m "initial commit"'
217
- say "NOTICE: If you change the config.hobo.routes_path, you should update the .gitignore file accordingly.", Color::YELLOW
224
+ say("NOTICE: If you change the config.hobo.routes_path, you should update the .gitignore file accordingly.", Color::YELLOW) if gitignore_auto_generated
218
225
  end
219
226
 
220
227
  def finalize
@@ -97,7 +97,7 @@ module Hobo
97
97
  end
98
98
  page << renderer.part_contexts_storage if renderer
99
99
  end
100
- end
100
+ end
101
101
 
102
102
 
103
103
  def dryml_context
data/lib/hobo/engine.rb CHANGED
@@ -39,30 +39,21 @@ module Hobo
39
39
 
40
40
  ActiveSupport.on_load(:before_initialize) do
41
41
  require 'hobo/undefined'
42
-
42
+ HoboFields.never_wrap(Hobo::Undefined)
43
43
  h = config.hobo
44
44
  Dryml::DrymlGenerator.enable([h.rapid_generators_path], h.auto_taglibs_path)
45
-
46
- HoboFields.never_wrap(Hobo::Undefined)
47
45
  end
48
46
 
49
47
  initializer 'hobo.routes' do |app|
50
48
  h = app.config.hobo
51
49
  # generate at first boot, so no manual generation is required
52
50
  unless File.exists?(h.routes_path)
53
- if h.read_only_file_system
54
- raise Hobo::Error, "No #{h.routes_path} found!"
55
- else
56
- Rails::Generators.invoke('hobo:routes', %w[-f -q])
57
- end
51
+ raise Hobo::Error, "No #{h.routes_path} found!" if h.read_only_file_system
52
+ Rails::Generators.invoke('hobo:routes', %w[-f -q])
58
53
  end
59
54
  app.routes_reloader.paths << h.routes_path
60
- unless h.read_only_file_system
61
- app.config.to_prepare do
62
- Rails::Generators.configure!
63
- # generate before each request in development
64
- Rails::Generators.invoke('hobo:routes', %w[-f -q])
65
- end
55
+ app.config.to_prepare do
56
+ Rails::Generators.invoke('hobo:routes', %w[-f -q])
66
57
  end
67
58
  end
68
59
 
@@ -15,8 +15,8 @@ module ActiveRecord
15
15
  end
16
16
  alias_method_chain :scoped, :origin
17
17
 
18
- def method_missing_with_origin(method, *args)
19
- res = method_missing_without_origin(method, *args)
18
+ def method_missing_with_origin(method, *args, &block)
19
+ res = method_missing_without_origin(method, *args, &block)
20
20
  res.origin = @owner if res.respond_to?(:origin)
21
21
  res.origin_attribute = @reflection.name if res.respond_to?(:origin_attribute)
22
22
  res
data/lib/hobo/routes.rb CHANGED
@@ -1,32 +1,31 @@
1
1
  module Hobo
2
- class Routes
3
- class << self
2
+ module Routes
3
+ extend self
4
4
 
5
- def reset_linkables
6
- @linkable_keys = Set.new
7
- end
8
-
9
- def linkable_key(klass, action, options)
10
- subsite = options[:subsite] || options['subsite']
11
- method = options[:method] || options['method'] || :get
12
- [ subsite, klass.name, action, method ].join('/')
13
- end
5
+ def reset_linkables
6
+ @linkable_keys = Set.new
7
+ end
14
8
 
15
- def linkable!(klass, action, options={})
16
- @linkable_keys << linkable_key(klass, action, options)
17
- end
9
+ def linkable_key(klass, action, options)
10
+ subsite = options[:subsite] || options['subsite']
11
+ method = options[:method] || options['method'] || :get
12
+ [ subsite, klass.name, action, method ].join('/')
13
+ end
18
14
 
19
- def linkable?(klass, action, options={})
20
- @linkable_keys.member? linkable_key(klass, action, options)
21
- end
15
+ def linkable!(klass, action, options={})
16
+ @linkable_keys << linkable_key(klass, action, options)
17
+ end
22
18
 
23
- def models_with(wanted_action)
24
- @linkable_keys.map do |k|
25
- subsite, class_name, action, method = k.split('/')
26
- (action == wanted_action) ? class_name.constantize : nil
27
- end.compact
28
- end
19
+ def linkable?(klass, action, options={})
20
+ @linkable_keys.member? linkable_key(klass, action, options)
21
+ end
29
22
 
23
+ def models_with(wanted_action)
24
+ @linkable_keys.map do |k|
25
+ subsite, class_name, action, method = k.split('/')
26
+ (action == wanted_action) ? class_name.constantize : nil
27
+ end.compact
30
28
  end
29
+
31
30
  end
32
31
  end
data/lib/hobo.rb CHANGED
@@ -5,13 +5,13 @@ require 'will_paginate'
5
5
  require 'hobo/extensions/enumerable'
6
6
  require 'hobo/extensions/array'
7
7
 
8
- ActiveSupport::Dependencies.autoload_paths |= [ File.dirname(__FILE__)]
8
+ ActiveSupport::Dependencies.autoload_paths |= [File.dirname(__FILE__)]
9
9
 
10
10
 
11
11
  module Hobo
12
12
 
13
13
  VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
14
- @@root = Pathname.new File.expand_path(File.dirname(__FILE__) + "/..")
14
+ @@root = Pathname.new File.expand_path('../..', __FILE__)
15
15
  def self.root; @@root; end
16
16
 
17
17
  class Error < RuntimeError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175963
4
+ hash: -1637175966
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre14
11
- version: 1.3.0.pre14
10
+ - pre15
11
+ version: 1.3.0.pre15
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-27 00:00:00 -04:00
19
+ date: 2010-11-03 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,13 +59,13 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: -1637175963
62
+ hash: -1637175966
63
63
  segments:
64
64
  - 1
65
65
  - 3
66
66
  - 0
67
- - pre14
68
- version: 1.3.0.pre14
67
+ - pre15
68
+ version: 1.3.0.pre15
69
69
  type: :runtime
70
70
  version_requirements: *id003
71
71
  - !ruby/object:Gem::Dependency
@@ -76,13 +76,13 @@ dependencies:
76
76
  requirements:
77
77
  - - "="
78
78
  - !ruby/object:Gem::Version
79
- hash: -1637175963
79
+ hash: -1637175966
80
80
  segments:
81
81
  - 1
82
82
  - 3
83
83
  - 0
84
- - pre14
85
- version: 1.3.0.pre14
84
+ - pre15
85
+ version: 1.3.0.pre15
86
86
  type: :runtime
87
87
  version_requirements: *id004
88
88
  - !ruby/object:Gem::Dependency
@@ -93,13 +93,13 @@ dependencies:
93
93
  requirements:
94
94
  - - "="
95
95
  - !ruby/object:Gem::Version
96
- hash: -1637175963
96
+ hash: -1637175966
97
97
  segments:
98
98
  - 1
99
99
  - 3
100
100
  - 0
101
- - pre14
102
- version: 1.3.0.pre14
101
+ - pre15
102
+ version: 1.3.0.pre15
103
103
  type: :runtime
104
104
  version_requirements: *id005
105
105
  - !ruby/object:Gem::Dependency