pebbles-citlunch 0.0.1 → 0.0.3
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.
- data/ChangeLog +17 -0
- data/README.md +8 -1
- data/lib/pebbles/citlunch/client.rb +5 -2
- data/lib/pebbles/citlunch/menu.rb +1 -2
- data/lib/pebbles/citlunch/version.rb +1 -1
- data/pebbles-citlunch.gemspec +0 -1
- data/spec/citlunch_spec.rb +21 -0
- metadata +3 -2
data/ChangeLog
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
2013-04-18 Jun SAITO <jsaito@jsaito-air.local>
|
|
2
|
+
|
|
3
|
+
* CHANGE Version 0.0.3
|
|
4
|
+
* CHANGE Adapted campus name changes.
|
|
5
|
+
|
|
6
|
+
2013-02-06 Jun SAITO <jsaito@xopowo.info>
|
|
7
|
+
|
|
8
|
+
* CHANGE Version 0.0.2
|
|
9
|
+
* CHANGE Menu class properties now replace ``&'' to ``&''.
|
|
10
|
+
|
|
11
|
+
2013-02-06 Jun SAITO <jsaito@xopowo.info>
|
|
12
|
+
|
|
13
|
+
* CHANGE Move to pebbles namespace. citlunch gem is now called pebbles-citlunch.
|
|
14
|
+
|
|
15
|
+
2013-01-12 Jun SAITO <jsaito@xopowo.info>
|
|
16
|
+
|
|
17
|
+
* CHANGE Version 0.0.1
|
data/README.md
CHANGED
|
@@ -23,5 +23,12 @@ See https://udon.upsilo.net/citlunch/ for more API doumentation.
|
|
|
23
23
|
## How to build
|
|
24
24
|
$ git clone https://github.com/st63jun/pebbles-citlunch.git
|
|
25
25
|
$ cd pebbles-citlunch
|
|
26
|
-
$
|
|
26
|
+
$ rake build
|
|
27
27
|
$ rake install
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
* GPL v3
|
|
32
|
+
|
|
33
|
+
See LICENSE
|
|
34
|
+
|
|
@@ -7,15 +7,18 @@ module CITLunch
|
|
|
7
7
|
class Client
|
|
8
8
|
|
|
9
9
|
API_ENDPOINT = "https://udon.upsilo.net/citlunch/api"
|
|
10
|
+
PLACES = [:tsuda_dining, :shiba_dining, :shiba_kissa, :snara_dining, :snara_kissa]
|
|
10
11
|
|
|
11
12
|
def get_today(place)
|
|
12
13
|
get(place, Date.today)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def get(place, date)
|
|
17
|
+
raise ArgumentError.new ("unknown place: #{place}") unless PLACES.include? place
|
|
16
18
|
url = "#{API_ENDPOINT}/#{place}/#{date.strftime("%Y-%m-%d")}/menu.json"
|
|
17
|
-
begin
|
|
18
|
-
open(url)
|
|
19
|
+
begin
|
|
20
|
+
json = open(url).read
|
|
21
|
+
JSON.parse(json).map {|r| Menu.new(r)}
|
|
19
22
|
rescue OpenURI::HTTPError
|
|
20
23
|
nil
|
|
21
24
|
end
|
data/pebbles-citlunch.gemspec
CHANGED
data/spec/citlunch_spec.rb
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
1
2
|
require 'spec_helper'
|
|
2
3
|
|
|
3
4
|
describe CITLunch do
|
|
5
|
+
context "when get menus" do
|
|
6
|
+
it "should create Menu objects from JSON" do
|
|
7
|
+
|
|
8
|
+
entry = [{ :price => 10,
|
|
9
|
+
:name => "うまい棒",
|
|
10
|
+
:details => ["サラダ味", "めんたいこ味"]}]
|
|
11
|
+
|
|
12
|
+
client = CITLunch::Client.new
|
|
13
|
+
client.should_receive(:open).and_return(StringIO.new(entry.to_json))
|
|
14
|
+
menus = client.get_today(:tsuda_dining)
|
|
15
|
+
|
|
16
|
+
menus.first.price.should == entry.first[:price]
|
|
17
|
+
menus.first.name.should == entry.first[:name]
|
|
18
|
+
menus.first.details.should == entry.first[:details]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "raise ArgumentError if illegal place specified" do
|
|
22
|
+
lambda { CITLunch.get_today(:nonexistent_place) }.should raise_error(ArgumentError)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
4
25
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pebbles-citlunch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
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-
|
|
12
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: Gets menus of Chiba Institute of Technology's student cafeteria from
|
|
15
15
|
CIT Lunch API (https://udon.upsilo.net/citlunch/)
|
|
@@ -20,6 +20,7 @@ extensions: []
|
|
|
20
20
|
extra_rdoc_files: []
|
|
21
21
|
files:
|
|
22
22
|
- .gitignore
|
|
23
|
+
- ChangeLog
|
|
23
24
|
- Gemfile
|
|
24
25
|
- LICENSE
|
|
25
26
|
- README.md
|