Permalink
Browse files

Removing javascript compiler stuff, which has been moved to twitter-c…

…ldr-js
  • Loading branch information...
Cameron Dutro
Cameron Dutro committed Aug 21, 2012
1 parent d555c15 commit 1cfb0d919cc3dbd62f49badaa5737bc881a981ee
Showing with 3 additions and 1,881 deletions.
  1. +1 −29 README.md
  2. +0 −25 Rakefile
  3. +0 −1 js/.jasmine-headless-webkit
  4. +0 −42 js/lib/compiler.rb
  5. +0 −14 js/lib/mustache/bundle.coffee
  6. +0 −240 js/lib/mustache/calendars/datetime.coffee
  7. +0 −52 js/lib/mustache/calendars/timespan.coffee
  8. +0 −179 js/lib/mustache/numbers/numbers.coffee
  9. +0 −14 js/lib/mustache/plurals/rules.coffee
  10. +0 −27 js/lib/mustache/shared/currencies.coffee
  11. +0 −18 js/lib/renderers/base.rb
  12. +0 −18 js/lib/renderers/bundle.rb
  13. +0 −34 js/lib/renderers/calendars/datetime_renderer.rb
  14. +0 −39 js/lib/renderers/calendars/timespan_renderer.rb
  15. +0 −31 js/lib/renderers/numbers/numbers_renderer.rb
  16. +0 −93 js/lib/renderers/plurals/rules/plural_rules_compiler.rb
  17. +0 −26 js/lib/renderers/plurals/rules/plural_rules_renderer.rb
  18. +0 −23 js/lib/renderers/shared/currencies_renderer.rb
  19. +0 −87 js/lib/twitter_cldr_js.rb
  20. +0 −418 js/spec/js/calendars/datetime_spec.js
  21. +0 −91 js/spec/js/calendars/timespan_spec.js
  22. +0 −34 js/spec/js/numbers/currency_spec.js
  23. +0 −24 js/spec/js/numbers/decimal_spec.js
  24. +0 −23 js/spec/js/numbers/helpers/fraction_spec.js
  25. +0 −100 js/spec/js/numbers/helpers/integer_spec.js
  26. +0 −70 js/spec/js/numbers/number_spec.js
  27. +0 −22 js/spec/js/numbers/percent_spec.js
  28. +0 −28 js/spec/js/plurals/plural_rules_spec.js
  29. +0 −8 js/spec/js/support/jasmine.yml
  30. +0 −56 js/spec/rb/renderers/plurals/plural_rules_compiler_spec.rb
  31. +0 −13 js/spec/rb/spec_helper.rb
  32. +2 −2 twitter_cldr.gemspec
View
@@ -512,35 +512,7 @@ Tests are written in RSpec using RR as the mocking framework.
## JavaScript Support
-TwitterCLDR currently supports localization of dates and times in JavaScript. More awesome features are coming soon. See [http://github.com/twitter/twitter-cldr-js](http://github.com/twitter/twitter-cldr-js) for details.
-
-### Generating the JavaScript
-
-You can automatically generate the JavaScript version of TwitterCLDR using this Rubygem. Here's the one-liner:
-
-`bundle exec rake js:build OUTPUT_DIR=/path/to/desired/output/location`
-
-If you'd like to customize the generated output further, you'll need to require the `TwitterCldr::Js` namespace. You can choose the locales to export and whether to export a minified version alongside the full version for each locale.
-
-```ruby
-require 'twitter_cldr'
-
-TwitterCldr.require_js # require JavaScript environment
-TwitterCldr::Js.output_dir = "/path/to/output/location"
-TwitterCldr::Js.make(:locales => [:de, :sv, :ja, :ar], # generate files for German, Swedish,
- :minify => true) # Japanese, and Arabic
-TwitterCldr::Js.install # copy files to output directory
-```
-
-### Running Tests (JS)
-
-A JavaScript test suite comes with twitter-cldr-rb. You'll need to install the Qt libs to be able to run the suite, as it uses [jasmine](https://github.com/pivotal/jasmine-gem) and [jasmine-headless-webkit](http://johnbintz.github.com/jasmine-headless-webkit/).
-
-1. Install qt (eg. `brew install qt`, `sudo apt-get install qt4`, etc)
-2. Run `bundle`
-3. Run `bundle exec rake js:test`
-
-The tests are located in `js/spec` and look similar to RSpec tests.
+TwitterCLDR currently supports localization of dates and times in JavaScript via the twitter-cldr-js gem. More awesome features are coming soon. See [http://github.com/twitter/twitter-cldr-js](http://github.com/twitter/twitter-cldr-js) for details.
## Authors
View
@@ -113,28 +113,3 @@ namespace :update do
TwitterCldr::Resources::CanonicalCompositionsUpdater.new('./resources/unicode_data').update
end
end
-
-namespace :js do
- desc 'Build JS files'
- task :build do
- TwitterCldr.require_js
- FileUtils.mkdir_p(TwitterCldr::Js.build_dir)
- TwitterCldr::Js.output_dir = File.expand_path(ENV["OUTPUT_DIR"])
- TwitterCldr::Js.make(:locales => TwitterCldr.supported_locales)
- TwitterCldr::Js.install
- end
-
- desc 'Run JS specs'
- task :test do
- TwitterCldr.require_js
- FileUtils.mkdir_p(TwitterCldr::Js.build_dir)
- TwitterCldr::Js.make(:locales => [:en])
- puts "Running JavaScript tests (Jasmine)..."
- TwitterCldr::Js.test
- FileUtils.rm_rf(TwitterCldr::Js.build_dir)
- puts "\nRunning Ruby tests (RSpec)..."
- Dir.chdir(File.join(File.dirname(__FILE__), "js")) do
- Rake::Task["spec"].execute
- end
- end
-end
@@ -1 +0,0 @@
--j spec/js/support/jasmine.yml
View
@@ -1,42 +0,0 @@
-# encoding: UTF-8
-
-# Copyright 2012 Twitter, Inc
-# http://www.apache.org/licenses/LICENSE-2.0
-
-module TwitterCldr
- module Js
- class Compiler
- def initialize(options = {})
- @locales = options[:locales] || TwitterCldr.supported_locales
- @features = options[:features] || renderers.keys
- end
-
- def compile
- @locales.each do |locale|
- contents = ""
-
- @features.each do |feature|
- renderer_const = renderers[feature]
- contents << renderer_const.new(:locale => locale).render if renderer_const
- end
-
- bundle = TwitterCldr::Js::Renderers::Bundle.new
- bundle[:contents] = contents
- yield CoffeeScript.compile(bundle.render, :bare => true), TwitterCldr.twitter_locale(locale) if block_given?
- end
- end
-
- private
-
- def renderers
- @renderers ||= {
- :plural_rules => TwitterCldr::Js::Renderers::PluralRules::PluralRulesRenderer,
- :timespan => TwitterCldr::Js::Renderers::Calendars::TimespanRenderer,
- :datetime => TwitterCldr::Js::Renderers::Calendars::DateTimeRenderer,
- :numbers => TwitterCldr::Js::Renderers::Numbers::NumbersRenderer,
- :currencies => TwitterCldr::Js::Renderers::Shared::CurrenciesRenderer
- }
- end
- end
- end
-end
@@ -1,14 +0,0 @@
-###
-// Copyright 2012 Twitter, Inc
-// http://www.apache.org/licenses/LICENSE-2.0
-
-// TwitterCLDR (JavaScript) v{{version}}
-// Authors: Cameron Dutro [@camertron]
- Kirill Lashuk [@KL_7]
- portions by Sven Fuchs [@svenfuchs]
-// Homepage: https://twitter.com
-// Description: Provides date, time, number, and list formatting functionality for various Twitter-supported locales in Javascript.
-###
-
-TwitterCldr = {}
-{{{contents}}}
@@ -1,240 +0,0 @@
-# Copyright 2012 Twitter, Inc
-# http://www.apache.org/licenses/LICENSE-2.0
-
-TwitterCldr.DateTimeFormatter = class DateTimeFormatter
- constructor: ->
- @tokens = `{{{tokens}}}`
- @calendar = `{{{calendar}}}`
- @weekday_keys = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
- @methods = # ignoring u, l, g, j, A
- 'G': 'era'
- 'y': 'year'
- 'Y': 'year_of_week_of_year'
- 'Q': 'quarter'
- 'q': 'quarter_stand_alone'
- 'M': 'month'
- 'L': 'month_stand_alone'
- 'w': 'week_of_year'
- 'W': 'week_of_month'
- 'd': 'day'
- 'D': 'day_of_month'
- 'F': 'day_of_week_in_month'
- 'E': 'weekday'
- 'e': 'weekday_local'
- 'c': 'weekday_local_stand_alone'
- 'a': 'period'
- 'h': 'hour'
- 'H': 'hour'
- 'K': 'hour'
- 'k': 'hour'
- 'm': 'minute'
- 's': 'second'
- 'S': 'second_fraction'
- 'z': 'timezone'
- 'Z': 'timezone'
- 'v': 'timezone_generic_non_location'
- 'V': 'timezone_metazone'
-
- format: (obj, options) ->
- format_token = (token) =>
- result = ""
-
- switch token.type
- when "pattern"
- return this.result_for_token(token, obj)
- else
- if token.value.length > 0 && token.value[0] == "'" && token.value[token.value.length - 1] == "'"
- return token.value.substring(1, token.value.length - 1)
- else
- return token.value
-
- tokens = this.get_tokens(obj, options)
- return (format_token(token) for token in tokens).join("")
-
- get_tokens: (obj, options) ->
- return @tokens[options.format || "date_time"][options.type || "default"]
-
- result_for_token: (token, date) ->
- return this[@methods[token.value[0]]](date, token.value, token.value.length)
-
- era: (date, pattern, length) ->
- switch length
- when 1, 2, 3
- choices = @calendar["eras"]["abbr"]
- else
- choices = @calendar["eras"]["name"]
-
- index = if (date.getFullYear() < 0) then 0 else 1
- return choices[index]
-
- year: (date, pattern, length) ->
- year = date.getFullYear().toString()
-
- if length == 2
- if year.length != 1
- year = year.slice(-2)
-
- if length > 1
- year = ("0000" + year).slice(-length)
-
- return year
-
- year_of_week_of_year: (date, pattern, length) ->
- throw 'not implemented'
-
- day_of_week_in_month: (date, pattern, length) -> # e.g. 2nd Wed in July
- throw 'not implemented'
-
- quarter: (date, pattern, length) ->
- # the bitwise OR is used here to truncate the decimal produced by the / 3
- quarter = ((date.getMonth() / 3) | 0) + 1
-
- switch length
- when 1
- return quarter.toString()
- when 2
- return ("0000" + quarter.toString()).slice(-length)
- when 3
- return @calendar.quarters.format.abbreviated[quarter]
- when 4
- return @calendar.quarters.format.wide[quarter]
-
- quarter_stand_alone: (date, pattern, length) ->
- quarter = (date.getMonth() - 1) / 3 + 1
-
- switch length
- when 1
- return quarter.toString()
- when 2
- return ("0000" + quarter.toString()).slice(-length)
- when 3
- throw 'not yet implemented (requires cldr\'s "multiple inheritance")'
- when 4
- throw 'not yet implemented (requires cldr\'s "multiple inheritance")'
- when 5
- return @calendar.quarters['stand-alone'].narrow[quarter]
-
- month: (date, pattern, length) ->
- month_str = (date.getMonth() + 1).toString()
-
- switch length
- when 1
- return month_str
- when 2
- return ("0000" + month_str).slice(-length)
- when 3
- return @calendar.months.format.abbreviated[month_str]
- when 4
- return @calendar.months.format.wide[month_str]
- when 5
- throw 'not yet implemented (requires cldr\'s "multiple inheritance")'
- else
- throw "Unknown date format"
-
- month_stand_alone: (date, pattern, length) ->
- switch length
- when 1
- return date.getMonth().toString()
- when 2
- return ("0000" + date.getMonth().toString()).slice(-length)
- when 3
- throw 'not yet implemented (requires cldr\'s "multiple inheritance")'
- when 4
- throw 'not yet implemented (requires cldr\'s "multiple inheritance")'
- when 5
- return @calendar.months['stand-alone'].narrow[date.month]
- else
- throw "Unknown date format"
-
- day: (date, pattern, length) ->
- switch length
- when 1
- return date.getDate().toString()
- when 2
- return ("0000" + date.getDate().toString()).slice(-length)
-
- weekday: (date, pattern, length) ->
- key = @weekday_keys[date.getDay()]
-
- switch length
- when 1, 2, 3
- return @calendar.days.format.abbreviated[key]
- when 4
- return @calendar.days.format.wide[key]
- when 5
- return @calendar.days['stand-alone'].narrow[key]
-
- weekday_local: (date, pattern, length) ->
- # "Like E except adds a numeric value depending on the local starting day of the week"
- # CLDR does not contain data as to which day is the first day of the week, so we will assume Monday (Ruby default)
- switch length
- when 1, 2
- day = date.getDay()
- return (if day == 0 then "7" else day.toString())
- else
- return this.weekday(date, pattern, length)
-
- weekday_local_stand_alone: (date, pattern, length) ->
- switch length
- when 1
- return this.weekday_local(date, pattern, length)
- else
- return this.weekday(date, pattern, length)
-
- period: (time, pattern, length) ->
- if time.getHours() > 11
- return @calendar.periods.format.wide["pm"]
- else
- return @calendar.periods.format.wide["am"]
-
- hour: (time, pattern, length) ->
- hour = time.getHours()
-
- switch pattern[0]
- when 'h'
- if hour > 12
- hour = hour - 12
- else if hour == 0
- hour = 12
- when 'K'
- if hour > 11
- hour = hour - 12
- when 'k'
- if hour == 0
- hour = 24
-
- if length == 1
- return hour.toString()
- else
- return ("000000" + hour.toString()).slice(-length)
-
- minute: (time, pattern, length) ->
- if length == 1
- return time.getMinutes().toString()
- else
- return ("000000" + time.getMinutes().toString()).slice(-length)
-
- second: (time, pattern, length) ->
- if length == 1
- return time.getSeconds().toString()
- else
- return ("000000" + time.getSeconds().toString()).slice(-length)
-
- second_fraction: (time, pattern, length) ->
- if length > 6
- throw 'can not use the S format with more than 6 digits'
-
- return ("000000" + Math.round(Math.pow(time.getMilliseconds() * 100.0, 6 - length)).toString()).slice(-length)
-
- timezone: (time, pattern, length) ->
- hours = ("00" + (time.getTimezoneOffset() / 60).toString()).slice(-2)
- minutes = ("00" + (time.getTimezoneOffset() % 60).toString()).slice(-2)
-
- switch length
- when 1, 2, 3
- return "-" + hours + ":" + minutes
- else
- return "UTC -" + hours + ":" + minutes
-
- timezone_generic_non_location: (time, pattern, length) ->
- throw 'not yet implemented (requires timezone translation data")'
Oops, something went wrong.

0 comments on commit 1cfb0d9

Please sign in to comment.