padrino-gen 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.6
@@ -83,8 +83,8 @@ module Padrino
83
83
  end
84
84
 
85
85
  # Returns the app_name for the application at root
86
- def fetch_app_name(root=nil)
87
- app_path = root ? File.join(root, 'app/app.rb') : 'app/app.rb'
86
+ def fetch_app_name(app='app')
87
+ app_path = destination_root(app, 'app.rb')
88
88
  @app_name ||= File.read(app_path).scan(/class\s(.*?)\s</).flatten[0]
89
89
  end
90
90
 
@@ -1,5 +1,6 @@
1
1
  class <%= @class_name %> < Padrino::Application
2
2
  configure do
3
+ register MailerInitializer if defined?(MailerInitializer) # Remove this if your not using mailer
3
4
  ##
4
5
  # Application-specific configuration options
5
6
  #
@@ -31,7 +31,7 @@ module Padrino
31
31
  if in_app_root?
32
32
  app = options[:app].underscore
33
33
  check_app_existence(app)
34
- @app_name = fetch_app_name(options[:root])
34
+ @app_name = fetch_app_name(app)
35
35
  @actions = controller_actions(fields)
36
36
  @controller = name
37
37
  self.behavior = :revoke if options[:destroy]
@@ -3,6 +3,7 @@ class <%= @class_name %> < Padrino::Application
3
3
  ##
4
4
  # Application-specific configuration options
5
5
  #
6
+ register MailerInitializer if defined?(MailerInitializer) # Remove this if your not using mailer
6
7
  # set :raise_errors, true # Show exceptions (default for development)
7
8
  # set :public, "foo/bar" # Location for static assets (default root/public)
8
9
  # set :sessions, false # Enabled by default
@@ -7,7 +7,7 @@ Mailer methods can be defined using the simple format:
7
7
  to user_email_address
8
8
  subject 'Welcome to the site!'
9
9
  body :name => name
10
- type 'html' # optional, defaults to plain/text
10
+ content_type 'text/html' # optional, defaults to plain/text
11
11
  charset 'windows-1252' # optional, defaults to utf-8
12
12
  via :sendmail # optional, to smtp if defined otherwise sendmail
13
13
  end
@@ -0,0 +1,43 @@
1
+ if defined?(MongoMapper)
2
+ namespace :mm do
3
+ desc "Generates .yml files for I18n translations."
4
+ task :translate => :environment do
5
+ models = Dir["#{Padrino.root}/app/models/**/*.rb"].collect { |m| File.basename(m, ".rb") }
6
+
7
+ models.each do |m|
8
+ # Get the model class
9
+ klass = m.camelize.constantize
10
+
11
+ # Init the processing
12
+ print "Processing #{m.humanize}: "
13
+ FileUtils.mkdir_p("#{Padrino.root}/app/locale/models/#{m}")
14
+ langs = Array(I18n.locale) # for now we use only one
15
+
16
+ # Create models for it and en locales
17
+ langs.each do |lang|
18
+ filename = "#{Padrino.root}/app/locale/models/#{m}/#{lang}.yml"
19
+ columns = klass.keys.values.collect(&:name).reject { |name| name =~ /id/i }
20
+ # If the lang file already exist we need to check it
21
+ if File.exist?(filename)
22
+ locale = File.open(filename).read
23
+ columns.each do |c|
24
+ locale += "\n #{c}: #{c.humanize}" unless locale.include?("#{c}:")
25
+ end
26
+ print "Lang #{lang.to_s.upcase} already exist ... "; $stdout.flush
27
+ # Do some ere
28
+ else
29
+ locale = "#{lang}:" + "\n" +
30
+ " models:" + "\n" +
31
+ " #{m}:" + "\n" +
32
+ " name: #{klass.human_name}" + "\n" +
33
+ " attributes:" + "\n" +
34
+ columns.collect { |c| " #{c}: #{c.humanize}" }.join("\n")
35
+ print "created a new for #{lang.to_s.upcase} Lang ... "; $stdout.flush
36
+ end
37
+ File.open(filename, "w") { |f| f.puts locale }
38
+ end
39
+ puts
40
+ end
41
+ end
42
+ end
43
+ end
data/padrino-gen.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-gen}
8
- s.version = "0.9.5"
8
+ s.version = "0.9.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-03-11}
12
+ s.date = %q{2010-03-15}
13
13
  s.default_executable = %q{padrino-gen}
14
14
  s.description = %q{Generators for easily creating and building padrino applications from the console}
15
15
  s.email = %q{padrinorb@gmail.com}
@@ -86,6 +86,7 @@ Gem::Specification.new do |s|
86
86
  "lib/padrino-gen/generators/templates/scripts/right.js",
87
87
  "lib/padrino-gen/padrino-tasks/activerecord.rb",
88
88
  "lib/padrino-gen/padrino-tasks/datamapper.rb",
89
+ "lib/padrino-gen/padrino-tasks/mongomapper.rb",
89
90
  "lib/padrino-gen/padrino-tasks/seed.rb",
90
91
  "padrino-gen.gemspec",
91
92
  "test/helper.rb",
@@ -110,7 +111,7 @@ Gem::Specification.new do |s|
110
111
  s.specification_version = 3
111
112
 
112
113
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
113
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.5"])
114
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.6"])
114
115
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
115
116
  s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
116
117
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
@@ -118,7 +119,7 @@ Gem::Specification.new do |s|
118
119
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
119
120
  s.add_development_dependency(%q<fakeweb>, [">= 1.2.3"])
120
121
  else
121
- s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
122
+ s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
122
123
  s.add_dependency(%q<haml>, [">= 2.2.1"])
123
124
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
124
125
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -127,7 +128,7 @@ Gem::Specification.new do |s|
127
128
  s.add_dependency(%q<fakeweb>, [">= 1.2.3"])
128
129
  end
129
130
  else
130
- s.add_dependency(%q<padrino-core>, ["= 0.9.5"])
131
+ s.add_dependency(%q<padrino-core>, ["= 0.9.6"])
131
132
  s.add_dependency(%q<haml>, [">= 2.2.1"])
132
133
  s.add_dependency(%q<shoulda>, [">= 2.10.3"])
133
134
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -36,8 +36,8 @@ class TestAppGenerator < Test::Unit::TestCase
36
36
  silence_logger { @project.start(['sample_project', '--root=/tmp']) }
37
37
  silence_logger { @app.start(['demo', '--root=/tmp/sample_project']) }
38
38
  silence_logger { @cont_gen.start(['demo_items', '-r=/tmp/sample_project', '-a=demo']) }
39
- assert_match_in_file(/SampleProject.controllers :demo_items do/m, '/tmp/sample_project/demo/controllers/demo_items.rb')
40
- assert_match_in_file(/SampleProject.helpers do/m, '/tmp/sample_project/demo/helpers/demo_items_helper.rb')
39
+ assert_match_in_file(/Demo.controllers :demo_items do/m, '/tmp/sample_project/demo/controllers/demo_items.rb')
40
+ assert_match_in_file(/Demo.helpers do/m, '/tmp/sample_project/demo/helpers/demo_items_helper.rb')
41
41
  assert_file_exists('/tmp/sample_project/demo/views/demo_items')
42
42
  end
43
43
 
@@ -47,6 +47,7 @@ class TestAppGenerator < Test::Unit::TestCase
47
47
  silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project', '-a=demo']) }
48
48
  assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/demo/mailers/demo_mailer.rb')
49
49
  assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/lib/mailer.rb')
50
+ assert_match_in_file(/register MailerInitializer/,'/tmp/sample_project/app/app.rb')
50
51
  assert_file_exists('/tmp/sample_project/demo/views/demo_mailer')
51
52
  end
52
53
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 5
9
- version: 0.9.5
8
+ - 6
9
+ version: 0.9.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Padrino Team
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-11 00:00:00 +01:00
20
+ date: 2010-03-15 00:00:00 -07:00
21
21
  default_executable: padrino-gen
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -30,8 +30,8 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  - 9
33
- - 5
34
- version: 0.9.5
33
+ - 6
34
+ version: 0.9.6
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -195,6 +195,7 @@ files:
195
195
  - lib/padrino-gen/generators/templates/scripts/right.js
196
196
  - lib/padrino-gen/padrino-tasks/activerecord.rb
197
197
  - lib/padrino-gen/padrino-tasks/datamapper.rb
198
+ - lib/padrino-gen/padrino-tasks/mongomapper.rb
198
199
  - lib/padrino-gen/padrino-tasks/seed.rb
199
200
  - padrino-gen.gemspec
200
201
  - test/helper.rb