sinatra-mapping 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,10 @@
1
1
  = Changes
2
2
 
3
+ [1.0.0 - July 2009]
4
+ * Added new helper method for creates links.
5
+
6
+ * All features for first release have been finished.
7
+
3
8
  [0.2.1 - July 2009]
4
9
  * The helper method for show title path has been fixed.
5
10
 
@@ -32,8 +32,11 @@ Example:
32
32
 
33
33
  map :root, "blog" # => /blog/
34
34
  map :posts, "articles" # => /blog/articles
35
- map :tags, "labels" # => /blog/labels
36
- map :archive, "archived-articles" # => /blog/archived-articles
35
+
36
+ mapping do
37
+ :tags => "labels" # => /blog/labels
38
+ :archive => "archived-articles" # => /blog/archived-articles
39
+ end
37
40
 
38
41
  get root_path do
39
42
  # /blog/
data/Rakefile CHANGED
@@ -48,13 +48,13 @@ end
48
48
 
49
49
  Rake::RDocTask.new("doc") do |rdoc|
50
50
  rdoc.title = "Sinatra::Mapping"
51
- rdoc.main = "README"
51
+ rdoc.main = "README.rdoc"
52
52
  rdoc.options = [ '-SHN', '-f', 'darkfish' ]
53
53
  rdoc.rdoc_dir = 'doc'
54
54
  rdoc.rdoc_files.include(
55
55
  "CHANGES",
56
56
  "LICENSE",
57
- "README",
57
+ "README.rdoc",
58
58
  "lib/**/*.rb"
59
59
  )
60
60
  end
data/VERSION CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  :release:
3
- :date: 2009-07-20
4
- :cycle: Alpha release
5
- :major: 0
6
- :minor: 2
7
- :patch: 1
3
+ :date: 2009-07-21
4
+ :cycle: Release
5
+ :major: 1
6
+ :minor: 0
7
+ :patch: 0
@@ -81,7 +81,6 @@ module Sinatra
81
81
 
82
82
  # Returns all paths mapped by root path in prefix.
83
83
  def path_mapped(*args)
84
- puts "ARGS: #{args.inspect}"
85
84
  !args.empty? ? cleanup_paths("/#{@root_path}/#{args.join('/')}") : @root_root
86
85
  end
87
86
 
@@ -16,6 +16,25 @@ module Sinatra
16
16
  (args.empty? ? title : "#{title} #{args.join(' ')}").strip.capitalize
17
17
  end
18
18
 
19
+ # Creates anchor links for name and extract path and HTML options from
20
+ # arguments. Example:
21
+ #
22
+ # # In Web application, add a map.
23
+ # map :status, "tasks/status"
24
+ #
25
+ # get status_path do
26
+ # status = "finished"
27
+ # erb :status, :locals => { :status => status }
28
+ # end
29
+ #
30
+ # # In status view, add a link to status map.
31
+ # <%= link_to "All finished", :status, status %>
32
+ # # => <a href="/tasks/status/finished">All finished</a>
33
+ def link_to(name = nil, *args)
34
+ options = args.last.kind_of?(Hash) ? args.pop : {}
35
+ "<a href=\"#{path_to *args}\" #{extract_tags_attributes options}>#{name}</a>"
36
+ end
37
+
19
38
  # Returns all paths with query parameters. Example:
20
39
  #
21
40
  # # in Sinatra application:
@@ -28,6 +47,25 @@ module Sinatra
28
47
  options.query_path_to(*args)
29
48
  end
30
49
 
50
+ private
51
+
52
+ # Extract all tag attributes from a hash keys and values.
53
+ def extract_tags_attributes(hash)
54
+ hash.select do |key, value|
55
+ [ :accesskey, :charset, :coords,
56
+ :hreflang, :id, :lang,
57
+ :name, :onblur, :onclick,
58
+ :ondblclick, :onfocus, :onkeydown,
59
+ :onkeypress, :onkeyup, :onmousedown,
60
+ :onmousemove, :onmouseout, :onmouseover,
61
+ :onmouseup, :rel, :rev,
62
+ :shape, :style, :tabindex,
63
+ :target, :title, :type ].include? key
64
+ end.map do |attr, value|
65
+ "#{attr}=\"#{value}\""
66
+ end
67
+ end
68
+
31
69
  end # module MapHelpers
32
70
 
33
71
  end # module Sinatra
@@ -19,9 +19,9 @@
19
19
  gemspec.test_files = gemspec.files.select{ |path| path =~ /^test\/test_.*.rb/ }
20
20
 
21
21
  gemspec.has_rdoc = true
22
- gemspec.extra_rdoc_files = %w[README LICENSE]
22
+ gemspec.extra_rdoc_files = %w[README.rdoc LICENSE]
23
23
 
24
- gemspec.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra - Mapping", "--main", "README"]
24
+ gemspec.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra - Mapping", "--main", "README.rdoc"]
25
25
  gemspec.rubyforge_project = gemspec.name
26
26
  gemspec.rubygems_version = "1.3.3"
27
27
  end if @version || @info # Gem::Specification
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.1
4
+ version: 1.0.0
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-20 00:00:00 -04:00
12
+ date: 2009-07-21 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,13 +39,13 @@ executables: []
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - README
42
+ - README.rdoc
43
43
  - LICENSE
44
44
  files:
45
45
  - CHANGES
46
46
  - INFO
47
47
  - LICENSE
48
- - README
48
+ - README.rdoc
49
49
  - Rakefile
50
50
  - VERSION
51
51
  - lib/sinatra/mapping.rb
@@ -63,7 +63,7 @@ rdoc_options:
63
63
  - --title
64
64
  - Sinatra - Mapping
65
65
  - --main
66
- - README
66
+ - README.rdoc
67
67
  require_paths:
68
68
  - lib
69
69
  required_ruby_version: !ruby/object:Gem::Requirement