nice-n-easy 1.0.0 → 1.1.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/.gitignore CHANGED
@@ -20,3 +20,5 @@ docs
20
20
  pkg
21
21
 
22
22
  ## PROJECT::SPECIFIC
23
+
24
+ .rvmrc
data/README.md CHANGED
@@ -15,12 +15,16 @@ ActiveSupport's "blank" functionality is included here, and I copy "`extract_opt
15
15
  "`symbolize_keys`" from there too but I add nothing else. Although if you include
16
16
  ActiveSupport yourself the `label` helper will take advantage of the `titleize` method.
17
17
 
18
+ Another influence on my design was ease of compatibility with [mustache](http://github.com/defunkt/mustache).
19
+ This meant that methods like `form_for` that take a block should be avoided,
20
+ as these would be harder to implement in a mustache (although not impossible).
21
+
18
22
 
19
23
  ## Install & Usage
20
24
 
21
25
  Install:
22
26
 
23
- sudo gem install nice-n-easy
27
+ sudo gem install nice-n-easy --source http://gemcutter.org
24
28
 
25
29
  Add this to your Sinatra app:
26
30
 
@@ -30,7 +34,7 @@ Add this to your Sinatra app:
30
34
  helpers Sinatra::NiceEasyHelpers
31
35
  end
32
36
 
33
- See the RDocs for how to use the individual helpers
37
+ See the [RDocs](http://brianjlandau.github.com/nice-n-easy/) for how to use the individual helpers
34
38
 
35
39
 
36
40
  ## Note on Patches/Pull Requests
@@ -39,7 +43,7 @@ See the RDocs for how to use the individual helpers
39
43
  * Make your feature addition or bug fix.
40
44
  * Add tests for it. This is important so I don't break it in a
41
45
  future version unintentionally.
42
- * Commit, do not mess with rakefile, version, or history.
46
+ * Commit, do not mess with rake file, version, or history.
43
47
  (if you want to have your own version, that is fine but
44
48
  bump version in a commit by itself I can ignore when I pull)
45
49
  * Send me a pull request. Bonus points for topic branches.
data/Rakefile CHANGED
@@ -10,8 +10,8 @@ begin
10
10
  gem.email = "brian.landau@viget.com"
11
11
  gem.homepage = "http://github.com/brianjlandau/nice-n-easy"
12
12
  gem.authors = ["Brian Landau"]
13
- gem.add_dependency('sinatra', '~> 0.9')
14
- gem.add_dependency('activesupport', '~> 2.3')
13
+ gem.add_dependency('sinatra')
14
+ gem.add_dependency('activesupport', '~> 3.0')
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
@@ -22,5 +22,4 @@ end
22
22
  require 'tasks/test'
23
23
  require 'tasks/rdoc'
24
24
 
25
- task :test => :check_dependencies
26
25
  task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -0,0 +1 @@
1
+ git://github.com/sinatra/sinatra.git e0ee682 # 0.9.4
@@ -1,6 +1,6 @@
1
1
  require 'sinatra/base'
2
2
  unless Object.method_defined?(:blank?)
3
- require 'active_support/core_ext/blank'
3
+ require 'active_support/core_ext/object/blank'
4
4
  end
5
5
 
6
6
  module Sinatra #:nodoc:
@@ -11,6 +11,32 @@ module Sinatra #:nodoc:
11
11
  HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }
12
12
  # :startdoc:
13
13
 
14
+ @@asset_sub_directories ||= {
15
+ :images => 'images',
16
+ :javascript => 'javascripts',
17
+ :stylesheets => 'stylesheets'
18
+ }
19
+ def self.asset_sub_directories
20
+ @@asset_sub_directories
21
+ end
22
+ def self.asset_sub_directories=(options)
23
+ @@asset_sub_directories = options
24
+ end
25
+ def asset_sub_directories
26
+ @@asset_sub_directories
27
+ end
28
+
29
+ @@asset_directory = nil
30
+ def self.asset_directory
31
+ @@asset_directory
32
+ end
33
+ def self.asset_directory=(path)
34
+ @@asset_directory = path
35
+ end
36
+ def asset_directory
37
+ @@asset_directory
38
+ end
39
+
14
40
  # Creates a link to a given URL with the given text as the link.
15
41
  # link "Check this out", '/path/to/something' # =>
16
42
  # <a href="/path/to/something">Check this out</a>
@@ -31,7 +57,7 @@ module Sinatra #:nodoc:
31
57
  # <img src="http://www.example.com/close.jpg" />
32
58
  #
33
59
  def image_tag(src, options = {})
34
- single_tag :img, options.merge(:src => compute_public_path(src, 'images'))
60
+ single_tag :img, options.merge(:src => compute_public_path(src, asset_sub_directories[:images]))
35
61
  end
36
62
 
37
63
  # Creates a script tag for each source provided. If you just supply a relative filename
@@ -53,7 +79,7 @@ module Sinatra #:nodoc:
53
79
  #
54
80
  def javascript_include_tag(*sources)
55
81
  sources.inject([]) { |tags, source|
56
- tags << tag(:script, '', {:src => compute_public_path(source, 'javascripts', 'js'), :type => 'text/javascript'})
82
+ tags << tag(:script, '', {:src => compute_public_path(source, asset_sub_directories[:javascript], 'js'), :type => 'text/javascript'})
57
83
  tags
58
84
  }.join("\n")
59
85
  end
@@ -76,7 +102,7 @@ module Sinatra #:nodoc:
76
102
  def stylesheet_link_tag(*sources)
77
103
  options = sources.extract_options!.symbolize_keys
78
104
  sources.inject([]) { |tags, source|
79
- tags << single_tag(:link, {:href => compute_public_path(source, 'stylesheets', 'css'),
105
+ tags << single_tag(:link, {:href => compute_public_path(source, asset_sub_directories[:stylesheets], 'css'),
80
106
  :type => 'text/css', :rel => 'stylesheet', :media => 'screen'}.merge(options))
81
107
  tags
82
108
  }.join("\n")
@@ -239,7 +265,7 @@ module Sinatra #:nodoc:
239
265
  # image_input "buttons/save_close.png", :alt => 'Save and close'
240
266
  # <input type="image" src="buttons/save_close.png" alt="Save and close" />
241
267
  def image_input(src, options = {})
242
- single_tag :input, options.merge(:type => 'image', :src => compute_public_path(src, 'images'))
268
+ single_tag :input, options.merge(:type => 'image', :src => compute_public_path(src, asset_sub_directories[:images]))
243
269
  end
244
270
 
245
271
  # Creates as submit input field with the text and options provided.
@@ -537,10 +563,36 @@ module Sinatra #:nodoc:
537
563
  unless source =~ %r{^[-a-z]+://}
538
564
  source = "/#{dir}/#{source}" unless source[0] == ?/
539
565
  end
566
+
567
+ source = add_asset_id(source)
540
568
 
541
569
  return source
542
570
  end
543
571
 
572
+ @@asset_timestamps_cache = {}
573
+ @@asset_timestamps_cache_guard = Mutex.new
574
+
575
+ def add_asset_id(source)
576
+ if asset_directory.present?
577
+ if @@cache_asset_timestamps && (asset_id = @@asset_timestamps_cache[source])
578
+ asset_id
579
+ else
580
+ path = File.join(asset_directory, source)
581
+ asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
582
+
583
+ if @@cache_asset_timestamps
584
+ @@asset_timestamps_cache_guard.synchronize do
585
+ @@asset_timestamps_cache[source] = asset_id
586
+ end
587
+ end
588
+ end
589
+ if asset_id.present?
590
+ source += "?#{asset_id}"
591
+ end
592
+ end
593
+ source
594
+ end
595
+
544
596
  end
545
597
  end
546
598
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nice-n-easy}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Landau"]
12
- s.date = %q{2009-10-28}
12
+ s.date = %q{2011-06-06}
13
13
  s.description = %q{A set of Sinatra HTML view helpers to make your life nicer and easier. Helpers for forms, links, and assets.}
14
14
  s.email = %q{brian.landau@viget.com}
15
15
  s.extra_rdoc_files = [
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  "README.md",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "deps.rip",
26
27
  "lib/sinatra/nice_easy_helpers.rb",
27
28
  "nice-n-easy.gemspec",
28
29
  "tasks/rdoc.rb",
@@ -36,7 +37,7 @@ Gem::Specification.new do |s|
36
37
  s.homepage = %q{http://github.com/brianjlandau/nice-n-easy}
37
38
  s.rdoc_options = ["--charset=UTF-8"]
38
39
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.5}
40
+ s.rubygems_version = %q{1.3.7}
40
41
  s.summary = %q{Sinatra HTML helpers that are nice-n-easy to use.}
41
42
  s.test_files = [
42
43
  "test/nice_easy_helpers_test.rb",
@@ -48,16 +49,16 @@ Gem::Specification.new do |s|
48
49
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
50
  s.specification_version = 3
50
51
 
51
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<sinatra>, ["~> 0.9"])
53
- s.add_runtime_dependency(%q<activesupport>, ["~> 2.3"])
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
54
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
54
55
  else
55
- s.add_dependency(%q<sinatra>, ["~> 0.9"])
56
- s.add_dependency(%q<activesupport>, ["~> 2.3"])
56
+ s.add_dependency(%q<sinatra>, [">= 0"])
57
+ s.add_dependency(%q<activesupport>, ["~> 3.0"])
57
58
  end
58
59
  else
59
- s.add_dependency(%q<sinatra>, ["~> 0.9"])
60
- s.add_dependency(%q<activesupport>, ["~> 2.3"])
60
+ s.add_dependency(%q<sinatra>, [">= 0"])
61
+ s.add_dependency(%q<activesupport>, ["~> 3.0"])
61
62
  end
62
63
  end
63
64
 
@@ -1,10 +1,15 @@
1
1
  require 'active_support'
2
2
  require 'rexml/document'
3
+ require 'active_support'
4
+ require 'active_support/hash_with_indifferent_access'
5
+ require 'active_support/core_ext'
3
6
  require 'action_controller/vendor/html-scanner'
4
- require 'action_controller/assertions/selector_assertions'
7
+ require 'action_controller/vendor/html-scanner/html/node'
8
+ require 'action_controller/vendor/html-scanner/html/document'
9
+ require 'action_dispatch/testing/assertions/selector'
5
10
 
6
11
  module TagMatchingAssertions
7
- include ActionController::Assertions::SelectorAssertions
12
+ include ActionDispatch::Assertions::SelectorAssertions
8
13
 
9
14
  def assert_tag_in(*opts)
10
15
  target = opts.shift
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice-n-easy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Brian Landau
@@ -9,29 +15,38 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-10-28 00:00:00 -04:00
18
+ date: 2011-06-06 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: sinatra
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
- - - ~>
27
+ - - ">="
22
28
  - !ruby/object:Gem::Version
23
- version: "0.9"
24
- version:
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
30
40
  requirements:
31
41
  - - ~>
32
42
  - !ruby/object:Gem::Version
33
- version: "2.3"
34
- version:
43
+ hash: 7
44
+ segments:
45
+ - 3
46
+ - 0
47
+ version: "3.0"
48
+ type: :runtime
49
+ version_requirements: *id002
35
50
  description: A set of Sinatra HTML view helpers to make your life nicer and easier. Helpers for forms, links, and assets.
36
51
  email: brian.landau@viget.com
37
52
  executables: []
@@ -48,6 +63,7 @@ files:
48
63
  - README.md
49
64
  - Rakefile
50
65
  - VERSION
66
+ - deps.rip
51
67
  - lib/sinatra/nice_easy_helpers.rb
52
68
  - nice-n-easy.gemspec
53
69
  - tasks/rdoc.rb
@@ -67,21 +83,27 @@ rdoc_options:
67
83
  require_paths:
68
84
  - lib
69
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
70
87
  requirements:
71
88
  - - ">="
72
89
  - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
73
93
  version: "0"
74
- version:
75
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
76
96
  requirements:
77
97
  - - ">="
78
98
  - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
79
102
  version: "0"
80
- version:
81
103
  requirements: []
82
104
 
83
105
  rubyforge_project:
84
- rubygems_version: 1.3.5
106
+ rubygems_version: 1.3.7
85
107
  signing_key:
86
108
  specification_version: 3
87
109
  summary: Sinatra HTML helpers that are nice-n-easy to use.