sandro-homeward 0.1.2 → 0.2.0

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.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.2.0 / 2009-06-01
2
+ * 2 major enhancements
3
+ - Removed many methods in the Homeward namespace - Homeward is now simply a generator.
4
+ - Generated rake file loads its rake tasks from the gem
5
+
6
+ * 3 minor enhancements
7
+ - APP_CONFIG is now APP_SETTINGS
8
+ - Running the Blueprint rake tasks clones the repo into /tmp unless its already present
9
+ - Jrails is installed from github
10
+
1
11
  == 0.1.1 / 2009-01-12
2
12
  * 2 major enhancements
3
13
  - Providing a mechanism for creating application specific settings via config/settings.yml. Access your settings via the APP_CONFIG constant
data/README.rdoc CHANGED
@@ -16,7 +16,7 @@ Rakefile and generators to help create my baseapp
16
16
  * Defines render_flashes which will render a flash message when available, utilized by the layout
17
17
  * Defines current_page helper to be used with will\_paginate
18
18
 
19
- rake homeward
19
+ rake homeward:install
20
20
  Update and install Blueprint, replace prototype with jrails
21
21
 
22
22
  rake homeward:blueprint:install
@@ -42,10 +42,9 @@ Rakefile and generators to help create my baseapp
42
42
 
43
43
  == INSTALL:
44
44
 
45
- 1. config.gem 'sandro-homeward', :lib => 'homeward', :source => 'http://gems.github.com'
46
- 2. Edit the BLUEPRINT_GIT_PATH constant in lib/tasks/homeward.rake
47
- 3. script/generate homeward
48
- 4. rake homeward
45
+ 1. gem install sandro-homeward
46
+ 2. script/generate homeward
47
+ 3. rake homeward:install
49
48
 
50
49
  == LICENSE:
51
50
 
data/lib/homeward.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Homeward
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
 
@@ -17,37 +17,13 @@ module Homeward
17
17
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
18
18
  end
19
19
 
20
- def self.require_all_libs_relative_to( fname, dir = nil )
20
+ def self.require_all_libs_relative_to(fname, dir = nil)
21
21
  dir ||= ::File.basename(fname, '.*')
22
22
  search_me = ::File.expand_path(
23
23
  ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
24
24
 
25
25
  Dir.glob(search_me).sort.each {|rb| require rb}
26
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
45
27
  end
46
28
 
47
29
  Homeward.require_all_libs_relative_to(__FILE__)
48
-
49
- if Object.const_defined?(:Rails)
50
- ActionView::Base.send(:include, Homeward::ViewHelpers)
51
- ActionController::Base.send(:include, Homeward::ControllerHelpers)
52
- end
53
-
@@ -0,0 +1,54 @@
1
+ require 'fileutils'
2
+ require 'open3'
3
+
4
+ BLUEPRINT_CLONE_URL = "git://github.com/joshuaclayton/blueprint-css.git"
5
+ BLUEPRINT_PATH = "/tmp/blueprint-css"
6
+
7
+ namespace :homeward do
8
+ desc %q(Update and install Blueprint, replace prototype with jrails)
9
+ task :install => %w(homeward:blueprint:update homeward:blueprint:install homeward:javascript:use_jrails)
10
+
11
+ namespace :blueprint do
12
+ task :clone do
13
+ unless File.exists?(BLUEPRINT_PATH)
14
+ puts %x(git clone #{BLUEPRINT_CLONE_URL} #{BLUEPRINT_PATH})
15
+ end
16
+ end
17
+
18
+ desc 'pulls the latest blueprint code'
19
+ task :update => :clone do
20
+ Dir.chdir BLUEPRINT_PATH do
21
+ Open3.popen3("git stash && git pull && git pop") do |stdin, stdout, stderr|
22
+ puts stdout.readlines.last
23
+ end
24
+ end
25
+ end
26
+
27
+ desc "installs blueprint"
28
+ task :install => :clone do
29
+ compressor = "#{BLUEPRINT_PATH}/lib/compress.rb"
30
+ install_path = "#{Rails.root}/public/stylesheets/blueprint"
31
+ %x(ruby #{compressor} -o #{install_path})
32
+ FileUtils.rm_rf "#{install_path}/src"
33
+ end
34
+ end
35
+
36
+ namespace :javascript do
37
+ desc 'replaces prototype with jrails'
38
+ task :use_jrails => [:remove_prototype, :install_jrails]
39
+
40
+ desc 'removes prototype'
41
+ task :remove_prototype do
42
+ Dir.chdir("#{Rails.root}/public/javascripts") do
43
+ FileUtils.rm_rf %w(prototype.js effects.js dragdrop.js controls.js)
44
+ end
45
+ end
46
+
47
+ desc 'installs jrails'
48
+ task :install_jrails do
49
+ Dir.chdir(Rails.root) do
50
+ puts %x(script/plugin install git://github.com/aaronchi/jrails.git)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,4 @@
1
1
  Description:
2
2
  Adds the homeward rake task to lib/tasks/homeward.rake
3
3
  Copies the homeward application layout to app/views/layouts/application.html.haml
4
- Creates application wide settings adding settings.yml to config/
5
-
4
+ Creates application wide settings in config/settings.yml
@@ -10,13 +10,18 @@ class HomewardGenerator < Rails::Generator::Base
10
10
  record do |m|
11
11
  m.directory 'lib/tasks'
12
12
  m.directory 'config/initializers'
13
+ m.directory 'app/helpers'
13
14
  m.directory 'app/views/layouts'
14
15
 
15
16
  m.with_options :collision => :ask do |mc|
16
17
  mc.file 'homeward.rake', 'lib/tasks/homeward.rake'
17
18
 
18
19
  mc.template 'application.html.haml', 'app/views/layouts/application.html.haml'
19
- mc.template 'constants.rb', 'config/initializers/constants.rb'
20
+
21
+ mc.template 'application_settings.rb', 'config/initializers/application_settings.rb'
22
+ mc.template 'current_page_normalizer.rb', 'config/initializers/current_page_normalizer.rb'
23
+ mc.template 'homeward_helper.rb', 'app/helpers/homeward_helper.rb'
24
+
20
25
  mc.template 'settings.yml', 'config/settings.yml'
21
26
  mc.template 'settings.yml', 'config/settings.yml.example'
22
27
  end
@@ -3,7 +3,7 @@
3
3
  %head
4
4
  %meta{"http-equiv" => 'Content-Type', :content => 'text/html;charset=utf-8'}
5
5
  %title= h(@title || "<%= project_name %>")
6
- = blueprint_includes
6
+ = blueprint_stylesheets
7
7
  = stylesheet_link_tag 'application', :media => 'screen, projection'
8
8
  = javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.to_json};" if protect_against_forgery?
9
9
  = javascript_include_tag %w(jquery jquery-ui jrails)
@@ -0,0 +1,13 @@
1
+ def load_app_settings
2
+ returning HashWithIndifferentAccess.new do |app_settings|
3
+ config_file_path = File.join(RAILS_ROOT, %w(config settings.yml))
4
+ if File.exist?(config_file_path)
5
+ config = YAML.load_file(config_file_path)
6
+ app_settings.merge!(config[Rails.env]) if config[Rails.env]
7
+ else
8
+ puts "WARNING: configuration file #{config_file_path} not found."
9
+ end
10
+ end
11
+ end
12
+
13
+ APP_SETTINGS = load_app_settings
@@ -0,0 +1,7 @@
1
+ ActionController::Base.class_eval do
2
+ private
3
+
4
+ def current_page
5
+ params[:page].to_i < 1 ? 1 : params[:page].to_i
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ begin
2
+ load 'homeward/lib/tasks/homeward.rake'
3
+ rescue LoadError
4
+ puts "Could not find the homeward raketask, did you install the 'sandro-homeward' gem?"
5
+ end
@@ -0,0 +1,17 @@
1
+ module HomewardHelper
2
+ def blueprint_stylesheets
3
+ %(
4
+ #{stylesheet_link_tag 'blueprint/screen', :media => 'screen, projection'}
5
+ #{stylesheet_link_tag 'blueprint/print', :media => 'print'}
6
+ <!--[if IE]>
7
+ #{stylesheet_link_tag 'blueprint/ie', :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
@@ -0,0 +1,11 @@
1
+ globals: &globals
2
+ project_name: <%= project_name %>
3
+
4
+ development:
5
+ <<: *globals
6
+
7
+ test:
8
+ <<: *globals
9
+
10
+ production:
11
+ <<: *globals
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.2
4
+ version: 0.2.0
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-13 00:00:00 -08:00
12
+ date: 2009-06-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -21,23 +21,26 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - History.txt
24
+ - Manifest.txt
24
25
  - README.rdoc
26
+ - lib/tasks/homeward.rake
25
27
  files:
26
28
  - History.txt
27
29
  - Manifest.txt
28
30
  - README.rdoc
29
31
  - Rakefile
30
- - generators/homeward/USAGE
31
- - generators/homeward/homeward_generator.rb
32
- - generators/homeward/templates/application.html.haml
33
- - generators/homeward/templates/constants.rb
34
- - generators/homeward/templates/homeward.rake
35
- - generators/homeward/templates/settings.yml
36
32
  - init.rb
37
33
  - lib/homeward.rb
38
- - lib/homeward/controller_helpers.rb
39
- - lib/homeward/view_helpers.rb
34
+ - lib/tasks/homeward.rake
40
35
  - rails/init.rb
36
+ - rails_generators/homeward/USAGE
37
+ - rails_generators/homeward/homeward_generator.rb
38
+ - rails_generators/homeward/templates/application.html.haml
39
+ - rails_generators/homeward/templates/application_settings.rb
40
+ - rails_generators/homeward/templates/current_page_normalizer.rb
41
+ - rails_generators/homeward/templates/homeward.rake
42
+ - rails_generators/homeward/templates/homeward_helper.rb
43
+ - rails_generators/homeward/templates/settings.yml
41
44
  - spec/homeward_spec.rb
42
45
  - spec/spec_helper.rb
43
46
  has_rdoc: true
@@ -1,6 +0,0 @@
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,51 +0,0 @@
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
-
@@ -1,14 +0,0 @@
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
-
@@ -1,10 +0,0 @@
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
-
@@ -1,20 +0,0 @@
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
-