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 +4 -4
- data/Manifest.txt +1 -1
- data/README.md +5 -3
- data/lib/eventdb.rb +3 -3
- data/lib/eventdb/calendar.rb +15 -10
- data/lib/eventdb/database.rb +36 -10
- data/lib/eventdb/models.rb +2 -0
- data/lib/eventdb/schema.rb +2 -1
- data/lib/eventdb/version.rb +1 -1
- data/test/data/RUBY.md +1 -1
- data/{templates/CALENDAR.md.erb → test/templates/RUBY.md.erb} +1 -1
- data/test/test_calendar.rb +7 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e654b4516eb35c7b99b568fc10b10fa9236d9886
|
4
|
+
data.tar.gz: 8e2b5920e684344fd7177f484783482efce0c859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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::
|
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 (
|
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
|
|
data/lib/eventdb/calendar.rb
CHANGED
@@ -49,9 +49,10 @@ end # class EventCursor
|
|
49
49
|
|
50
50
|
class EventCalendar
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
64
|
-
|
63
|
+
def render( opts={} )
|
64
|
+
tmpl_path = opts[:template] || './templates/CALENDAR.md.erb'
|
65
|
+
tmpl = File.read_utf8( tmpl_path )
|
65
66
|
|
66
|
-
|
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
|
data/lib/eventdb/database.rb
CHANGED
@@ -2,21 +2,26 @@
|
|
2
2
|
|
3
3
|
module EventDb
|
4
4
|
|
5
|
-
class Database
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
class DatabaseBase ## fix: rename to Database (see below)
|
7
|
+
def initialize( config={} )
|
8
|
+
@config = config
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
def connect
|
12
|
+
ActiveRecord::Base.establish_connection( @config )
|
13
|
+
end
|
12
14
|
|
13
|
-
|
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
|
|
data/lib/eventdb/models.rb
CHANGED
data/lib/eventdb/schema.rb
CHANGED
@@ -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?
|
data/lib/eventdb/version.rb
CHANGED
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://
|
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)
|
data/test/test_calendar.rb
CHANGED
@@ -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
|
-
|
18
|
-
|
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.
|
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-
|
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
|