gcal_mapper 0.1.1

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.
Files changed (58) hide show
  1. data/.gitignore +32 -0
  2. data/.travis.yml +16 -0
  3. data/CHANGELOG.md +15 -0
  4. data/Gemfile +20 -0
  5. data/Guardfile +19 -0
  6. data/LICENSE +22 -0
  7. data/README.md +370 -0
  8. data/Rakefile +32 -0
  9. data/bin/ci/file/auth.yaml +7 -0
  10. data/bin/ci/file/bad_yaml.yaml +0 -0
  11. data/bin/ci/file/config.yaml +8 -0
  12. data/bin/ci/file/privatekey.p12 +0 -0
  13. data/bin/ci/travis_build.sh +4 -0
  14. data/bin/ci/vcr/GcalMapper_Authentification/access_token_should_exist_with_assertion_auth.yml +49 -0
  15. data/bin/ci/vcr/GcalMapper_Authentification/should_be_fasle_if_bad_client_email_is_given.yml +47 -0
  16. data/bin/ci/vcr/GcalMapper_Authentification_Assertion/should_have_access_token_attribute.yml +49 -0
  17. data/bin/ci/vcr/GcalMapper_Authentification_Assertion/should_have_refresh_token_attribute.yml +49 -0
  18. data/bin/ci/vcr/GcalMapper_Calendar/should_get_the_calendar_list.yml +190 -0
  19. data/bin/ci/vcr/GcalMapper_Calendar/should_get_the_events_list.yml +45 -0
  20. data/bin/ci/vcr/GcalMapper_Calendar/should_raise_error_if_the_calendar_id_isn_t_accessible.yml +56 -0
  21. data/bin/ci/vcr/GcalMapper_Calendar/should_raise_error_if_the_token_is_bad.yml +60 -0
  22. data/bin/ci/vcr/GcalMapper_Mapper/should_save_all_events.yml +232 -0
  23. data/bin/ci/vcr/GcalMapper_Mapper/should_save_events_only_once.yml +232 -0
  24. data/bin/gcal-mapper +108 -0
  25. data/gcal_mapper.gemspec +25 -0
  26. data/lib/gcal_mapper.rb +15 -0
  27. data/lib/gcal_mapper/authentification.rb +57 -0
  28. data/lib/gcal_mapper/authentification/assertion.rb +110 -0
  29. data/lib/gcal_mapper/authentification/base.rb +20 -0
  30. data/lib/gcal_mapper/authentification/oauth2.rb +68 -0
  31. data/lib/gcal_mapper/calendar.rb +51 -0
  32. data/lib/gcal_mapper/configuration.rb +23 -0
  33. data/lib/gcal_mapper/errors.rb +40 -0
  34. data/lib/gcal_mapper/mapper.rb +76 -0
  35. data/lib/gcal_mapper/mapper/active_record.rb +74 -0
  36. data/lib/gcal_mapper/mapper/dsl.rb +57 -0
  37. data/lib/gcal_mapper/mapper/simple.rb +97 -0
  38. data/lib/gcal_mapper/railtie.rb +8 -0
  39. data/lib/gcal_mapper/rest_request.rb +73 -0
  40. data/lib/gcal_mapper/sync.rb +159 -0
  41. data/lib/gcal_mapper/version.rb +4 -0
  42. data/spec/authentification/assertion_spec.rb +15 -0
  43. data/spec/authentification/base_spec.rb +18 -0
  44. data/spec/authentification/oauth2_spec.rb +15 -0
  45. data/spec/authentification_spec.rb +34 -0
  46. data/spec/calendar_spec.rb +33 -0
  47. data/spec/gcal_mapper_spec.rb +5 -0
  48. data/spec/mapper/active_record_spec.rb +46 -0
  49. data/spec/mapper/dsl_spec.rb +31 -0
  50. data/spec/mapper/simple_spec.rb +48 -0
  51. data/spec/mapper_spec.rb +32 -0
  52. data/spec/rest_request_spec.rb +5 -0
  53. data/spec/spec_helper.rb +51 -0
  54. data/spec/support/models/event.rb +25 -0
  55. data/spec/support/models/event_jeu.rb +22 -0
  56. data/spec/support/schema.rb +28 -0
  57. data/spec/sync_spec.rb +28 -0
  58. metadata +200 -0
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe GcalMapper::RestRequest do
4
+
5
+ end
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ require 'rspec'
4
+ require 'active_record'
5
+
6
+
7
+ # SimpleCov
8
+ if ENV['COVERAGE']
9
+ require 'simplecov'
10
+ SimpleCov.start
11
+ end
12
+
13
+ require 'gcal_mapper'
14
+
15
+ Spork.prefork do
16
+
17
+ #vcr
18
+ require 'vcr'
19
+ VCR.configure do |c|
20
+ c.cassette_library_dir = 'spec/vcr'
21
+ c.hook_into :fakeweb
22
+ c.configure_rspec_metadata!
23
+ c.default_cassette_options = {
24
+ :record => :new_episodes,
25
+ :allow_playback_repeats => :true
26
+ }
27
+ end
28
+
29
+ RSpec.configure do |config|
30
+ config.filter_run :focus => true
31
+ config.treat_symbols_as_metadata_keys_with_true_values = true
32
+ config.run_all_when_everything_filtered = true
33
+ config.before :all do
34
+ ActiveRecord::Base.establish_connection(
35
+ :adapter => "sqlite3",
36
+ :database => File.dirname(__FILE__) + "/test.sqlite3"
37
+ )
38
+ load File.dirname(__FILE__) + '/support/schema.rb'
39
+
40
+ config = YAML.load_file('spec/file/config.yaml')
41
+ @p12 = config['p12']
42
+ @client_email = config['client_email']
43
+ @user_email = config['user_email']
44
+ @yaml = config['yaml']
45
+ @yaml_relative = config['yaml_relative']
46
+ @bad_yaml = config['bad_yaml']
47
+ @calendar_id = config['calendar_id']
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,25 @@
1
+ require 'active_record'
2
+
3
+ class Event < ActiveRecord::Base
4
+
5
+ include GcalMapper::Mapper::ActiveRecord
6
+
7
+ calendar do
8
+ configure :file => 'spec/file/auth.yaml'
9
+
10
+ calendar 'neville.dubuis@liquid-concept.ch'
11
+ calendar 'neville.dubuis@liquid-concept.ch'
12
+
13
+ google_id 'gid'
14
+
15
+ field 'name', :source => 'summary'
16
+ field 'description', :source => 'description',
17
+ :match => /^category: (.*)$/, :default => 'not categorized'
18
+ field 'status', :source => 'status'
19
+ field 'start_at', :source => 'start.dateTime'
20
+ field 'end_at', :source => 'end.dateTime'
21
+ field 'created_at', :source => 'created'
22
+ field 'updated_at', :source => 'updated'
23
+ end
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_record'
2
+
3
+ class EventJeu < ActiveRecord::Base
4
+
5
+ include GcalMapper::Mapper
6
+
7
+ calendar do
8
+ configure :file => '/home/ndubuis/Dev/gcalmapper/spec/file/privatekey2.p12',
9
+ :client_email => '877466408867@developer.gserviceaccount.com',
10
+ :user_email => 'webmaster@jeunesse-suchy.ch',
11
+ :password => 'notasecret'
12
+
13
+ calendar 'webmaster@jeunesse-suchy.ch'
14
+
15
+ google_id 'gid'
16
+
17
+ field 'name', :source => 'summary'
18
+ field 'start_at', :source => 'start.dateTime'
19
+ field 'end_at', :source => 'end.dateTime'
20
+ end
21
+
22
+ end
@@ -0,0 +1,28 @@
1
+ ActiveRecord::Schema.define do
2
+ self.verbose = false
3
+
4
+ create_table :events, :force => true do |t|
5
+ t.string :gid
6
+ t.string :name
7
+ t.string :description
8
+ t.string :status
9
+ t.datetime :start_at
10
+ t.datetime :end_at
11
+ t.datetime :created_at
12
+ t.datetime :updated_at
13
+ end
14
+
15
+ create_table :event_jeus, :force => true do |t|
16
+ t.string :gid
17
+ t.string :name
18
+ t.datetime :start_at
19
+ t.datetime :end_at
20
+ t.datetime :created_at
21
+ t.datetime :updated_at
22
+ end
23
+
24
+ create_table :users, :force => true do |t|
25
+ t.string :first_name
26
+ t.string :name
27
+ end
28
+ end
data/spec/sync_spec.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe GcalMapper::Sync do
4
+ before(:each) do
5
+ GcalMapper::Sync.send(:public, *GcalMapper::Sync.private_instance_methods)
6
+ end
7
+
8
+ it "should raise error if regexp is not valid" do
9
+ sync = GcalMapper::Sync.new(nil, nil)
10
+ expect {sync.eval_value({:source => 'test', :match => test, :default => 'category: test'}, 'test')}.to raise_error
11
+ end
12
+
13
+ it "should return default if no match" do
14
+ sync = GcalMapper::Sync.new(nil, nil)
15
+ sync.eval_value({:source => 'test', :match => /^category: (.*)$/, :default => 'default'}, 'test').should eq('default')
16
+ end
17
+
18
+ it "should return match" do
19
+ sync = GcalMapper::Sync.new(nil, nil)
20
+ sync.eval_value({:source => 'test', :match => /^test$/, :default => 'default'}, 'test').should eq('test')
21
+ end
22
+
23
+ it "should give raw data if no regexp given" do
24
+ sync = GcalMapper::Sync.new(nil, nil)
25
+ sync.eval_value({:source => 'test'}, 'raw').should eq('raw')
26
+ end
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gcal_mapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Néville Dubuis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: launchy
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activerecord
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: vcr
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: fakeweb
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: A library to map Google Calendar events with an ORM
95
+ email:
96
+ - neville.dubuis@liquid-concept.ch
97
+ executables:
98
+ - gcal-mapper
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - .travis.yml
104
+ - CHANGELOG.md
105
+ - Gemfile
106
+ - Guardfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - bin/ci/file/auth.yaml
111
+ - bin/ci/file/bad_yaml.yaml
112
+ - bin/ci/file/config.yaml
113
+ - bin/ci/file/privatekey.p12
114
+ - bin/ci/travis_build.sh
115
+ - bin/ci/vcr/GcalMapper_Authentification/access_token_should_exist_with_assertion_auth.yml
116
+ - bin/ci/vcr/GcalMapper_Authentification/should_be_fasle_if_bad_client_email_is_given.yml
117
+ - bin/ci/vcr/GcalMapper_Authentification_Assertion/should_have_access_token_attribute.yml
118
+ - bin/ci/vcr/GcalMapper_Authentification_Assertion/should_have_refresh_token_attribute.yml
119
+ - bin/ci/vcr/GcalMapper_Calendar/should_get_the_calendar_list.yml
120
+ - bin/ci/vcr/GcalMapper_Calendar/should_get_the_events_list.yml
121
+ - bin/ci/vcr/GcalMapper_Calendar/should_raise_error_if_the_calendar_id_isn_t_accessible.yml
122
+ - bin/ci/vcr/GcalMapper_Calendar/should_raise_error_if_the_token_is_bad.yml
123
+ - bin/ci/vcr/GcalMapper_Mapper/should_save_all_events.yml
124
+ - bin/ci/vcr/GcalMapper_Mapper/should_save_events_only_once.yml
125
+ - bin/gcal-mapper
126
+ - gcal_mapper.gemspec
127
+ - lib/gcal_mapper.rb
128
+ - lib/gcal_mapper/authentification.rb
129
+ - lib/gcal_mapper/authentification/assertion.rb
130
+ - lib/gcal_mapper/authentification/base.rb
131
+ - lib/gcal_mapper/authentification/oauth2.rb
132
+ - lib/gcal_mapper/calendar.rb
133
+ - lib/gcal_mapper/configuration.rb
134
+ - lib/gcal_mapper/errors.rb
135
+ - lib/gcal_mapper/mapper.rb
136
+ - lib/gcal_mapper/mapper/active_record.rb
137
+ - lib/gcal_mapper/mapper/dsl.rb
138
+ - lib/gcal_mapper/mapper/simple.rb
139
+ - lib/gcal_mapper/railtie.rb
140
+ - lib/gcal_mapper/rest_request.rb
141
+ - lib/gcal_mapper/sync.rb
142
+ - lib/gcal_mapper/version.rb
143
+ - spec/authentification/assertion_spec.rb
144
+ - spec/authentification/base_spec.rb
145
+ - spec/authentification/oauth2_spec.rb
146
+ - spec/authentification_spec.rb
147
+ - spec/calendar_spec.rb
148
+ - spec/gcal_mapper_spec.rb
149
+ - spec/mapper/active_record_spec.rb
150
+ - spec/mapper/dsl_spec.rb
151
+ - spec/mapper/simple_spec.rb
152
+ - spec/mapper_spec.rb
153
+ - spec/rest_request_spec.rb
154
+ - spec/spec_helper.rb
155
+ - spec/support/models/event.rb
156
+ - spec/support/models/event_jeu.rb
157
+ - spec/support/schema.rb
158
+ - spec/sync_spec.rb
159
+ homepage: http://rubygems.org/gems/gcal_mapper
160
+ licenses: []
161
+ post_install_message:
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ! '>='
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 1.8.24
180
+ signing_key:
181
+ specification_version: 3
182
+ summary: A library to map Google Calendar events with an ORM
183
+ test_files:
184
+ - spec/authentification/assertion_spec.rb
185
+ - spec/authentification/base_spec.rb
186
+ - spec/authentification/oauth2_spec.rb
187
+ - spec/authentification_spec.rb
188
+ - spec/calendar_spec.rb
189
+ - spec/gcal_mapper_spec.rb
190
+ - spec/mapper/active_record_spec.rb
191
+ - spec/mapper/dsl_spec.rb
192
+ - spec/mapper/simple_spec.rb
193
+ - spec/mapper_spec.rb
194
+ - spec/rest_request_spec.rb
195
+ - spec/spec_helper.rb
196
+ - spec/support/models/event.rb
197
+ - spec/support/models/event_jeu.rb
198
+ - spec/support/schema.rb
199
+ - spec/sync_spec.rb
200
+ has_rdoc: