eventdb 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5581ae0b83f990cdd56b947c0b504fdf973435aa
4
- data.tar.gz: 71d16f477128f028f6db5a0703b1e656d2c20cce
3
+ metadata.gz: e654b4516eb35c7b99b568fc10b10fa9236d9886
4
+ data.tar.gz: 8e2b5920e684344fd7177f484783482efce0c859
5
5
  SHA512:
6
- metadata.gz: 153c35ffef9355d7624b7a4e828ea8f60abb4f44b9a899478806191ea75f71e1793ff86a25b777e5de7feaedb2a00ddfdf1c82efbcfe2226e51fdad91b86275e
7
- data.tar.gz: 2bc79006fcb71edb6301c686a1716aa5ee0dfca9b7c16a7365f6135fb64daa85891eccbf454971faa1b99cfc675a682be5361b6e6c577bfcb2fffe591e26c8f9
6
+ metadata.gz: e2055488d9f4f913557b59f6b01ecb28e5e84c88b24933443eb19c8148e46a9599b9f8ea5605baebdb308293ccff282817ec1c474a80438fc198ef5a990e77d0
7
+ data.tar.gz: afaeae0de077a297795e27e2ed19d8924caf2c1358ff4c1559c496609332da95db606ffc2227246dc7942f320b8eae8db23d54fadba42691b16bf83cc0e75289
data/Manifest.txt CHANGED
@@ -9,9 +9,9 @@ lib/eventdb/models.rb
9
9
  lib/eventdb/reader.rb
10
10
  lib/eventdb/schema.rb
11
11
  lib/eventdb/version.rb
12
- templates/CALENDAR.md.erb
13
12
  test/data/RUBY.md
14
13
  test/helper.rb
14
+ test/templates/RUBY.md.erb
15
15
  test/test_calendar.rb
16
16
  test/test_database.rb
17
17
  test/test_reader.rb
data/README.md CHANGED
@@ -21,10 +21,12 @@ See the [whatson project for more »](https://github.com/textkit/whatson)
21
21
  ## Usage
22
22
 
23
23
  ~~~
24
- r = EventDb::EventReader.from_url( "https://github.com/planetruby/awesome-events/raw/master/README.md" )
24
+ url = "https://github.com/planetruby/awesome-events/raw/master/README.md"
25
+
26
+ r = EventDb::EventReader.from_url( url )
25
27
  events = r.read
26
28
 
27
- db = EventDb::Database.new # note: by default uses in-memory SQLite database
29
+ db = EventDb::MemDatabase.new # note: use in-memory SQLite database
28
30
  db.add( events )
29
31
 
30
32
 
@@ -57,7 +59,7 @@ Upcoming Ruby Conferences:
57
59
 
58
60
  in 18d Brighton Ruby Conference, Mon Jul/20 (1d) @ Brighton, East Sussex › England (en) › Western Europe › Europe
59
61
  in 27d European Ruby Camp - eurucamp, Fri-Sun Jul/31-Aug/2 (3d) @ Berlin (Potsdam), Germany › Europe
60
- in 27d JRuby Conference Europe - JRubyConf EU, Fri Jul/31 (1d) @ Berlin (Potdam), Germany › Europe
62
+ in 27d JRuby Conference Europe - JRubyConf EU, Fri Jul/31 (1d) @ Berlin (Potsdam), Germany › Europe
61
63
  in 28d Burlington Ruby Conference, Sat+Sun Aug/1+2 (2d) @ Burlington, Vermont › New England › United States (us) › North America › America
62
64
  in 50d Madison+ Ruby, Fri+Sat Aug/21+22 (2d) @ Madison, Wisconsin › Great Lakes › United States (us) › North America › America
63
65
  in 61d Full Stack Fest - Barcelona Ruby Conference (BaRuCo) + Barcelona Future JS, Tue-Sat Sep/1-5 (5d) @ Barcelona, Catalonia › Spain / España (es) › Southern Europe › Europe
data/lib/eventdb.rb CHANGED
@@ -20,10 +20,10 @@ require 'logutils/activerecord'
20
20
  require 'eventdb/version' ## let version always go first
21
21
 
22
22
  require 'eventdb/schema'
23
- require 'eventdb/reader'
24
- require 'eventdb/calendar'
25
-
26
23
  require 'eventdb/models'
24
+
25
+ require 'eventdb/reader'
26
+ require 'eventdb/calendar' # note: depends (requires) models (first)
27
27
  require 'eventdb/database'
28
28
 
29
29
 
@@ -49,9 +49,10 @@ end # class EventCursor
49
49
 
50
50
  class EventCalendar
51
51
 
52
- def initialize( events )
53
- @events = events.sort { |l,r| r.start_date <=> l.start_date } ## sort events by date (newest first)
54
- @tmpl = File.read_utf8( "#{EventDb.root}/templates/CALENDAR.md.erb" )
52
+ include Models # e.g. lets you use Event instead of (EventDb::)Model::Event
53
+
54
+ def initialize( opts={} )
55
+ @events = opts[:events] || Event.order('start_date DESC') ## sort events by date (newest first)
55
56
  end
56
57
 
57
58
  def events
@@ -59,15 +60,19 @@ class EventCalendar
59
60
  EventCursor.new( @events )
60
61
  end
61
62
 
62
- def render
63
- ERB.new( @tmpl, nil, '<>' ).result( binding ) # <> omit newline for lines starting with <% and ending in %>
64
- end
63
+ def render( opts={} )
64
+ tmpl_path = opts[:template] || './templates/CALENDAR.md.erb'
65
+ tmpl = File.read_utf8( tmpl_path )
65
66
 
66
- def save( path = './CALENDAR.md' ) ## use (rename to) save_as - why? why not??
67
- File.open( path, 'w' ) do |f|
68
- f.write( render )
69
- end
67
+ ERB.new( tmpl, nil, '<>' ).result( binding ) # <> omit newline for lines starting with <% and ending in %>
70
68
  end
69
+
70
+ # def save( path = './CALENDAR.md' ) ## use (rename to) save_as - why? why not??
71
+ # File.open( path, 'w' ) do |f|
72
+ # f.write( render )
73
+ # end
74
+ # end
75
+
71
76
  end # class EventCalendar
72
77
 
73
78
  end # module EventDb
@@ -2,21 +2,26 @@
2
2
 
3
3
  module EventDb
4
4
 
5
- class Database
6
5
 
7
- def initialize
8
- ## connect
6
+ class DatabaseBase ## fix: rename to Database (see below)
7
+ def initialize( config={} )
8
+ @config = config
9
+ end
9
10
 
10
- ActiveRecord::Base.establish_connection( adapter: 'sqlite3',
11
- database: ':memory:' )
11
+ def connect
12
+ ActiveRecord::Base.establish_connection( @config )
13
+ end
12
14
 
13
- LogDb.create # add logs table
14
- ConfDb.create
15
-
15
+ def create
16
16
  CreateDb.new.up
17
17
  ConfDb::Model::Prop.create!( key: 'db.schema.event.version', value: VERSION )
18
18
  end
19
-
19
+
20
+ def create_all
21
+ LogDb.create # add logs table
22
+ ConfDb.create
23
+ create
24
+ end
20
25
 
21
26
  def add( events )
22
27
  events.each do |ev|
@@ -27,12 +32,13 @@ class Database
27
32
  title = $1
28
33
  puts " adding #{title} #{ev.start_date.year}, #{ev.date}"
29
34
  else
30
- puts "warn: cannot find event title in #{ev.title}"
35
+ puts "*** warn: cannot find event title in #{ev.title}"
31
36
  next # skip record; todo: issue error
32
37
  end
33
38
 
34
39
  Model::Event.create!(
35
40
  title: title,
41
+ text: ev.title, ### "full" title - incl. markdown links
36
42
  place: ev.place,
37
43
  date: ev.date,
38
44
  start_date: ev.start_date,
@@ -45,7 +51,27 @@ class Database
45
51
  end
46
52
  end
47
53
 
54
+ end ## class DatabaseBase
55
+
56
+
57
+ ## convenience class for in-memory (SQLite3) database
58
+
59
+ class Database < DatabaseBase ## fix: rename to MemDatabase or MemoryDatabase
60
+
61
+ def initialize
62
+ ## -- default to sqlite3 in-memory database
63
+ super( adapter: 'sqlite3',
64
+ database: ':memory:' )
65
+
66
+ ## step 1) (auto-)connect
67
+ connect
68
+ ## step 2) (auto-)migrate, that is, create tables, etc.
69
+ create_all # -- incl. props, logs tables etc.
70
+ end
71
+
48
72
  end # class Database
49
73
 
74
+ MemDatabase = Database ## note: start using MemDatabase today (will get renamed!)
75
+
50
76
  end # module EventDb
51
77
 
@@ -63,5 +63,7 @@ class Event < ActiveRecord::Base
63
63
  end # class Event
64
64
 
65
65
  end # module Model
66
+
67
+ Models = Model ## note: add conveniene shortcut for models
66
68
  end # module EventDb
67
69
 
@@ -8,7 +8,8 @@ def up
8
8
  ActiveRecord::Schema.define do
9
9
 
10
10
  create_table :events do |t|
11
- t.string :title, null: false
11
+ t.string :title, null: false ## title (just the first link text)
12
+ t.string :text, null: false ## -- "full" title - incl. markdown link(s)
12
13
  t.string :place, null: false
13
14
  t.string :date, null: false # note: full date range (start to end) for now as *string*
14
15
  t.date :start_date, null: false ## use (rename) to start_at - why? why not?
@@ -3,7 +3,7 @@
3
3
  module EventDb
4
4
 
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 5
6
+ MINOR = 6
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
data/test/data/RUBY.md CHANGED
@@ -127,7 +127,7 @@ NOTE: A calendar page ([CALENDAR.md](CALENDAR.md)) gets auto-generated from this
127
127
  #### Germany / Deutschland (de)
128
128
 
129
129
  - @ Berlin
130
- - [Ruby User Group Berlin (RUG::B)](http://berlin.onruby.de)
130
+ - [Ruby User Group Berlin (RUG::B)](http://rug-b.de)
131
131
  - [Rails Girls Berlin](http://railsgirlsberlin.de)
132
132
  - @ Hamburg
133
133
  - [Hamburg on Ruby](http://hamburg.onruby.de)
@@ -19,6 +19,6 @@ on the [awesome-events](README.md) page. Anything missing? Contributions welcome
19
19
 
20
20
  <% end %>
21
21
 
22
- <%= ev.date %> • **<%= ev.title %>** @ <%= ev.place %>
22
+ <%= ev.date %> • **<%= ev.text %>** @ <%= ev.place %>
23
23
 
24
24
  <% end %>
@@ -10,14 +10,17 @@ require 'helper'
10
10
  class TestCalendar < MiniTest::Test
11
11
 
12
12
  def test_ruby
13
-
13
+
14
14
  r = EventDb::EventReader.from_file( "#{EventDb.root}/test/data/RUBY.md" )
15
15
  events = r.read
16
16
 
17
- cal = EventDb::EventCalendar.new( events )
18
- buf = cal.render
17
+ db = EventDb::Database.new
18
+ db.add( events )
19
+
20
+ cal = EventDb::EventCalendar.new
21
+ buf = cal.render( template: "#{EventDb.root}/test/templates/RUBY.md.erb" )
19
22
  pp buf
20
-
23
+
21
24
  start_buf =<<EOS
22
25
  # Ruby Conference Calendar
23
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -143,9 +143,9 @@ files:
143
143
  - lib/eventdb/reader.rb
144
144
  - lib/eventdb/schema.rb
145
145
  - lib/eventdb/version.rb
146
- - templates/CALENDAR.md.erb
147
146
  - test/data/RUBY.md
148
147
  - test/helper.rb
148
+ - test/templates/RUBY.md.erb
149
149
  - test/test_calendar.rb
150
150
  - test/test_database.rb
151
151
  - test/test_reader.rb