syoboi_calendar 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +6 -19
- data/lib/syoboi_calendar/client.rb +12 -0
- data/lib/syoboi_calendar/version.rb +1 -1
- data/spec/syoboi_calendar/client_spec.rb +22 -0
- metadata +16 -16
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,24 +4,16 @@ Simple gem for [SyoboiCalendar](http://cal.syoboi.jp/) to search Japanese anime
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install syoboi_calendar
|
7
|
+
```
|
8
|
+
$ gem install syoboi_calendar
|
9
|
+
```
|
18
10
|
|
19
11
|
## Usage
|
20
12
|
|
21
13
|
```
|
22
14
|
require "syoboi_calender"
|
23
15
|
|
24
|
-
client = SyoboiCalendar
|
16
|
+
client = SyoboiCalendar.new(
|
25
17
|
:user => "r7kamura",
|
26
18
|
:pass => "********"
|
27
19
|
)
|
@@ -35,10 +27,5 @@ p programs[0].start_time #=> 2012-04-06 02:50:00 +0900
|
|
35
27
|
p programs[0].channel_name #=> "TBS"
|
36
28
|
```
|
37
29
|
|
38
|
-
##
|
39
|
-
|
40
|
-
1. Fork it
|
41
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
43
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
-
5. Create new Pull Request
|
30
|
+
## Requirement
|
31
|
+
* Ruby >= 1.9.2
|
@@ -68,6 +68,8 @@ class SyoboiCalendar
|
|
68
68
|
|
69
69
|
# create hash for search query
|
70
70
|
def create_search_query(opts)
|
71
|
+
opts[:range] &&= canonicalize_range(opts[:range])
|
72
|
+
|
71
73
|
{
|
72
74
|
:sd => { nil => 2, :program => 2, :title => 0 }[opts[:mode]],
|
73
75
|
:r => { nil => 0, :all => 0, :past => 1, :future => 2}[opts[:range]] || 3,
|
@@ -83,5 +85,15 @@ class SyoboiCalendar
|
|
83
85
|
:pfs => opts[:special] && 1, # special program
|
84
86
|
}.select { |k, v| v }
|
85
87
|
end
|
88
|
+
|
89
|
+
def canonicalize_range(range)
|
90
|
+
if range.kind_of?(Range)
|
91
|
+
[range.first, range.last].map { |date|
|
92
|
+
date.strftime("%Y/%m/%d")
|
93
|
+
}.join("-")
|
94
|
+
else
|
95
|
+
range
|
96
|
+
end
|
97
|
+
end
|
86
98
|
end
|
87
99
|
end
|
@@ -66,4 +66,26 @@ describe "SyoboiCalendar::Client" do
|
|
66
66
|
it { should_not be_login }
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
describe "#canonicalize_range" do
|
71
|
+
shared_examples_for "return date format string" do
|
72
|
+
it { should match(%r|\d{4}/\d{2}/\d{2}-\d{4}/\d{2}/\d{2}|) }
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when passed Range of Date" do
|
76
|
+
subject do
|
77
|
+
range = (Date.today .. Date.today + 1)
|
78
|
+
@client.send(:canonicalize_range, range)
|
79
|
+
end
|
80
|
+
it_should_behave_like "return date format string"
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when passed Range of Time" do
|
84
|
+
subject do
|
85
|
+
range = (Time.now .. Time.now + 86400)
|
86
|
+
@client.send(:canonicalize_range, range)
|
87
|
+
end
|
88
|
+
it_should_behave_like "return date format string"
|
89
|
+
end
|
90
|
+
end
|
69
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syoboi_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &70208228304300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70208228304300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70208228303400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70208228303400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70208228302780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.9.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70208228302780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &70208228302120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.8.6
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70208228302120
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70208228301540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.6.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70208228301540
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov-vim
|
71
|
-
requirement: &
|
71
|
+
requirement: &70208228300620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 0.0.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70208228300620
|
80
80
|
description: Simple gem for Syoboi Calendar
|
81
81
|
email:
|
82
82
|
- r7kamura@gmail.com
|
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash:
|
125
|
+
hash: 1762739173120087868
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
segments:
|
133
133
|
- 0
|
134
|
-
hash:
|
134
|
+
hash: 1762739173120087868
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
137
|
rubygems_version: 1.8.15
|