ultimate-base 0.2.4 → 0.3.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/.gitignore +4 -1
  2. data/.rvmrc +0 -1
  3. data/.rvmrc.example +0 -1
  4. data/Gemfile +6 -0
  5. data/Gemfile.lock +113 -1
  6. data/app/assets/javascripts/ultimate/backbone/base.js.coffee +14 -2
  7. data/app/assets/javascripts/ultimate/backbone/extra/jquery-plugin-adapter.js.coffee +1 -1
  8. data/app/assets/javascripts/ultimate/backbone/model.js.coffee +6 -0
  9. data/app/assets/javascripts/ultimate/backbone/view.js.coffee +5 -4
  10. data/app/assets/javascripts/ultimate/backbone/views/slider.js.coffee +4 -1
  11. data/app/assets/javascripts/ultimate/helpers/asset_tag.js.coffee +71 -54
  12. data/app/assets/javascripts/ultimate/helpers/base.js.coffee +3 -0
  13. data/app/assets/javascripts/ultimate/helpers/decor.js.coffee +19 -14
  14. data/app/assets/javascripts/ultimate/helpers/number.js.coffee +600 -0
  15. data/app/assets/javascripts/ultimate/helpers/record_tag.js.coffee +66 -0
  16. data/app/assets/javascripts/ultimate/helpers/tag.js.coffee +77 -0
  17. data/app/assets/javascripts/ultimate/helpers/url.js.coffee +49 -0
  18. data/app/assets/javascripts/ultimate/helpers.js.coffee +39 -66
  19. data/app/assets/javascripts/ultimate/{devise.js.coffee → improves/devise.js.coffee} +0 -0
  20. data/app/assets/javascripts/ultimate/improves/i18n-lite.js.coffee +18 -12
  21. data/app/assets/javascripts/ultimate/improves/magic-radios.js.coffee +2 -0
  22. data/app/assets/javascripts/ultimate/improves/typed-fields.js.coffee +13 -14
  23. data/app/assets/javascripts/ultimate/{base.js.coffee → jquery.base.js.coffee} +24 -37
  24. data/app/assets/javascripts/ultimate/{experimental/_inflections → underscore}/underscore.inflection.js +19 -18
  25. data/app/assets/javascripts/ultimate/underscore/underscore.outcasts.js.coffee +123 -0
  26. data/app/assets/javascripts/ultimate/underscore/underscore.string.js +16 -6
  27. data/config/routes.rb +2 -0
  28. data/lib/{ultimate-base → ultimate/base}/engine.rb +1 -0
  29. data/lib/{ultimate-base → ultimate/base}/version.rb +1 -1
  30. data/lib/ultimate/base.rb +10 -0
  31. data/lib/{ultimate-base → ultimate}/extensions/directive_processor.rb +0 -0
  32. data/lib/{ultimate-base → ultimate}/extensions/sass_script_functions.rb +0 -0
  33. data/scripts/rails +8 -0
  34. data/test/dummy/Rakefile +7 -0
  35. data/test/dummy/_emfile +18 -0
  36. data/{app/assets/javascripts/ultimate/helpers/forms.js.coffee → test/dummy/app/assets/images/.gitkeep} +0 -0
  37. data/test/dummy/app/assets/javascripts/application.js +3 -0
  38. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  39. data/test/dummy/app/assets/stylesheets/global/forms.css.scss +65 -0
  40. data/test/dummy/app/assets/stylesheets/global/layout/footer.scss +18 -0
  41. data/test/dummy/app/assets/stylesheets/global/layout/header.scss +13 -0
  42. data/test/dummy/app/assets/stylesheets/global/layout/main-menu.scss +68 -0
  43. data/test/dummy/app/assets/stylesheets/global/layout.css.scss +46 -0
  44. data/test/dummy/app/assets/stylesheets/global/reserved.css.scss +79 -0
  45. data/test/dummy/app/assets/stylesheets/global/reset.css.scss +85 -0
  46. data/test/dummy/app/assets/stylesheets/global/structures.css.scss +9 -0
  47. data/test/dummy/app/assets/stylesheets/import/base.scss +34 -0
  48. data/test/dummy/app/assets/stylesheets/plugins/qunit.css.scss +3 -0
  49. data/test/dummy/app/controllers/application_controller.rb +4 -0
  50. data/test/dummy/app/controllers/main_controller.rb +8 -0
  51. data/test/dummy/app/helpers/application_helper.rb +2 -0
  52. data/test/dummy/app/mailers/.gitkeep +0 -0
  53. data/test/dummy/app/models/.gitkeep +0 -0
  54. data/test/dummy/app/views/application/_footer.html.haml +3 -0
  55. data/test/dummy/app/views/application/_header.html.haml +4 -0
  56. data/test/dummy/app/views/application/_main_menu.html.haml +11 -0
  57. data/test/dummy/app/views/layouts/application.html.haml +24 -0
  58. data/test/dummy/app/views/main/index.html.haml +13 -0
  59. data/test/dummy/app/views/main/qunit.html.haml +7 -0
  60. data/test/dummy/config/application.rb +59 -0
  61. data/test/dummy/config/boot.rb +10 -0
  62. data/test/dummy/config/database.yml +25 -0
  63. data/test/dummy/config/environment.rb +5 -0
  64. data/test/dummy/config/environments/development.rb +40 -0
  65. data/test/dummy/config/environments/production.rb +67 -0
  66. data/test/dummy/config/environments/test.rb +37 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/inflections.rb +15 -0
  69. data/test/dummy/config/initializers/mime_types.rb +5 -0
  70. data/test/dummy/config/initializers/qunit-rails.rb +1 -0
  71. data/test/dummy/config/initializers/secret_token.rb +7 -0
  72. data/test/dummy/config/initializers/session_store.rb +8 -0
  73. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  74. data/test/dummy/config/locales/en.yml +5 -0
  75. data/test/dummy/config/routes.rb +63 -0
  76. data/test/dummy/config.ru +4 -0
  77. data/test/dummy/log/.gitkeep +0 -0
  78. data/test/dummy/public/404.html +26 -0
  79. data/test/dummy/public/422.html +26 -0
  80. data/test/dummy/public/500.html +25 -0
  81. data/test/dummy/public/favicon.ico +0 -0
  82. data/test/dummy/script/rails +6 -0
  83. data/test/javascripts/all_tests.js.coffee +13 -0
  84. data/test/javascripts/test_helper.js.coffee +3 -0
  85. data/test/javascripts/tests/base_test.js.coffee +42 -0
  86. data/test/javascripts/tests/helpers/asset_tag_test.js.coffee +51 -0
  87. data/test/javascripts/tests/helpers/number_test.js.coffee +250 -0
  88. data/test/javascripts/tests/helpers/record_tag_test.js.coffee +56 -0
  89. data/test/javascripts/tests/helpers/tag_test.js.coffee +33 -0
  90. data/test/javascripts/tests/helpers/url_test.js.coffee +28 -0
  91. data/test/javascripts/tests/helpers_test.js.coffee +47 -0
  92. data/test/javascripts/tests/improves/i18n-lite_test.js.coffee +25 -0
  93. data/test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee +38 -0
  94. data/test/stylesheets/test_helper.css +4 -0
  95. data/ultimate-base.gemspec +4 -4
  96. metadata +116 -24
  97. data/app/assets/javascripts/ultimate/bus.js.coffee +0 -57
  98. data/app/assets/javascripts/ultimate/experimental/_inflections/dzone.inflections.js +0 -154
  99. data/app/assets/javascripts/ultimate/helpers/array.js.coffee +0 -63
  100. data/app/assets/javascripts/ultimate/helpers/tags.js.coffee +0 -73
  101. data/app/assets/javascripts/ultimate/widgets/dock.js.coffee +0 -70
  102. data/app/assets/javascripts/ultimate/widgets/gear.js.coffee +0 -84
  103. data/app/assets/javascripts/ultimate/widgets/jquery-ext.js.coffee +0 -104
  104. data/app/assets/javascripts/ultimate/widgets/jquery.adapter.js.coffee +0 -62
  105. data/app/assets/javascripts/ultimate/widgets/widget.js.coffee +0 -115
  106. data/lib/ultimate-base.rb +0 -10
metadata CHANGED
@@ -1,16 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
5
- prerelease:
4
+ version: 0.3.0.alpha
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dmitry KODer Karpunin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-17 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-09-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &8050420 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.8
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *8050420
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &8050000 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *8050000
36
+ - !ruby/object:Gem::Dependency
37
+ name: coffee-rails
38
+ requirement: &8163580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 3.2.1
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *8163580
14
47
  description: Ultimate UI core, base helpers and improves for Ruby on Rails Front-end
15
48
  email:
16
49
  - koderfunk@gmail.com
@@ -37,34 +70,30 @@ files:
37
70
  - app/assets/javascripts/ultimate/backbone/view.js.coffee
38
71
  - app/assets/javascripts/ultimate/backbone/views/slider.js.coffee
39
72
  - app/assets/javascripts/ultimate/backbone/views/typed-fields.js.coffee
40
- - app/assets/javascripts/ultimate/base.js.coffee
41
- - app/assets/javascripts/ultimate/bus.js.coffee
42
- - app/assets/javascripts/ultimate/devise.js.coffee
43
- - app/assets/javascripts/ultimate/experimental/_inflections/dzone.inflections.js
44
73
  - app/assets/javascripts/ultimate/experimental/_inflections/inflections.js.coffee
45
74
  - app/assets/javascripts/ultimate/experimental/_inflections/plur.js
46
- - app/assets/javascripts/ultimate/experimental/_inflections/underscore.inflection.js
47
75
  - app/assets/javascripts/ultimate/experimental/fuzzy-json-generator.js.coffee
48
76
  - app/assets/javascripts/ultimate/helpers.js.coffee
49
- - app/assets/javascripts/ultimate/helpers/array.js.coffee
50
77
  - app/assets/javascripts/ultimate/helpers/asset_tag.js.coffee
78
+ - app/assets/javascripts/ultimate/helpers/base.js.coffee
51
79
  - app/assets/javascripts/ultimate/helpers/decor.js.coffee
52
- - app/assets/javascripts/ultimate/helpers/forms.js.coffee
53
- - app/assets/javascripts/ultimate/helpers/tags.js.coffee
80
+ - app/assets/javascripts/ultimate/helpers/number.js.coffee
81
+ - app/assets/javascripts/ultimate/helpers/record_tag.js.coffee
82
+ - app/assets/javascripts/ultimate/helpers/tag.js.coffee
83
+ - app/assets/javascripts/ultimate/helpers/url.js.coffee
54
84
  - app/assets/javascripts/ultimate/improves/datepicker.js.coffee
85
+ - app/assets/javascripts/ultimate/improves/devise.js.coffee
55
86
  - app/assets/javascripts/ultimate/improves/form-errors.js.coffee
56
87
  - app/assets/javascripts/ultimate/improves/form.js.coffee
57
88
  - app/assets/javascripts/ultimate/improves/i18n-lite.js.coffee
58
89
  - app/assets/javascripts/ultimate/improves/magic-radios.js.coffee
59
90
  - app/assets/javascripts/ultimate/improves/tablesorter.js
60
91
  - app/assets/javascripts/ultimate/improves/typed-fields.js.coffee
92
+ - app/assets/javascripts/ultimate/jquery.base.js.coffee
93
+ - app/assets/javascripts/ultimate/underscore/underscore.inflection.js
61
94
  - app/assets/javascripts/ultimate/underscore/underscore.js
95
+ - app/assets/javascripts/ultimate/underscore/underscore.outcasts.js.coffee
62
96
  - app/assets/javascripts/ultimate/underscore/underscore.string.js
63
- - app/assets/javascripts/ultimate/widgets/dock.js.coffee
64
- - app/assets/javascripts/ultimate/widgets/gear.js.coffee
65
- - app/assets/javascripts/ultimate/widgets/jquery-ext.js.coffee
66
- - app/assets/javascripts/ultimate/widgets/jquery.adapter.js.coffee
67
- - app/assets/javascripts/ultimate/widgets/widget.js.coffee
68
97
  - app/assets/stylesheets/polyfills/PIE.htc
69
98
  - app/assets/stylesheets/polyfills/boxsizing.htc
70
99
  - app/assets/stylesheets/ultimate/mixins/_routines.scss
@@ -75,11 +104,74 @@ files:
75
104
  - app/assets/stylesheets/ultimate/mixins/fonts.scss
76
105
  - app/assets/stylesheets/ultimate/mixins/microstructures.scss
77
106
  - app/assets/stylesheets/ultimate/structures/slider.scss
78
- - lib/ultimate-base.rb
79
- - lib/ultimate-base/engine.rb
80
- - lib/ultimate-base/extensions/directive_processor.rb
81
- - lib/ultimate-base/extensions/sass_script_functions.rb
82
- - lib/ultimate-base/version.rb
107
+ - config/routes.rb
108
+ - lib/ultimate/base.rb
109
+ - lib/ultimate/base/engine.rb
110
+ - lib/ultimate/base/version.rb
111
+ - lib/ultimate/extensions/directive_processor.rb
112
+ - lib/ultimate/extensions/sass_script_functions.rb
113
+ - scripts/rails
114
+ - test/dummy/Rakefile
115
+ - test/dummy/_emfile
116
+ - test/dummy/app/assets/images/.gitkeep
117
+ - test/dummy/app/assets/javascripts/application.js
118
+ - test/dummy/app/assets/stylesheets/application.css
119
+ - test/dummy/app/assets/stylesheets/global/forms.css.scss
120
+ - test/dummy/app/assets/stylesheets/global/layout.css.scss
121
+ - test/dummy/app/assets/stylesheets/global/layout/footer.scss
122
+ - test/dummy/app/assets/stylesheets/global/layout/header.scss
123
+ - test/dummy/app/assets/stylesheets/global/layout/main-menu.scss
124
+ - test/dummy/app/assets/stylesheets/global/reserved.css.scss
125
+ - test/dummy/app/assets/stylesheets/global/reset.css.scss
126
+ - test/dummy/app/assets/stylesheets/global/structures.css.scss
127
+ - test/dummy/app/assets/stylesheets/import/base.scss
128
+ - test/dummy/app/assets/stylesheets/plugins/qunit.css.scss
129
+ - test/dummy/app/controllers/application_controller.rb
130
+ - test/dummy/app/controllers/main_controller.rb
131
+ - test/dummy/app/helpers/application_helper.rb
132
+ - test/dummy/app/mailers/.gitkeep
133
+ - test/dummy/app/models/.gitkeep
134
+ - test/dummy/app/views/application/_footer.html.haml
135
+ - test/dummy/app/views/application/_header.html.haml
136
+ - test/dummy/app/views/application/_main_menu.html.haml
137
+ - test/dummy/app/views/layouts/application.html.haml
138
+ - test/dummy/app/views/main/index.html.haml
139
+ - test/dummy/app/views/main/qunit.html.haml
140
+ - test/dummy/config.ru
141
+ - test/dummy/config/application.rb
142
+ - test/dummy/config/boot.rb
143
+ - test/dummy/config/database.yml
144
+ - test/dummy/config/environment.rb
145
+ - test/dummy/config/environments/development.rb
146
+ - test/dummy/config/environments/production.rb
147
+ - test/dummy/config/environments/test.rb
148
+ - test/dummy/config/initializers/backtrace_silencers.rb
149
+ - test/dummy/config/initializers/inflections.rb
150
+ - test/dummy/config/initializers/mime_types.rb
151
+ - test/dummy/config/initializers/qunit-rails.rb
152
+ - test/dummy/config/initializers/secret_token.rb
153
+ - test/dummy/config/initializers/session_store.rb
154
+ - test/dummy/config/initializers/wrap_parameters.rb
155
+ - test/dummy/config/locales/en.yml
156
+ - test/dummy/config/routes.rb
157
+ - test/dummy/log/.gitkeep
158
+ - test/dummy/public/404.html
159
+ - test/dummy/public/422.html
160
+ - test/dummy/public/500.html
161
+ - test/dummy/public/favicon.ico
162
+ - test/dummy/script/rails
163
+ - test/javascripts/all_tests.js.coffee
164
+ - test/javascripts/test_helper.js.coffee
165
+ - test/javascripts/tests/base_test.js.coffee
166
+ - test/javascripts/tests/helpers/asset_tag_test.js.coffee
167
+ - test/javascripts/tests/helpers/number_test.js.coffee
168
+ - test/javascripts/tests/helpers/record_tag_test.js.coffee
169
+ - test/javascripts/tests/helpers/tag_test.js.coffee
170
+ - test/javascripts/tests/helpers/url_test.js.coffee
171
+ - test/javascripts/tests/helpers_test.js.coffee
172
+ - test/javascripts/tests/improves/i18n-lite_test.js.coffee
173
+ - test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee
174
+ - test/stylesheets/test_helper.css
83
175
  - ultimate-base.gemspec
84
176
  homepage: http://github.com/KODerFunk/ultimate-base
85
177
  licenses: []
@@ -96,9 +188,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
188
  required_rubygems_version: !ruby/object:Gem::Requirement
97
189
  none: false
98
190
  requirements:
99
- - - ! '>='
191
+ - - ! '>'
100
192
  - !ruby/object:Gem::Version
101
- version: '0'
193
+ version: 1.3.1
102
194
  requirements: []
103
195
  rubyforge_project: ultimate-base
104
196
  rubygems_version: 1.8.10
@@ -1,57 +0,0 @@
1
- # TODO bus as class
2
- # TODO may be, settable maxInstances
3
- # TODO tree presentative logic in eventName syntax provided by ':', '.', ...
4
- # require underscore
5
-
6
- class EventBus
7
-
8
- events: {}
9
-
10
- #constructor: ->
11
-
12
- bind: (eventName, callback) ->
13
- if @events[eventName]
14
- @events[eventName].push callback
15
- else
16
- @events[eventName] = [callback]
17
- true
18
-
19
- # TODO simplify logic
20
- unbind: (eventName, callback = null) ->
21
- if eventName
22
- if eventsHeap = @events[eventName]
23
- if callback
24
- i = _.indexOf eventsHeap, callback
25
- if i >= 0
26
- eventsHeap.splice i, 1
27
- true
28
- else
29
- false
30
- else
31
- delete @events[eventName]
32
- else
33
- false
34
- else
35
- if callback
36
- # TODO return boolean
37
- @unbind eventName, callback for eventName, eventsHeap of @events
38
- else
39
- false
40
-
41
- has: (eventName, callback = null) ->
42
- if eventsHeap = @events[eventName]
43
- if callback
44
- _.include eventsHeap, callback
45
- else
46
- true
47
- else
48
- false
49
-
50
- trigger: (eventName, callbackArguments...) ->
51
- for callback in @events[eventName] or []
52
- callback.apply(@, callbackArguments)
53
-
54
-
55
-
56
- # transitional instance
57
- @bus = new EventBus
@@ -1,154 +0,0 @@
1
- //pluralize(9) // "9th"
2
- //'dog'.pluralize() // "dogs"
3
- //'dog'.pluralize(4) // "4 dogs"
4
- //'dog'.pluralize(2, 'dogs too many') // "2 dogs too many"
5
- //'dogs'.singularize() // "dog"
6
- //'dogs'.singularize(1) // "1 dog"
7
-
8
-
9
-
10
- //Dogs suck! CATS FOREVER!
11
-
12
- Inflector = {
13
- Inflections: {
14
- plural: [
15
- [/(quiz)$/i, "$1zes" ],
16
- [/^(ox)$/i, "$1en" ],
17
- [/([m|l])ouse$/i, "$1ice" ],
18
- [/(matr|vert|ind)ix|ex$/i, "$1ices" ],
19
- [/(x|ch|ss|sh)$/i, "$1es" ],
20
- [/([^aeiouy]|qu)y$/i, "$1ies" ],
21
- [/(hive)$/i, "$1s" ],
22
- [/(?:([^f])fe|([lr])f)$/i, "$1$2ves"],
23
- [/sis$/i, "ses" ],
24
- [/([ti])um$/i, "$1a" ],
25
- [/(buffal|tomat)o$/i, "$1oes" ],
26
- [/(bu)s$/i, "$1ses" ],
27
- [/(alias|status)$/i, "$1es" ],
28
- [/(octop|vir)us$/i, "$1i" ],
29
- [/(ax|test)is$/i, "$1es" ],
30
- [/s$/i, "s" ],
31
- [/$/, "s" ]
32
- ],
33
- singular: [
34
- [/(quiz)zes$/i, "$1" ],
35
- [/(matr)ices$/i, "$1ix" ],
36
- [/(vert|ind)ices$/i, "$1ex" ],
37
- [/^(ox)en/i, "$1" ],
38
- [/(alias|status)es$/i, "$1" ],
39
- [/(octop|vir)i$/i, "$1us" ],
40
- [/(cris|ax|test)es$/i, "$1is" ],
41
- [/(shoe)s$/i, "$1" ],
42
- [/(o)es$/i, "$1" ],
43
- [/(bus)es$/i, "$1" ],
44
- [/([m|l])ice$/i, "$1ouse" ],
45
- [/(x|ch|ss|sh)es$/i, "$1" ],
46
- [/(m)ovies$/i, "$1ovie" ],
47
- [/(s)eries$/i, "$1eries"],
48
- [/([^aeiouy]|qu)ies$/i, "$1y" ],
49
- [/([lr])ves$/i, "$1f" ],
50
- [/(tive)s$/i, "$1" ],
51
- [/(hive)s$/i, "$1" ],
52
- [/([^f])ves$/i, "$1fe" ],
53
- [/(^analy)ses$/i, "$1sis" ],
54
- [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, "$1$2sis"],
55
- [/([ti])a$/i, "$1um" ],
56
- [/(n)ews$/i, "$1ews" ],
57
- [/s$/i, "" ]
58
- ],
59
- irregular: [
60
- ['move', 'moves' ],
61
- ['sex', 'sexes' ],
62
- ['child', 'children'],
63
- ['man', 'men' ],
64
- ['person', 'people' ]
65
- ],
66
- uncountable: [
67
- "sheep",
68
- "fish",
69
- "series",
70
- "species",
71
- "money",
72
- "rice",
73
- "information",
74
- "equipment"
75
- ]
76
- },
77
- ordinalize: function(number) {
78
- if (11 <= parseInt(number) % 100 && parseInt(number) % 100 <= 13) {
79
- return number + "th";
80
- } else {
81
- switch (parseInt(number) % 10) {
82
- case 1: return number + "st";
83
- case 2: return number + "nd";
84
- case 3: return number + "rd";
85
- default: return number + "th";
86
- }
87
- }
88
- },
89
- pluralize: function(word) {
90
- for (var i = 0; i < Inflector.Inflections.uncountable.length; i++) {
91
- var uncountable = Inflector.Inflections.uncountable[i];
92
- if (word.toLowerCase == uncountable) {
93
- return uncountable;
94
- }
95
- }
96
- for (var i = 0; i < Inflector.Inflections.irregular.length; i++) {
97
- var singular = Inflector.Inflections.irregular[i][0];
98
- var plural = Inflector.Inflections.irregular[i][1];
99
- if ((word.toLowerCase == singular) || (word == plural)) {
100
- return plural;
101
- }
102
- }
103
- for (var i = 0; i < Inflector.Inflections.plural.length; i++) {
104
- var regex = Inflector.Inflections.plural[i][0];
105
- var replace_string = Inflector.Inflections.plural[i][1];
106
- if (regex.test(word)) {
107
- return word.replace(regex, replace_string);
108
- }
109
- }
110
- },
111
- singularize: function(word) {
112
- for (var i = 0; i < Inflector.Inflections.uncountable.length; i++) {
113
- var uncountable = Inflector.Inflections.uncountable[i];
114
- if (word.toLowerCase == uncountable) {
115
- return uncountable;
116
- }
117
- }
118
- for (var i = 0; i < Inflector.Inflections.irregular.length; i++) {
119
- var singular = Inflector.Inflections.irregular[i][0];
120
- var plural = Inflector.Inflections.irregular[i][1];
121
- if ((word.toLowerCase == singular) || (word == plural)) {
122
- return plural;
123
- }
124
- }
125
- for (var i = 0; i < Inflector.Inflections.singular.length; i++) {
126
- var regex = Inflector.Inflections.singular[i][0];
127
- var replace_string = Inflector.Inflections.singular[i][1];
128
- if (regex.test(word)) {
129
- return word.replace(regex, replace_string);
130
- }
131
- }
132
- }
133
- }
134
-
135
- function ordinalize(number) {
136
- return Inflector.ordinalize(number);
137
- }
138
-
139
- Object.extend(String.prototype, {
140
- pluralize: function(count, plural) {
141
- if (typeof count == 'undefined') {
142
- return Inflector.pluralize(this);
143
- } else {
144
- return count + ' ' + (1 == parseInt(count) ? this : plural || Inflector.pluralize(this));
145
- }
146
- },
147
- singularize: function(count) {
148
- if (typeof count == 'undefined') {
149
- return Inflector.singularize(this);
150
- } else {
151
- return count + " " + Inflector.singularize(this);
152
- }
153
- }
154
- });
@@ -1,63 +0,0 @@
1
- @compact = (arr) ->
2
- @deprecate 'compact(arr)', '_.compact arr'
3
- r = []
4
- for e in arr
5
- r.push e if e?
6
- r
7
-
8
- @reverse = (arr) =>
9
- @deprecate 'reverse(arr)', 'arr.reverse()'
10
- _isString = _.isString arr
11
- return arr unless _isString or $.isArray arr
12
- if _isString then @warning 'reverse(someString)', 'STOP USE IT!' else arr.reverse()
13
-
14
- ###
15
- Split array into slices of <number> elements.
16
- Map result by iterator if last given.
17
-
18
- >>> eachSlice [1..10], 3, (a) -> cout a
19
- [1, 2, 3]
20
- [4, 5, 6]
21
- [7, 8, 9]
22
- [10]
23
- ###
24
- @eachSlice = (array, number, iterator = null) =>
25
- size = array.length
26
- index = 0
27
- slices = []
28
- while index < size
29
- nextIndex = index + number
30
- slices.push array.slice(index, nextIndex)
31
- index = nextIndex
32
- if _.isFunction iterator then _.map slices, iterator else slices
33
-
34
- ###
35
- Splits or iterates over the array in groups of size +number+,
36
- padding any remaining slots with +fill_with+ unless it is +false+.
37
-
38
- >>> inGroupsOf [1..7], 3, (group) -> cout group
39
- [1, 2, 3]
40
- [4, 5, 6]
41
- [7, null, null]
42
-
43
- >>> inGroupsOf [1..3], 2, '&nbsp;', (group) -> cout group
44
- [1, 2]
45
- [3, "&nbsp;"]
46
-
47
- >>> inGroupsOf [1..3], 2, false, (group) -> cout group
48
- [1, 2]
49
- [3]
50
- ###
51
- @inGroupsOf = (array, number, fillWith = null) =>
52
- return array if number < 1
53
- iterator = @blockGiven arguments
54
- unless fillWith is false
55
- # size % number gives how many extra we have;
56
- # subtracting from number gives how many to add;
57
- # modulo number ensures we don't add group of just fill.
58
- padding = (number - array.length % number) % number
59
- if padding
60
- fillWith = null if _.isFunction fillWith
61
- array = array.slice()
62
- array.push fillWith while padding-- > 0
63
- @eachSlice array, number, iterator
@@ -1,73 +0,0 @@
1
- # The DOM class convention is to use the singular form of an object or class. Examples:
2
- #
3
- # dom_class(post) # => "post"
4
- # dom_class(Person) # => "person"
5
- #
6
- # If you need to address multiple instances of the same class in the same view, you can prefix the dom_class:
7
- #
8
- # dom_class(post, :edit) # => "edit_post"
9
- # dom_class(Person, :edit) # => "edit_person"
10
- @dom_class = (record_or_class, prefix = "") ->
11
- singular = _.singular(record_or_class)
12
- if prefix then "#{prefix}_#{singular}" else singular
13
-
14
- # The DOM id convention is to use the singular form of an object or class with the id following an underscore.
15
- # If no id is found, prefix with "new_" instead. Examples:
16
- #
17
- # dom_id(Post.find(45)) # => "post_45"
18
- # dom_id(Post.new) # => "new_post"
19
- #
20
- # If you need to address multiple instances of the same class in the same view, you can prefix the dom_id:
21
- #
22
- # dom_id(Post.find(45), :edit) # => "edit_post_45"
23
- # TODO sync with rorId and ror_id
24
- @dom_id = (record, prefix = "") =>
25
- if record_id = @record_key_for_dom_id(record)
26
- "#{@dom_class(record, prefix)}_#{record_id}"
27
- else
28
- @dom_class(record, prefix or "new")
29
-
30
- @record_key_for_dom_id = (record) ->
31
- record = record.to_model() if _.isFunction(record.to_model)
32
- key = record.to_key()
33
- if key then key.join("_") else key
34
-
35
- # TODO more zen features: +, *x, {content}
36
- # TODO cache
37
- @selectorToHtml = (selector) =>
38
- if matches = selector.match(/^[\s>]*([\w\.]+)(.*)$/)
39
- selector = matches[1]
40
- continuation = matches[2]
41
- classes = selector.split(".")
42
- tag_name = classes.shift() or "div"
43
- html_options = {}
44
- html_options["class"] = classes.join(" ") if classes.length
45
- if continuation
46
- @content_tag(tag_name, @selectorToHtml(continuation), html_options)
47
- else
48
- @tag(tag_name, html_options)
49
- else
50
- ""
51
-
52
- @concat_class = =>
53
- @warning "concat_class()", "refactoring with underscore"
54
- @uniq(@compact(arguments).join(" ").split(/\s+/)).join(" ")
55
-
56
- @html_options_to_s = (html_options, prefix = "") =>
57
- if $.isPlainObject(html_options)
58
- prefix = "#{prefix}-" if prefix
59
- (for key, value of html_options when typeof value isnt "undefined"
60
- if $.isPlainObject(value) then @html_options_to_s(value, "#{prefix}#{key}") else " #{prefix}#{key}=\"#{value}\""
61
- ).join("")
62
- else
63
- ""
64
-
65
- @tag = (tag_name, html_options = {}) =>
66
- "<#{tag_name}#{@html_options_to_s html_options} />"
67
-
68
- @content_tag = (tag_name, content, html_options) =>
69
- "<#{tag_name}#{@html_options_to_s html_options}>#{content}</#{tag_name}>"
70
-
71
- @link_to = (body, url, html_options = {}) =>
72
- html_options["href"] = url
73
- @content_tag("a", body, html_options)
@@ -1,70 +0,0 @@
1
- @Ultimate =
2
- Proto: {}
3
- Widgets: {}
4
- LazyWidgets: {}
5
- Observers: {}
6
- Plugins: {}
7
-
8
- scopes: {}
9
-
10
- widgetsHeap: []
11
-
12
- initialize: ->
13
- @scopes =
14
- Proto : @Proto
15
- Widgets : @Widgets
16
- LazyWidgets : @LazyWidgets
17
- Observers : @Observers
18
- Plugins : @Plugins
19
- @distributeClassNames()
20
-
21
- # get last instance by default
22
- getWidgetByName: (widgetClassName, instanceIndex = -1) ->
23
- if widgetClass = @Widgets[widgetClassName] or @LazyWidgets[widgetClassName]
24
- if _.isArray(widgetClass.instances)
25
- instanceIndex += widgetClass.instances.length if instanceIndex < 0
26
- widgetClass.instances[instanceIndex]
27
-
28
- gcWidgets: ->
29
- newHeap = []
30
- garbage = []
31
- for widget in @widgetsHeap
32
- if widget.isGarbage()
33
- instances = widget.constructor.instances
34
- i = _.indexOf instances, widget
35
- instances.splice i, 1 if i >= 0
36
- garbage.push widget
37
- else
38
- widget.heapIndex = newHeap.push widget
39
- @widgetsHeap = newHeap if garbage.length
40
- garbage
41
-
42
- isWidget: (candidate) ->
43
- candidate instanceof @Proto.Widget
44
-
45
- isWidgetClass: (candidate) ->
46
- (candidate::) instanceof @Proto.Widget
47
-
48
- # This is the best way to create an instance of the widget.
49
- createWidget: (widgetClass, jContainer, options = {}) ->
50
- widget = null
51
- if widgetClass.canCreateInstance()
52
- unless jContainer.hasWidget widgetClass
53
- widget = new widgetClass jContainer, options
54
- widget.heapIndex = @widgetsHeap.push widget
55
- else
56
- warning "Ultimate.createWidget() can't create widget on passed jContainer, because it already has widget #{widgetClass.className}"
57
- else
58
- warning "Ultimate.createWidget() can't create widget, because blocked by widgetClass.canCreateInstance()"
59
- widget
60
-
61
- distributeClassNames: (widgetClassesOrScopes = @scopes, deep = true) ->
62
- if deep
63
- for scopeName, scope of widgetClassesOrScopes
64
- @distributeClassNames scope, false
65
- else
66
- for widgetName, widgetClass of widgetClassesOrScopes
67
- widgetClass.className = widgetName
68
-
69
- #
70
- _.bindAll Ultimate