aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Goce <carlosgoce@gmail.com>2015-01-22 22:40:08 +0100
committerCarlos Goce <carlosgoce@gmail.com>2015-01-22 22:40:08 +0100
commite8341ef9884861fc24040d4f219a271ae1022722 (patch)
tree191cc7162a6ca5596ceef95977a3f0aa025e3b37
parentfa4e80e193d541d3b7744971ac92f4835d8a9188 (diff)
downloadpdf-calendars-e8341ef9884861fc24040d4f219a271ae1022722.tar.gz
pdf-calendars-e8341ef9884861fc24040d4f219a271ae1022722.tar.bz2
pdf-calendars-e8341ef9884861fc24040d4f219a271ae1022722.zip
Add class calendar, rspec, locales for calendar and updated Gemfile
-rw-r--r--Gemfile5
-rw-r--r--Gemfile.lock29
-rw-r--r--calendar.rb22
-rw-r--r--config/locales/en.yml206
-rw-r--r--config/locales/es.yml192
-rw-r--r--lib/carlosgoce/calendar.rb7
-rw-r--r--spec/calendar_spec.rb14
7 files changed, 469 insertions, 6 deletions
diff --git a/Gemfile b/Gemfile
index 9e1b0ff..c95c1ab 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,7 @@
source 'https://rubygems.org'
gem 'prawn', '~> 1.3.0'
-gem 'rake', '~> 10.4.2' \ No newline at end of file
+gem 'prawn-table', '~> 0.2.1'
+gem 'rake', '~> 10.4.2'
+gem 'activesupport', '~> 4.2.0'
+gem 'rspec', '~> 3.1.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index a070371..c92cb67 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,16 +1,45 @@
GEM
remote: https://rubygems.org/
specs:
+ activesupport (4.2.0)
+ i18n (~> 0.7)
+ json (~> 1.7, >= 1.7.7)
+ minitest (~> 5.1)
+ thread_safe (~> 0.3, >= 0.3.4)
+ tzinfo (~> 1.1)
+ diff-lcs (1.2.5)
+ i18n (0.7.0)
+ json (1.8.1)
+ minitest (5.5.0)
pdf-core (0.4.0)
prawn (1.3.0)
pdf-core (~> 0.4.0)
ttfunk (~> 1.4.0)
+ prawn-table (0.2.1)
rake (10.4.2)
+ rspec (3.1.0)
+ rspec-core (~> 3.1.0)
+ rspec-expectations (~> 3.1.0)
+ rspec-mocks (~> 3.1.0)
+ rspec-core (3.1.7)
+ rspec-support (~> 3.1.0)
+ rspec-expectations (3.1.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.1.0)
+ rspec-mocks (3.1.3)
+ rspec-support (~> 3.1.0)
+ rspec-support (3.1.2)
+ thread_safe (0.3.4)
ttfunk (1.4.0)
+ tzinfo (1.2.2)
+ thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
+ activesupport (~> 4.2.0)
prawn (~> 1.3.0)
+ prawn-table (~> 0.2.1)
rake (~> 10.4.2)
+ rspec (~> 3.1.0)
diff --git a/calendar.rb b/calendar.rb
index 8ebe619..efb315c 100644
--- a/calendar.rb
+++ b/calendar.rb
@@ -1,9 +1,27 @@
require 'rubygems'
require 'bundler/setup'
require 'prawn'
+require 'prawn/table'
+require 'active_support/core_ext/time'
+require 'active_support/core_ext/date'
+locales_folder = 'config/locales'
output_folder = 'output'
+# Para obtener el primer día de la semana
+d = Date.today
+puts d.beginning_of_week
+
+I18n.load_path = Dir["#{locales_folder}/*.yml"]
+I18n.backend.load_translations
+I18n.locale = 'es' || I18n.default_locale
+
Prawn::Document.generate("#{output_folder}/calendar.pdf") do
- text 'Hello World'
-end \ No newline at end of file
+ (1..12).each do |month|
+ text I18n.t('date.month_names')[month]
+ data = (1..Time.days_in_month(month)).to_a.each_slice(7).to_a
+ table data, :cell_style => {:align => :center}
+ end
+end
+
+# `open #{output_folder}/calendar.pdf` \ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 35ceacf..e1de9ab 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,4 +1,204 @@
-es:
+en:
date:
- month_names: [~, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre]
- abbr_month_names: [~, Ene, Feb, Mar, Abr, May, Jun, Jul, Ago, Sep, Oct, Nov, Dic] \ No newline at end of file
+ abbr_day_names:
+ - Sun
+ - Mon
+ - Tue
+ - Wed
+ - Thu
+ - Fri
+ - Sat
+ abbr_month_names:
+ -
+ - Jan
+ - Feb
+ - Mar
+ - Apr
+ - May
+ - Jun
+ - Jul
+ - Aug
+ - Sep
+ - Oct
+ - Nov
+ - Dec
+ day_names:
+ - Sunday
+ - Monday
+ - Tuesday
+ - Wednesday
+ - Thursday
+ - Friday
+ - Saturday
+ formats:
+ default: ! '%Y-%m-%d'
+ long: ! '%B %d, %Y'
+ short: ! '%b %d'
+ month_names:
+ -
+ - January
+ - February
+ - March
+ - April
+ - May
+ - June
+ - July
+ - August
+ - September
+ - October
+ - November
+ - December
+ order:
+ - :year
+ - :month
+ - :day
+ datetime:
+ distance_in_words:
+ about_x_hours:
+ one: about 1 hour
+ other: about %{count} hours
+ about_x_months:
+ one: about 1 month
+ other: about %{count} months
+ about_x_years:
+ one: about 1 year
+ other: about %{count} years
+ almost_x_years:
+ one: almost 1 year
+ other: almost %{count} years
+ half_a_minute: half a minute
+ less_than_x_minutes:
+ one: less than a minute
+ other: less than %{count} minutes
+ less_than_x_seconds:
+ one: less than 1 second
+ other: less than %{count} seconds
+ over_x_years:
+ one: over 1 year
+ other: over %{count} years
+ x_days:
+ one: 1 day
+ other: ! '%{count} days'
+ x_minutes:
+ one: 1 minute
+ other: ! '%{count} minutes'
+ x_months:
+ one: 1 month
+ other: ! '%{count} months'
+ x_seconds:
+ one: 1 second
+ other: ! '%{count} seconds'
+ prompts:
+ day: Day
+ hour: Hour
+ minute: Minute
+ month: Month
+ second: Seconds
+ year: Year
+ errors:
+ format: ! '%{attribute} %{message}'
+ messages:
+ accepted: must be accepted
+ blank: can't be blank
+ present: must be blank
+ confirmation: ! "doesn't match %{attribute}"
+ empty: can't be empty
+ equal_to: must be equal to %{count}
+ even: must be even
+ exclusion: is reserved
+ greater_than: must be greater than %{count}
+ greater_than_or_equal_to: must be greater than or equal to %{count}
+ inclusion: is not included in the list
+ invalid: is invalid
+ less_than: must be less than %{count}
+ less_than_or_equal_to: must be less than or equal to %{count}
+ not_a_number: is not a number
+ not_an_integer: must be an integer
+ odd: must be odd
+ record_invalid: ! 'Validation failed: %{errors}'
+ restrict_dependent_destroy:
+ one: "Cannot delete record because a dependent %{record} exists"
+ many: "Cannot delete record because dependent %{record} exist"
+ taken: has already been taken
+ too_long:
+ one: is too long (maximum is 1 character)
+ other: is too long (maximum is %{count} characters)
+ too_short:
+ one: is too short (minimum is 1 character)
+ other: is too short (minimum is %{count} characters)
+ wrong_length:
+ one: is the wrong length (should be 1 character)
+ other: is the wrong length (should be %{count} characters)
+ other_than: "must be other than %{count}"
+ template:
+ body: ! 'There were problems with the following fields:'
+ header:
+ one: 1 error prohibited this %{model} from being saved
+ other: ! '%{count} errors prohibited this %{model} from being saved'
+ helpers:
+ select:
+ prompt: Please select
+ submit:
+ create: Create %{model}
+ submit: Save %{model}
+ update: Update %{model}
+ number:
+ currency:
+ format:
+ delimiter: ! ','
+ format: ! '%u%n'
+ precision: 2
+ separator: .
+ significant: false
+ strip_insignificant_zeros: false
+ unit: $
+ format:
+ delimiter: ! ','
+ precision: 3
+ separator: .
+ significant: false
+ strip_insignificant_zeros: false
+ human:
+ decimal_units:
+ format: ! '%n %u'
+ units:
+ billion: Billion
+ million: Million
+ quadrillion: Quadrillion
+ thousand: Thousand
+ trillion: Trillion
+ unit: ''
+ format:
+ delimiter: ''
+ precision: 3
+ significant: true
+ strip_insignificant_zeros: true
+ storage_units:
+ format: ! '%n %u'
+ units:
+ byte:
+ one: Byte
+ other: Bytes
+ gb: GB
+ kb: KB
+ mb: MB
+ tb: TB
+ percentage:
+ format:
+ delimiter: ''
+ format: "%n%"
+ precision:
+ format:
+ delimiter: ''
+ support:
+ array:
+ last_word_connector: ! ', and '
+ two_words_connector: ! ' and '
+ words_connector: ! ', '
+ time:
+ am: am
+ formats:
+ default: ! '%a, %d %b %Y %H:%M:%S %z'
+ long: ! '%B %d, %Y %H:%M'
+ short: ! '%d %b %H:%M'
+ pm: pm
diff --git a/config/locales/es.yml b/config/locales/es.yml
index e69de29..5e17e0a 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -0,0 +1,192 @@
+es:
+ date:
+ abbr_day_names:
+ - dom
+ - lun
+ - mar
+ - mié
+ - jue
+ - vie
+ - sáb
+ abbr_month_names:
+ -
+ - ene
+ - feb
+ - mar
+ - abr
+ - may
+ - jun
+ - jul
+ - ago
+ - sep
+ - oct
+ - nov
+ - dic
+ day_names:
+ - domingo
+ - lunes
+ - martes
+ - miércoles
+ - jueves
+ - viernes
+ - sábado
+ formats:
+ default: ! '%d/%m/%Y'
+ long: ! '%d de %B de %Y'
+ short: ! '%d de %b'
+ month_names:
+ -
+ - enero
+ - febrero
+ - marzo
+ - abril
+ - mayo
+ - junio
+ - julio
+ - agosto
+ - septiembre
+ - octubre
+ - noviembre
+ - diciembre
+ order:
+ - :day
+ - :month
+ - :year
+ datetime:
+ distance_in_words:
+ about_x_hours:
+ one: alrededor de 1 hora
+ other: alrededor de %{count} horas
+ about_x_months:
+ one: alrededor de 1 mes
+ other: alrededor de %{count} meses
+ about_x_years:
+ one: alrededor de 1 año
+ other: alrededor de %{count} años
+ almost_x_years:
+ one: casi 1 año
+ other: casi %{count} años
+ half_a_minute: medio minuto
+ less_than_x_minutes:
+ one: menos de 1 minuto
+ other: menos de %{count} minutos
+ less_than_x_seconds:
+ one: menos de 1 segundo
+ other: menos de %{count} segundos
+ over_x_years:
+ one: más de 1 año
+ other: más de %{count} años
+ x_days:
+ one: 1 día
+ other: ! '%{count} días'
+ x_minutes:
+ one: 1 minuto
+ other: ! '%{count} minutos'
+ x_months:
+ one: 1 mes
+ other: ! '%{count} meses'
+ x_seconds:
+ one: 1 segundo
+ other: ! '%{count} segundos'
+ prompts:
+ day: Día
+ hour: Hora
+ minute: Minutos
+ month: Mes
+ second: Segundos
+ year: Año
+ errors:
+ format: ! '%{attribute} %{message}'
+ messages:
+ accepted: debe ser aceptado
+ blank: no puede estar en blanco
+ confirmation: no coincide
+ empty: no puede estar vacío
+ equal_to: debe ser igual a %{count}
+ even: debe ser par
+ exclusion: está reservado
+ greater_than: debe ser mayor que %{count}
+ greater_than_or_equal_to: debe ser mayor que o igual a %{count}
+ inclusion: no está incluido en la lista
+ invalid: no es válido
+ less_than: debe ser menor que %{count}
+ less_than_or_equal_to: debe ser menor que o igual a %{count}
+ not_a_number: no es un número
+ not_an_integer: debe ser un entero
+ odd: debe ser impar
+ record_invalid: ! 'La validación falló: %{errors}'
+ taken: ya está en uso
+ too_long: es demasiado largo (%{count} caracteres máximo)
+ too_short: es demasiado corto (%{count} caracteres mínimo)
+ wrong_length: no tiene la longitud correcta (%{count} caracteres exactos)
+ template:
+ body: ! 'Se encontraron problemas con los siguientes campos:'
+ header:
+ one: No se pudo guardar este/a %{model} porque se encontró 1 error
+ other: No se pudo guardar este/a %{model} porque se encontraron %{count} errores
+ helpers:
+ select:
+ prompt: Por favor seleccione
+ submit:
+ create: Crear %{model}
+ submit: Guardar %{model}
+ update: Actualizar %{model}
+ number:
+ currency:
+ format:
+ delimiter: .
+ format: ! '%n %u'
+ precision: 2
+ separator: ! ','
+ significant: false
+ strip_insignificant_zeros: false
+ unit: €
+ format:
+ delimiter: .
+ precision: 3
+ separator: ! ','
+ significant: false
+ strip_insignificant_zeros: false
+ human:
+ decimal_units:
+ format: ! '%n %u'
+ units:
+ billion: mil millones
+ million: millón
+ quadrillion: mil billones
+ thousand: mil
+ trillion: billón
+ unit: ''
+ format:
+ delimiter: ''
+ precision: 1
+ significant: true
+ strip_insignificant_zeros: true
+ storage_units:
+ format: ! '%n %u'
+ units:
+ byte:
+ one: Byte
+ other: Bytes
+ gb: GB
+ kb: KB
+ mb: MB
+ tb: TB
+ percentage:
+ format:
+ delimiter: ''
+ precision:
+ format:
+ delimiter: ''
+ support:
+ array:
+ last_word_connector: ! ', y '
+ two_words_connector: ! ' y '
+ words_connector: ! ', '
+ time:
+ am: am
+ formats:
+ default: ! '%A, %d de %B de %Y %H:%M:%S %z'
+ long: ! '%d de %B de %Y %H:%M'
+ short: ! '%d de %b %H:%M'
+ pm: pm
diff --git a/lib/carlosgoce/calendar.rb b/lib/carlosgoce/calendar.rb
new file mode 100644
index 0000000..cb77325
--- /dev/null
+++ b/lib/carlosgoce/calendar.rb
@@ -0,0 +1,7 @@
+module CarlosGoce
+ class Calendar
+ def to_h
+ {enero: []}
+ end
+ end
+end \ No newline at end of file
diff --git a/spec/calendar_spec.rb b/spec/calendar_spec.rb
new file mode 100644
index 0000000..a543dbe
--- /dev/null
+++ b/spec/calendar_spec.rb
@@ -0,0 +1,14 @@
+require 'rspec'
+require_relative '../lib/carlosgoce/calendar'
+
+describe 'Calendar' do
+ before(:each) do
+ @calendar = CarlosGoce::Calendar.new
+ end
+
+ describe 'Return months and days of given year' do
+ it 'localize month names' do
+ expect(@calendar.to_h.keys.first.to_s).to eq('enero')
+ end
+ end
+end \ No newline at end of file