sinatra-mapping 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,13 @@
1
1
  = Changes
2
2
 
3
+ [0.2.1 - July 2009]
4
+ * The helper method for show title path has been fixed.
5
+
6
+ * Added new task for show the current version.
7
+
8
+ [0.2.0 - July 2009]
9
+ * New method for mapping of paths has been added.
10
+
3
11
  [0.1.1 - July 2009]
4
12
  * New helper methods have been added.
5
13
 
data/Rakefile CHANGED
@@ -4,21 +4,24 @@ require 'rake/gempackagetask'
4
4
  require 'rake/rdoctask'
5
5
  load 'sinatra-mapping.gemspec'
6
6
 
7
+ def current_version(file = "VERSION")
8
+ @current_value ||= YAML.load_file(file) || {}
9
+ end
10
+
7
11
  desc "Generate version for release and tagging."
8
12
  task :version, [:major, :minor, :patch, :release, :date, :cycle] do |taskspec, version|
9
13
  require 'parsedate'
10
- current = YAML.load_file(taskspec.name.upcase) || {}
11
- version_date = Date.new(*ParseDate.parsedate(version[:date] || current[:date].to_s).compact) unless version or current
14
+ version_date = Date.new(*ParseDate.parsedate(version[:date] || current_version[:date].to_s).compact) unless version or current_version
12
15
  newer = {
13
- :major => version[:major].to_i || current[:major].to_i,
14
- :minor => version[:minor].to_i || current[:minor].to_i,
15
- :patch => version[:patch].to_i || current[:patch].to_i,
16
+ :major => version[:major].to_i || current_version[:major].to_i,
17
+ :minor => version[:minor].to_i || current_version[:minor].to_i,
18
+ :patch => version[:patch].to_i || current_version[:patch].to_i,
16
19
  :release => version[:release].to_s.empty? ? nil : version[:release].to_i,
17
20
  :date => version_date || Date.today,
18
- :cycle => version[:cycle] || current[:cycle]
21
+ :cycle => version[:cycle] || current_version[:cycle]
19
22
  }
20
23
 
21
- newer.merge(current) do |key, new_value, current_value|
24
+ newer.merge(current_version) do |key, new_value, current_value|
22
25
  new_value || current_value
23
26
  end
24
27
 
@@ -27,6 +30,16 @@ task :version, [:major, :minor, :patch, :release, :date, :cycle] do |taskspec, v
27
30
  end
28
31
  end
29
32
 
33
+ namespace :version do
34
+ desc "Show the current version."
35
+ task :show do
36
+ version = [:major, :minor, :patch, :release].map do |info|
37
+ current_version[info]
38
+ end.compact.join('.')
39
+ puts "#{@spec.name} v#{version} released at #{current_version[:date]} (#{current_version[:cycle]})"
40
+ end
41
+ end
42
+
30
43
  Rake::TestTask.new
31
44
 
32
45
  Rake::GemPackageTask.new(@spec) do |pkg|
data/VERSION CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  :release:
3
- :date: 2009-07-18
3
+ :date: 2009-07-20
4
4
  :cycle: Alpha release
5
5
  :major: 0
6
6
  :minor: 2
7
- :patch: 0
7
+ :patch: 1
@@ -9,6 +9,9 @@ module Sinatra
9
9
  # methods.
10
10
  module Mapping
11
11
 
12
+ # All location paths mapped.
13
+ attr_reader :locations
14
+
12
15
  # Write URL path method for use in HTTP methods.
13
16
  #
14
17
  # The map method most be used by following syntax:
@@ -78,6 +81,7 @@ module Sinatra
78
81
 
79
82
  # Returns all paths mapped by root path in prefix.
80
83
  def path_mapped(*args)
84
+ puts "ARGS: #{args.inspect}"
81
85
  !args.empty? ? cleanup_paths("/#{@root_path}/#{args.join('/')}") : @root_root
82
86
  end
83
87
 
@@ -11,9 +11,9 @@ module Sinatra
11
11
  # Creates a title using a path mapped. Otherwise, returns just arguments
12
12
  # joined by spaces and capitalised.
13
13
  def title_path(path, *args)
14
- title = (options.send("#{path}_path") || path).to_s.gsub('/',' ').strip
14
+ title = (options.locations[path] || path).to_s.gsub('/',' ').strip
15
15
  title.gsub!(/\W/,' ') # Cleanup
16
- (args.empty? ? title : "#{title} #{args.join(' ')}").capitalize
16
+ (args.empty? ? title : "#{title} #{args.join(' ')}").strip.capitalize
17
17
  end
18
18
 
19
19
  # Returns all paths with query parameters. Example:
data/test/test_mapping.rb CHANGED
@@ -23,11 +23,11 @@ class AppForTest < Sinatra::Base
23
23
  end
24
24
 
25
25
  get root_path do
26
- "#{title_path :root}:#{path_to :root}"
26
+ "#{title_path :root, :path}:#{path_to :root}"
27
27
  end
28
28
 
29
29
  get posts_path do
30
- "#{title_path :posts}:#{path_to :posts}"
30
+ "#{title_path :posts, :published}:#{path_to :posts}"
31
31
  end
32
32
 
33
33
  get posts_path "/" do
@@ -98,7 +98,7 @@ class TestMapping < Test::Unit::TestCase
98
98
  get "#{@locations[:root_path]}" do |response|
99
99
  assert response.ok?
100
100
  assert_equal "http://example.org#{@locations[:root_path]}", last_request.url
101
- assert_equal ":#{@locations[:root_path]}", response.body
101
+ assert_equal "Path:#{@locations[:root_path]}", response.body
102
102
  end
103
103
  end
104
104
 
@@ -106,7 +106,7 @@ class TestMapping < Test::Unit::TestCase
106
106
  get "#{@locations[:posts_path]}" do |response|
107
107
  assert response.ok?
108
108
  assert_equal "http://example.org#{@locations[:posts_path]}", last_request.url
109
- assert_equal "Articles:#{@locations[:posts_path]}", response.body
109
+ assert_equal "Articles published:#{@locations[:posts_path]}", response.body
110
110
  end
111
111
 
112
112
  get "#{@locations[:posts_path]}/" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-mapping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hallison Batista
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-18 00:00:00 -04:00
12
+ date: 2009-07-20 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency