sandro-homeward 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,2 +1,13 @@
1
+ == 0.1.1 / 2009-01-12
2
+ * 2 major enhancements
3
+ - Providing a mechanism for creating application specific settings via config/settings.yml. Access your settings via the APP_CONFIG constant
4
+ - The homeward generator creates all homeward files, including the application_layout; the homeward_layout generator has been removed
5
+
6
+ * 3 minor enhancements
7
+ - View and Controller helpers now mixed-in to ActionView::Base and ActionController::Base [thanks tpope]
8
+ - Added config/initializers/constants.rb to the generator
9
+ - Added config/settings.yml and config/settings.yml.example to the generator
10
+ - Note: you should add config/settings.yml to your .gitignore
11
+
1
12
  == 0.1.0 / 2009-01-04
2
13
  * Birthday!
data/Manifest.txt CHANGED
@@ -1,19 +1,17 @@
1
1
  History.txt
2
2
  Manifest.txt
3
3
  README.markdown
4
- README.txt
5
4
  Rakefile
6
5
  generators/homeward/USAGE
7
6
  generators/homeward/homeward_generator.rb
7
+ generators/homeward/templates/application.html.haml
8
+ generators/homeward/templates/constants.rb
8
9
  generators/homeward/templates/homeward.rake
9
- generators/homeward_layout/USAGE
10
- generators/homeward_layout/homeward_layout_generator.rb
11
- generators/homeward_layout/templates/application.html.haml
10
+ generators/homeward/templates/settings.yml
12
11
  init.rb
13
12
  lib/homeward.rb
14
- lib/homeward/controllers/application.rb
15
- lib/homeward/helpers/application_helper.rb
13
+ lib/homeward/controller_helpers.rb
14
+ lib/homeward/view_helpers.rb
16
15
  rails/init.rb
17
16
  spec/homeward_spec.rb
18
17
  spec/spec_helper.rb
19
- tasks/homeward.rake
data/README.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  Homeward
2
2
  ==========
3
- by Sandro Turriate
3
+ by Sandro Turriate
4
4
  http://github.com/sandro/homeward
5
5
 
6
6
  DESCRIPTION:
@@ -10,52 +10,43 @@ Rakefile and generators to help create my baseapp
10
10
  FEATURES:
11
11
  --------
12
12
  Installs Blueprint css
13
- Replaces Prototype with jQuery
14
- Creates an application layout which includes Blueprint and jQuery
15
- Includes a `render_flashes` application\_helper method which will render a flash message when available
16
- Includes a `current_page` helper to be used with will\_paginate
13
+ Replaces prototype with jrails
14
+ Creates an application layout which includes Blueprint and jrails
15
+ Creates config/settings.yml for application specific settings
16
+ Creates config/initializers/constants.rb with an APP\_CONFIG constant which consists of the settings defined in config/settings.yml
17
+ Defines `render_flashes` which will render a flash message when available, utilized by the layout
18
+ Defines `current_page` helper to be used with will\_paginate
17
19
 
18
20
  rake homeward
19
- Run all significant tasks
20
- Create application layout
21
- Update Blueprint
22
- Install Blueprint
23
- Replace prototype with jrails
24
-
25
- rake homeward:application_layout
26
- Invokes the homeward_layout generator
27
-
21
+ Update and install Blueprint, replace prototype with jrails
22
+
28
23
  rake homeward:blueprint:install
29
24
  installs blueprint
30
-
25
+
31
26
  rake homeward:blueprint:update
32
27
  pulls the latest blueprint code
33
-
28
+
34
29
  rake homeward:javascript:install_jrails
35
30
  installs jrails
36
-
31
+
37
32
  rake homeward:javascript:remove_prototype
38
33
  removes prototype
39
-
34
+
40
35
  rake homeward:javascript:use_jrails
41
36
  replaces prototype with jrails
42
37
 
43
- TODO/FIXES:
44
- --------
45
- Don't re-open classes to define methods, they need to be overwritable.
46
-
47
- SYNOPSIS:
48
- --------
49
- script/generate homeward
50
- rake homeward
51
-
52
38
  REQUIREMENTS:
53
39
  --------
54
40
  * Rails
41
+ * Haml
42
+ * blueprint-css cloned somewhere on your filesystem (see lib/tasks/homeward.rake)
55
43
 
56
44
  INSTALL:
57
45
  --------
58
- sudo gem install --source http://gems.github.com sandro-homeward
46
+ 1. `config.gem 'sandro-homeward', :lib => 'homeward', :source => 'http://gems.github.com'`
47
+ 2. Edit the `BLUEPRINT_GIT_PATH` constant in lib/tasks/homeward.rake
48
+ 3. `script/generate homeward`
49
+ 4. `rake homeward`
59
50
 
60
51
  LICENSE:
61
52
  --------
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ task :default => 'spec:run'
20
20
 
21
21
  namespace :gem do
22
22
  task :redo do
23
- puts %x(rm -rf pkg/homeward-1.0.0 && rake manifest:create && rake gem:reinstall)
23
+ puts %x(rm -rf pkg/homeward-1.0.0 && rake manifest:create && rake gem:reinstall && rake gem:spec)
24
24
  end
25
25
  end
26
26
 
@@ -32,9 +32,9 @@ PROJ.email = 'sandro.turriate@gmail.com'
32
32
  PROJ.url = 'http://github.com/sandro/homeward'
33
33
  PROJ.version = Homeward::VERSION
34
34
  PROJ.rubyforge.name = 'homeward'
35
+ PROJ.readme_file = 'README.markdown'
35
36
 
36
37
  PROJ.spec.opts << '--color'
37
38
 
38
39
  PROJ.exclude << %w(.*.gemspec \.gitignore)
39
40
 
40
- # EOF
@@ -1,2 +1,5 @@
1
1
  Description:
2
2
  Adds the homeward rake task to lib/tasks/homeward.rake
3
+ Copies the homeward application layout to app/views/layouts/application.html.haml
4
+ Creates application wide settings adding settings.yml to config/
5
+
@@ -1,12 +1,26 @@
1
1
  class HomewardGenerator < Rails::Generator::Base
2
+ attr_accessor :project_name
3
+
2
4
  def initialize(runtime_args, runtime_options = {})
3
- Dir.mkdir('lib/tasks') unless File.directory?('lib/tasks')
4
5
  super
6
+ @project_name = File.basename(Rails.root).humanize
5
7
  end
6
8
 
7
9
  def manifest
8
10
  record do |m|
9
- m.file 'homeward.rake', 'lib/tasks/homeward.rake', :collision => :ask
11
+ m.directory 'lib/tasks'
12
+ m.directory 'config/initializers'
13
+ m.directory 'app/views/layouts'
14
+
15
+ m.with_options :collision => :ask do |mc|
16
+ mc.file 'homeward.rake', 'lib/tasks/homeward.rake'
17
+
18
+ mc.template 'application.html.haml', 'app/views/layouts/application.html.haml'
19
+ mc.template 'constants.rb', 'config/initializers/constants.rb'
20
+ mc.template 'settings.yml', 'config/settings.yml'
21
+ mc.template 'settings.yml', 'config/settings.yml.example'
22
+ end
10
23
  end
11
24
  end
12
25
  end
26
+
@@ -0,0 +1,6 @@
1
+ DO_NOT_REPLY = "donotreply@example.com"
2
+ PROJECT_NAME = "<%= project_name %>"
3
+ HOST = "localhost"
4
+
5
+ APP_CONFIG = Homeward.load_app_config
6
+
@@ -1 +1,51 @@
1
- /Users/santuri/Code/Ruby/homeward/tasks/homeward.rake
1
+ require 'fileutils'
2
+
3
+ BLUEPRINT_GIT_PATH = "#{ENV['HOME']}/Code/Css/blueprint-css"
4
+
5
+ desc %q(Update and install Blueprint, replace prototype with jrails)
6
+ task :homeward => %w(homeward:blueprint:update homeward:blueprint:install homeward:javascript:use_jrails)
7
+
8
+ namespace :homeward do
9
+ namespace :blueprint do
10
+ desc 'pulls the latest blueprint code'
11
+ task :update do
12
+ Dir.chdir BLUEPRINT_GIT_PATH do
13
+ puts %x(echo "Stashing\n" &&
14
+ git stash &&
15
+ echo "\nPulling\n" &&
16
+ git pull &&
17
+ echo "\nPopping\n" &&
18
+ git stash pop
19
+ )
20
+ end
21
+ end
22
+
23
+ desc "installs blueprint"
24
+ task :install do
25
+ compressor = "#{BLUEPRINT_GIT_PATH}/lib/compress.rb"
26
+ install_path = "#{Rails.root}/public/stylesheets/blueprint"
27
+ %x(ruby #{compressor} -o #{install_path})
28
+ FileUtils.rm_rf "#{install_path}/src"
29
+ end
30
+ end
31
+
32
+ namespace :javascript do
33
+ desc 'replaces prototype with jrails'
34
+ task :use_jrails => [:remove_prototype, :install_jrails]
35
+
36
+ desc 'removes prototype'
37
+ task :remove_prototype do
38
+ Dir.chdir("#{Rails.root}/public/javascripts") do
39
+ FileUtils.rm_rf %w(prototype.js effects.js dragdrop.js controls.js)
40
+ end
41
+ end
42
+
43
+ desc 'installs jrails'
44
+ task :install_jrails do
45
+ Dir.chdir(Rails.root) do
46
+ puts %x(script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails)
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -0,0 +1,14 @@
1
+ base_settings: &base_settings
2
+ :todo: development
3
+
4
+ development:
5
+ <<: *base_settings
6
+
7
+ test:
8
+ <<: *base_settings
9
+ :todo: test
10
+
11
+ production:
12
+ <<: *base_settings
13
+ :todo: production
14
+
@@ -0,0 +1,10 @@
1
+ module Homeward
2
+ module ControllerHelpers
3
+ protected
4
+
5
+ def current_page
6
+ params[:page].to_i < 1 ? 1 : params[:page].to_i
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,20 @@
1
+ module Homeward
2
+ module ViewHelpers
3
+ def blueprint_includes
4
+ %q(
5
+ <link rel="stylesheet" href="/stylesheets/blueprint/screen.css" type="text/css" media="screen, projection">
6
+ <link rel="stylesheet" href="/stylesheets/blueprint/print.css" type="text/css" media="print">
7
+ <!--[if IE]>
8
+ <link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection">
9
+ <![endif]-->
10
+ )
11
+ end
12
+
13
+ def render_flashes
14
+ flash.map do |type, value|
15
+ content_tag('div', value, :id => "flash_#{type}")
16
+ end.join("\n")
17
+ end
18
+ end
19
+ end
20
+
data/lib/homeward.rb CHANGED
@@ -1,5 +1,7 @@
1
+ require 'yaml'
2
+
1
3
  module Homeward
2
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
3
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
4
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
5
7
 
@@ -22,7 +24,30 @@ module Homeward
22
24
 
23
25
  Dir.glob(search_me).sort.each {|rb| require rb}
24
26
  end
27
+
28
+ def self.define_method_unless_defined(klass, method_name, &block)
29
+ unless klass.method_defined?(method_name)
30
+ klass.send(:define_method, method_name, block)
31
+ end
32
+ end
33
+
34
+ def self.load_app_config
35
+ returning HashWithIndifferentAccess.new do |app_config|
36
+ config_file_path = File.join(RAILS_ROOT, %w(config settings.yml))
37
+ if File.exist?(config_file_path)
38
+ config = YAML.load_file(config_file_path)
39
+ app_config.merge!(config[Rails.env]) if config.has_key?(Rails.env)
40
+ else
41
+ puts "WARNING: configuration file #{config_file_path} not found."
42
+ end
43
+ end
44
+ end
25
45
  end
26
46
 
27
47
  Homeward.require_all_libs_relative_to(__FILE__)
28
48
 
49
+ if Object.const_defined?(:Rails)
50
+ ActionView::Base.send(:include, Homeward::ViewHelpers)
51
+ ActionController::Base.send(:include, Homeward::ControllerHelpers)
52
+ end
53
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandro-homeward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Turriate
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-04 00:00:00 -08:00
12
+ date: 2009-01-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -29,33 +29,30 @@ extensions: []
29
29
 
30
30
  extra_rdoc_files:
31
31
  - History.txt
32
- - README.txt
33
32
  files:
34
33
  - History.txt
35
34
  - Manifest.txt
36
35
  - README.markdown
37
- - README.txt
38
36
  - Rakefile
39
37
  - generators/homeward/USAGE
40
38
  - generators/homeward/homeward_generator.rb
39
+ - generators/homeward/templates/application.html.haml
40
+ - generators/homeward/templates/constants.rb
41
41
  - generators/homeward/templates/homeward.rake
42
- - generators/homeward_layout/USAGE
43
- - generators/homeward_layout/homeward_layout_generator.rb
44
- - generators/homeward_layout/templates/application.html.haml
42
+ - generators/homeward/templates/settings.yml
45
43
  - init.rb
46
44
  - lib/homeward.rb
47
- - lib/homeward/controllers/application.rb
48
- - lib/homeward/helpers/application_helper.rb
45
+ - lib/homeward/controller_helpers.rb
46
+ - lib/homeward/view_helpers.rb
49
47
  - rails/init.rb
50
48
  - spec/homeward_spec.rb
51
49
  - spec/spec_helper.rb
52
- - tasks/homeward.rake
53
50
  has_rdoc: true
54
51
  homepage: http://github.com/sandro/homeward
55
52
  post_install_message:
56
53
  rdoc_options:
57
54
  - --main
58
- - README.txt
55
+ - README.markdown
59
56
  require_paths:
60
57
  - lib
61
58
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.txt DELETED
File without changes
@@ -1,2 +0,0 @@
1
- Description:
2
- Copies the homeward layout to app/views/layouts/application.html.haml
@@ -1,16 +0,0 @@
1
- class HomewardLayoutGenerator < Rails::Generator::Base
2
- attr_accessor :project_name
3
-
4
- def initialize(runtime_args, runtime_options = {})
5
- super
6
- @project_name = File.basename(Rails.root).humanize
7
- end
8
-
9
- def manifest
10
- record do |m|
11
- m.template 'application.html.haml', 'app/views/layouts/application.html.haml', :collision => :ask
12
- end
13
- end
14
-
15
-
16
- end
@@ -1,7 +0,0 @@
1
- class ApplicationController
2
- private
3
-
4
- def current_page
5
- params[:page].to_i < 1 ? 1 : params[:page].to_i
6
- end
7
- end
@@ -1,17 +0,0 @@
1
- module ApplicationHelper
2
- def blueprint_includes
3
- %q(
4
- <link rel="stylesheet" href="/stylesheets/blueprint/screen.css" type="text/css" media="screen, projection">
5
- <link rel="stylesheet" href="/stylesheets/blueprint/print.css" type="text/css" media="print">
6
- <!--[if IE]>
7
- <link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection">
8
- <![endif]-->
9
- )
10
- end
11
-
12
- def render_flashes
13
- flash.map do |type, value|
14
- content_tag('div', value, :id => "flash_#{type}")
15
- end.join("\n")
16
- end
17
- end
data/tasks/homeward.rake DELETED
@@ -1,63 +0,0 @@
1
- require 'fileutils'
2
-
3
- BLUEPRINT_GIT_PATH = "#{ENV['HOME']}/Code/Css/blueprint-css"
4
-
5
- desc %q(Run all significant tasks
6
- Create application layout
7
- Update Blueprint
8
- Install Blueprint
9
- Replace prototype with jrails
10
- )
11
- task :homeward => %w(homeward:application_layout homeward:blueprint:update homeward:blueprint:install homeward:javascript:use_jrails)
12
-
13
- namespace :homeward do
14
- desc 'Invokes the homeward_layout generator'
15
- task :application_layout do
16
- Dir.chdir(Rails.root) do
17
- puts %x(script/generate homeward_layout)
18
- end
19
- end
20
-
21
- namespace :blueprint do
22
- desc 'pulls the latest blueprint code'
23
- task :update do
24
- Dir.chdir BLUEPRINT_GIT_PATH do
25
- puts %x(echo "Stashing\n" &&
26
- git stash &&
27
- echo "\nPulling\n" &&
28
- git pull &&
29
- echo "\nPopping\n" &&
30
- git stash pop
31
- )
32
- end
33
- end
34
-
35
- desc "installs blueprint"
36
- task :install do
37
- compressor = "#{BLUEPRINT_GIT_PATH}/lib/compress.rb"
38
- install_path = "#{Rails.root}/public/stylesheets/blueprint"
39
- %x(ruby #{compressor} -o #{install_path})
40
- FileUtils.rm_rf "#{install_path}/src"
41
- end
42
- end
43
-
44
- namespace :javascript do
45
- desc 'replaces prototype with jrails'
46
- task :use_jrails => [:remove_prototype, :install_jrails]
47
-
48
- desc 'removes prototype'
49
- task :remove_prototype do
50
- Dir.chdir("#{Rails.root}/public/javascripts") do
51
- FileUtils.rm_rf %w(prototype.js effects.js dragdrop.js controls.js)
52
- end
53
- end
54
-
55
- desc 'installs jrails'
56
- task :install_jrails do
57
- Dir.chdir(Rails.root) do
58
- puts %x(script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails)
59
- end
60
- end
61
- end
62
- end
63
-