snippr 0.3.0 → 0.13.1

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.
Files changed (57) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/README.md +143 -0
  6. data/Rakefile +5 -4
  7. data/lib/snippr.rb +14 -2
  8. data/lib/snippr/i18n.rb +9 -10
  9. data/lib/snippr/links.rb +59 -0
  10. data/lib/snippr/meta_data.rb +33 -0
  11. data/lib/snippr/normalizer.rb +18 -0
  12. data/lib/snippr/normalizer/camelizer.rb +18 -0
  13. data/lib/snippr/normalizer/de_rester.rb +25 -0
  14. data/lib/snippr/path.rb +27 -6
  15. data/lib/snippr/processor.rb +18 -0
  16. data/lib/snippr/processor/dynamics.rb +31 -0
  17. data/lib/snippr/processor/functions.rb +50 -0
  18. data/lib/snippr/processor/links.rb +20 -0
  19. data/lib/snippr/processor/wikilinks.rb +20 -0
  20. data/lib/snippr/snip.rb +57 -0
  21. data/lib/snippr/snippr.rb +41 -45
  22. data/lib/snippr/view_helper.rb +71 -0
  23. data/snippr.gemspec +30 -0
  24. data/spec/fixtures/a/path/aSnippet.snip +1 -0
  25. data/spec/fixtures/a/path/aSnippetWithParam.snip +1 -0
  26. data/spec/fixtures/controller/action/aSnippet.snip +1 -0
  27. data/spec/fixtures/empty.snip +3 -0
  28. data/spec/fixtures/i18n/list_de.snip +0 -0
  29. data/spec/fixtures/meta/broken.snip +5 -0
  30. data/spec/fixtures/meta/withContent.snip +5 -0
  31. data/spec/fixtures/meta/withContentNoNewline.snip +4 -0
  32. data/spec/fixtures/meta/withNoContent.snip +4 -0
  33. data/spec/fixtures/withUnderscore/andUnderscore/aSnippet.snip +1 -0
  34. data/spec/fixtures/withViewHelperMethod.snip +1 -0
  35. data/spec/snippr/i18n_spec.rb +30 -0
  36. data/spec/snippr/links_spec.rb +137 -0
  37. data/spec/snippr/normalizer/camelizer_spec.rb +13 -0
  38. data/spec/snippr/normalizer/de_rester_spec.rb +24 -0
  39. data/spec/snippr/normalizer_spec.rb +40 -0
  40. data/spec/snippr/path_spec.rb +87 -0
  41. data/spec/snippr/processor/dynamics_spec.rb +49 -0
  42. data/spec/snippr/processor/functions_spec.rb +72 -0
  43. data/spec/snippr/processor/links_spec.rb +12 -0
  44. data/spec/snippr/processor/wikilinks_spec.rb +12 -0
  45. data/spec/snippr/processor_spec.rb +35 -0
  46. data/spec/snippr/snip_spec.rb +179 -0
  47. data/spec/snippr/snippr_spec.rb +60 -55
  48. data/spec/snippr/view_helper_spec.rb +221 -0
  49. data/spec/spec_helper.rb +17 -3
  50. metadata +178 -87
  51. data/README.rdoc +0 -77
  52. data/lib/snippr/core_ext.rb +0 -12
  53. data/lib/snippr/helper.rb +0 -23
  54. data/lib/snippr/link.rb +0 -26
  55. data/spec/fixtures/tariff/einheit.snip +0 -1
  56. data/spec/fixtures/wiki.snip +0 -1
  57. data/spec/snippr/core_ext_spec.rb +0 -11
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,18 @@
1
- require "spec"
2
- require "date"
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require(:default, :development)
3
4
 
4
- require "snippr"
5
+ RSpec.configure do |config|
6
+ config.mock_with :mocha
7
+ config.before do
8
+ Snippr::I18n.enabled = nil
9
+ Snippr::Links.adjust_urls_except = nil
10
+ snippr_path = File.expand_path '../fixtures', __FILE__
11
+ if RUBY_PLATFORM =~ /java/
12
+ Snippr::Path.path = snippr_path
13
+ Snippr::Path::JavaLang::System.set_property Snippr::Path::JVM_PROPERTY, snippr_path
14
+ else
15
+ Snippr::Path.path = snippr_path
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,122 +1,213 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: snippr
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.13.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel Harrington
9
+ - Thomas Jachmann
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2010-07-05 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-05-15 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: i18n
17
+ requirement: &2181996100 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
23
24
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ version_requirements: *2181996100
26
+ - !ruby/object:Gem::Dependency
27
+ name: activesupport
28
+ requirement: &2181995660 !ruby/object:Gem::Requirement
25
29
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
33
34
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ version_requirements: *2181995660
37
+ - !ruby/object:Gem::Dependency
38
+ name: ci_reporter
39
+ requirement: &2181995160 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.6.5
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2181995160
48
+ - !ruby/object:Gem::Dependency
36
49
  name: rspec
50
+ requirement: &2181994660 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 2.6.0
56
+ type: :development
37
57
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
58
+ version_requirements: *2181994660
59
+ - !ruby/object:Gem::Dependency
60
+ name: mocha
61
+ requirement: &2181994200 !ruby/object:Gem::Requirement
39
62
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 15
44
- segments:
45
- - 1
46
- - 2
47
- - 8
48
- version: 1.2.8
63
+ requirements:
64
+ - - =
65
+ - !ruby/object:Gem::Version
66
+ version: 0.9.12
49
67
  type: :development
50
- version_requirements: *id002
51
- description:
52
- email: me@rubiii.com
68
+ prerelease: false
69
+ version_requirements: *2181994200
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: &2181993740 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.9.0
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *2181993740
81
+ - !ruby/object:Gem::Dependency
82
+ name: ZenTest
83
+ requirement: &2181993280 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - =
87
+ - !ruby/object:Gem::Version
88
+ version: 4.5.0
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *2181993280
92
+ description: This gem provides ways to access file based cms resources from a rails
93
+ app.
94
+ email:
95
+ - me@rubiii.com
96
+ - self@thomasjachmann.com
53
97
  executables: []
54
-
55
98
  extensions: []
56
-
57
- extra_rdoc_files:
58
- - README.rdoc
59
- files:
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - .travis.yml
60
104
  - CHANGELOG
105
+ - Gemfile
106
+ - README.md
61
107
  - Rakefile
62
- - README.rdoc
63
108
  - lib/snippr.rb
64
- - lib/snippr/snippr.rb
65
- - lib/snippr/helper.rb
66
- - lib/snippr/path.rb
67
- - lib/snippr/core_ext.rb
68
- - lib/snippr/link.rb
69
109
  - lib/snippr/i18n.rb
110
+ - lib/snippr/links.rb
111
+ - lib/snippr/meta_data.rb
112
+ - lib/snippr/normalizer.rb
113
+ - lib/snippr/normalizer/camelizer.rb
114
+ - lib/snippr/normalizer/de_rester.rb
115
+ - lib/snippr/path.rb
116
+ - lib/snippr/processor.rb
117
+ - lib/snippr/processor/dynamics.rb
118
+ - lib/snippr/processor/functions.rb
119
+ - lib/snippr/processor/links.rb
120
+ - lib/snippr/processor/wikilinks.rb
121
+ - lib/snippr/snip.rb
122
+ - lib/snippr/snippr.rb
123
+ - lib/snippr/view_helper.rb
70
124
  - rails/init.rb
71
- - spec/snippr/snippr_spec.rb
72
- - spec/snippr/core_ext_spec.rb
73
- - spec/spec_helper.rb
74
- - spec/fixtures/topup/someError.snip
75
- - spec/fixtures/topup/success.snip
76
- - spec/fixtures/wiki.snip
77
- - spec/fixtures/tariff/einheit.snip
125
+ - snippr.gemspec
126
+ - spec/fixtures/a/path/aSnippet.snip
127
+ - spec/fixtures/a/path/aSnippetWithParam.snip
128
+ - spec/fixtures/controller/action/aSnippet.snip
129
+ - spec/fixtures/empty.snip
130
+ - spec/fixtures/home.snip
131
+ - spec/fixtures/i18n/list_de.snip
78
132
  - spec/fixtures/i18n/shop_de.snip
79
133
  - spec/fixtures/i18n/shop_en.snip
80
- - spec/fixtures/home.snip
81
- has_rdoc: true
134
+ - spec/fixtures/meta/broken.snip
135
+ - spec/fixtures/meta/withContent.snip
136
+ - spec/fixtures/meta/withContentNoNewline.snip
137
+ - spec/fixtures/meta/withNoContent.snip
138
+ - spec/fixtures/topup/someError.snip
139
+ - spec/fixtures/topup/success.snip
140
+ - spec/fixtures/withUnderscore/andUnderscore/aSnippet.snip
141
+ - spec/fixtures/withViewHelperMethod.snip
142
+ - spec/snippr/i18n_spec.rb
143
+ - spec/snippr/links_spec.rb
144
+ - spec/snippr/normalizer/camelizer_spec.rb
145
+ - spec/snippr/normalizer/de_rester_spec.rb
146
+ - spec/snippr/normalizer_spec.rb
147
+ - spec/snippr/path_spec.rb
148
+ - spec/snippr/processor/dynamics_spec.rb
149
+ - spec/snippr/processor/functions_spec.rb
150
+ - spec/snippr/processor/links_spec.rb
151
+ - spec/snippr/processor/wikilinks_spec.rb
152
+ - spec/snippr/processor_spec.rb
153
+ - spec/snippr/snip_spec.rb
154
+ - spec/snippr/snippr_spec.rb
155
+ - spec/snippr/view_helper_spec.rb
156
+ - spec/spec_helper.rb
82
157
  homepage: http://github.com/blaulabs/snippr
83
158
  licenses: []
84
-
85
159
  post_install_message:
86
- rdoc_options:
87
- - --charset=UTF-8
88
- - --line-numbers
89
- - --inline-source
90
- - --title
91
- - Snippr - File based content management
92
- require_paths:
160
+ rdoc_options: []
161
+ require_paths:
93
162
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
163
+ required_ruby_version: !ruby/object:Gem::Requirement
95
164
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
170
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
112
175
  requirements: []
113
-
114
- rubyforge_project:
115
- rubygems_version: 1.3.7
176
+ rubyforge_project: snippr
177
+ rubygems_version: 1.8.11
116
178
  signing_key:
117
179
  specification_version: 3
118
180
  summary: File based content management
119
- test_files:
181
+ test_files:
182
+ - spec/fixtures/a/path/aSnippet.snip
183
+ - spec/fixtures/a/path/aSnippetWithParam.snip
184
+ - spec/fixtures/controller/action/aSnippet.snip
185
+ - spec/fixtures/empty.snip
186
+ - spec/fixtures/home.snip
187
+ - spec/fixtures/i18n/list_de.snip
188
+ - spec/fixtures/i18n/shop_de.snip
189
+ - spec/fixtures/i18n/shop_en.snip
190
+ - spec/fixtures/meta/broken.snip
191
+ - spec/fixtures/meta/withContent.snip
192
+ - spec/fixtures/meta/withContentNoNewline.snip
193
+ - spec/fixtures/meta/withNoContent.snip
194
+ - spec/fixtures/topup/someError.snip
195
+ - spec/fixtures/topup/success.snip
196
+ - spec/fixtures/withUnderscore/andUnderscore/aSnippet.snip
197
+ - spec/fixtures/withViewHelperMethod.snip
198
+ - spec/snippr/i18n_spec.rb
199
+ - spec/snippr/links_spec.rb
200
+ - spec/snippr/normalizer/camelizer_spec.rb
201
+ - spec/snippr/normalizer/de_rester_spec.rb
202
+ - spec/snippr/normalizer_spec.rb
203
+ - spec/snippr/path_spec.rb
204
+ - spec/snippr/processor/dynamics_spec.rb
205
+ - spec/snippr/processor/functions_spec.rb
206
+ - spec/snippr/processor/links_spec.rb
207
+ - spec/snippr/processor/wikilinks_spec.rb
208
+ - spec/snippr/processor_spec.rb
209
+ - spec/snippr/snip_spec.rb
120
210
  - spec/snippr/snippr_spec.rb
121
- - spec/snippr/core_ext_spec.rb
211
+ - spec/snippr/view_helper_spec.rb
122
212
  - spec/spec_helper.rb
213
+ has_rdoc:
data/README.rdoc DELETED
@@ -1,77 +0,0 @@
1
- = Snippr
2
- ==== File based content management
3
-
4
- A snippr file is a piece of HTML or raw text to be included in a website. They are plain text
5
- files stored on the file system. Snippr files end with ".snip" and are read from the Snippr path.
6
-
7
- == Snippr path
8
-
9
- You need to specify the path to the directory where your Snippr files are stored:
10
-
11
- Snippr.path = File.join File.dirname(__FILE__), "..", "snippr"
12
-
13
- When running on JRuby, you can also set the path via JVM properties. The property you need to
14
- specify is defined in Snippr::Path::JVMProperty. This allows system administrators to change the
15
- path without having to touch your application.
16
-
17
- == Loading a snippr
18
-
19
- To load a snippr file, you can use the +load+ method, passing in the path to the snippr file as
20
- a String (including path separators):
21
-
22
- Snippr.load "tariff/einheit"
23
-
24
- or by using multiple Strings or Symbols:
25
-
26
- Snippr.load :tariff, :einheit
27
-
28
- === Dynamic values
29
-
30
- A snippr file may contain placeholders to be replaced with dynamic values. Placeholders are
31
- wrapped in curly braces.
32
-
33
- <p>You're topup of {topup_amount} at {date_today} was successful.</p>
34
-
35
- To replace both {topup_amount} and {date_today} with a dynamic value, you just pass in a Hash of
36
- placeholders and dynamic values when loading a snippr file.
37
-
38
- Snippr.load :topup, :success, :topup_amount => number_to_currency(15), :date_today => Date.today
39
-
40
- The result will obviously be something like:
41
-
42
- <p>You're topup of 15,00 &euro; at 2010-04-03 was successful.</p>
43
-
44
- == I18n
45
-
46
- Snippr comes with support for I18n, but up until further notice, you have to manually enable this
47
- behavior in your application.
48
-
49
- Snippr.i18n = true
50
-
51
- Afterwards Snippr uses the locale specified via I18n and automatically prepends the current locale
52
- prefixed with a "_" to your snippr files.
53
-
54
- I18n.locale = :de
55
- Snippr.load :shop # tries to load "shop_de.snip" relative to your Snippr path
56
-
57
- I18n.locale = :en
58
- Snippr.load :shop # tries to load "shop_en.snip" relative to your Snippr path
59
-
60
- == Wiki Syntax
61
-
62
- Until now, only wiki links with text are supported by Snippr:
63
-
64
- [[http://www.blaulabs.de|blaulabs]]
65
-
66
- will be converted to:
67
-
68
- <a href="http://www.blaulabs.de">blaulabs</a>
69
-
70
- == Rails Helper
71
-
72
- When using the Snippr module with Rails, it automatically adds the +Snippr::Helper+ module to
73
- your views. You can then use the +snippr+ helper method to load snippr files.
74
-
75
- %h1 Topup successful
76
- .topup.info
77
- = snippr :topup, :success
@@ -1,12 +0,0 @@
1
- class String
2
-
3
- # Returns the String in lowerCamelCase.
4
- def lower_camelcase
5
- str = dup
6
- str.gsub!(/\/(.?)/) { "::#{$1.upcase}" }
7
- str.gsub!(/(?:_+|-+)([a-z])/) { $1.upcase }
8
- str.gsub!(/(\A|\s)([A-Z])/) { $1 + $2.downcase }
9
- str
10
- end
11
-
12
- end
data/lib/snippr/helper.rb DELETED
@@ -1,23 +0,0 @@
1
- # = Snippr::Helper
2
- #
3
- # This module is automatically included into +ActionView::Base+ when using the Snippr
4
- # component with Rails. It provides a +snippr+ helper method for loading snippr files.
5
- #
6
- # %h1 Topup successful
7
- # .topup.info
8
- # = snippr :topup, :success
9
- module Snippr
10
- module Helper
11
-
12
- # Returns a snippr specified via +args+.
13
- def snippr(*args)
14
- snippr = Snippr.load *args
15
- snippr.respond_to?(:html_safe) ? snippr.html_safe : snippr
16
- end
17
-
18
- end
19
- end
20
-
21
- if defined? ActionView::Base
22
- ActionView::Base.send :include, Snippr::Helper
23
- end
data/lib/snippr/link.rb DELETED
@@ -1,26 +0,0 @@
1
- # = Snippr::Link
2
- #
3
- # Extends the Snippr module adding support for link helpers like wiki links.
4
- module Snippr
5
- module Link
6
-
7
- # Regex for links in wiki syntax (eg. [[http://www.google.de|google]]).
8
- WikiLink = /\[\[([^|]+)\|([^\]]+)\]\]/
9
-
10
- # Pattern for general link tags.
11
- HtmlLink = '<a href="\1">\2</a>'
12
-
13
- # Convert all links to html links (eg. wiki links to html links).
14
- def linkify(content)
15
- convert_wiki_links content
16
- end
17
-
18
- private
19
-
20
- # Convert wiki links to html links
21
- def convert_wiki_links(content)
22
- content.gsub WikiLink, HtmlLink
23
- end
24
-
25
- end
26
- end