the-city-admin 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module CityKeys
2
2
 
3
- KEY = '8d326a8d354fcdeb97cb2a7b83561ac654d4ad53'
4
- TOKEN = '5a2aeeddac031b0a'
3
+ KEY = '**** YOUR CITY API KEY ****'
4
+ TOKEN = '**** YOUR CITY API TOKEN ****'
5
5
 
6
6
  end
data/lib/api/campus.rb ADDED
@@ -0,0 +1,20 @@
1
+ module TheCity
2
+
3
+ class Campus < ApiObject
4
+
5
+ tc_attr_accessor :id,
6
+ :name
7
+
8
+
9
+ # Constructor.
10
+ #
11
+ # @param json_data JSON data of the group tag.
12
+ def initialize(json_data)
13
+ initialize_from_json_object(json_data)
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,72 @@
1
+ module TheCity
2
+
3
+ class CampusList < ApiList
4
+
5
+ include Enumerable
6
+
7
+ # Constructor.
8
+ #
9
+ # @param options A hash of options for loading the list.
10
+ #
11
+ # Options:
12
+ # :page - The page number to get.
13
+ # :reader - The Reader to use to load the data.
14
+ # :search - (optional) A campus name to search on.
15
+ #
16
+ #
17
+ # Examples:
18
+ # CampusList.new
19
+ #
20
+ # CampusList.new({:page => 2})
21
+ #
22
+ def initialize(options = {})
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::CampusListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the campuss in the list.
36
+ #
37
+ # @return array of campus names.
38
+ def all_names
39
+ @json_data['campuses'].collect { |campus| campus['name'] }
40
+ end
41
+ alias :names :all_names
42
+
43
+
44
+ # Get the specified campus.
45
+ #
46
+ # @param index The index of the campus to get.
47
+ #
48
+ # @return [Group]
49
+ def [](index)
50
+ Campus.new( @json_data['campuses'][index] ) if @json_data['campuses'][index]
51
+ end
52
+
53
+
54
+ # This method is needed for Enumerable.
55
+ def each &block
56
+ @json_data['campuses'].each{ |campus| yield( Campus.new(campus) )}
57
+ end
58
+
59
+
60
+ # Alias the count method
61
+ alias :size :count
62
+
63
+ # Checks if the list is empty.
64
+ #
65
+ # @return True on empty, false otherwise.
66
+ def empty?
67
+ @json_data['campuses'].empty?
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,27 @@
1
+ module TheCity
2
+
3
+ class CampusListReader < ApiReader
4
+
5
+ # Constructor.
6
+ #
7
+ # @param options A hash of options for requesting data from the server. Adds default of page 1 if page not set.
8
+ # @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
9
+ def initialize(options = {}, cacher = nil)
10
+ options[:page] ||= 1
11
+
12
+ #@class_key = "group_list_#{options[:page]}_{some_kind_of_md5_thing_here}"
13
+ @url_data_path = "/campuses"
14
+ @url_data_params = white_list_options(options)
15
+
16
+ # The object to store and load the cache.
17
+ @cacher = cacher unless cacher.nil?
18
+ end
19
+
20
+ def white_list_options(options)
21
+ white_list = [:page]
22
+ options.clone.delete_if { |key, value| !white_list.include?(key) }
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  PROJECT_GEM = 'the-city-admin'
3
- PROJECT_GEM_VERSION = '0.6.4'
3
+ PROJECT_GEM_VERSION = '0.6.5'
4
4
 
5
5
  s.name = PROJECT_GEM
6
6
  s.version = PROJECT_GEM_VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the-city-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
@@ -67,6 +67,8 @@ files:
67
67
  - lib/api/api_list.rb
68
68
  - lib/api/api_object.rb
69
69
  - lib/api/barcode.rb
70
+ - lib/api/campus.rb
71
+ - lib/api/campus_list.rb
70
72
  - lib/api/checkin.rb
71
73
  - lib/api/checkin_list.rb
72
74
  - lib/api/church.rb
@@ -146,6 +148,7 @@ files:
146
148
  - lib/readers/address_list_reader.rb
147
149
  - lib/readers/address_reader.rb
148
150
  - lib/readers/api_reader.rb
151
+ - lib/readers/campus_list_reader.rb
149
152
  - lib/readers/checkin_list_reader.rb
150
153
  - lib/readers/checkin_reader.rb
151
154
  - lib/readers/church_reader.rb