bijint 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa745db959dd179c133dd7ebf5f93ef2301a304d
4
- data.tar.gz: a5e7fe4469e0bf19f8013eb89f8a92652d6aa46f
3
+ metadata.gz: 2b2e1670cab9bd113b3244cc857d9a34f69d4923
4
+ data.tar.gz: 929056ce920887b62342d0c312ea536aa30053e9
5
5
  SHA512:
6
- metadata.gz: 26823536d67cdc8c4cb50bf09699fbe31eca403b933efc45a1e8c46d9b3c9cdf718f29e2ecd7847fdc3760e5fe471c07dcf5d8ccceb88ae5b5e1fb65e7aad1d3
7
- data.tar.gz: f82f700fe276ef1d69d8a2aac1e086cb268592a684e21a09dfdfc93f97f9abc7a84d6421a4d4e775be414ca3a44d9bdc6905af4b6a49a1937a2a894fb8fec23c
6
+ metadata.gz: 9e20e2a5e05d0c5df50d84fe2d94cd6ac5da28fdef571e1bdaa036320efa8ae798c8efadc39a4d5014ff4aff0c8529d25797511e17e58b62201f824f96e9b405
7
+ data.tar.gz: 0e088ccf690247da1a73e7e89fa4d2497adb41bbc7ce2d817f7760ec77cc80c007d7c2e319ddbd2e9ff69a0b918b00b32634df0359f40dc8ec6113eebd514e32
data/README.md CHANGED
@@ -36,6 +36,20 @@ http://www.bijint.com/assets/pict/tokyo/pc/2357.jpg
36
36
  http://www.bijint.com/assets/pict/tokyo/pc/0003.jpg
37
37
  ```
38
38
 
39
+ ### area
40
+
41
+ ```sh
42
+ % bijint area hokkaido
43
+ http://www.bijint.com/assets/pict/hokkaido/pc/2357.jpg
44
+ ```
45
+
46
+ ### area random
47
+
48
+ ```sh
49
+ % bijint area_random hokkaido
50
+ http://www.bijint.com/assets/pict/hokkaido/pc/0909.jpg
51
+ ```
52
+
39
53
  ### markdown
40
54
 
41
55
  ```sh
@@ -50,6 +64,20 @@ http://www.bijint.com/assets/pict/tokyo/pc/0003.jpg
50
64
  [![bijint](http://www.bijint.com/assets/pict/tokyo/pc/0025.jpg)](http://www.bijint.com/assets/pict/tokyo/pc/0025.jpg)
51
65
  ```
52
66
 
67
+ ### markdown area
68
+
69
+ ```sh
70
+ % bijint md_area hokkaido
71
+ [![bijint](http://www.bijint.com/assets/pict/hokkaido/pc/0105.jpg)](http://www.bijint.com/assets/pict/hokkaido/pc/0105.jpg)
72
+ ```
73
+
74
+ ### markdown area random
75
+
76
+ ```sh
77
+ % bijint md_area_random hokkaido
78
+ [![bijint](http://www.bijint.com/assets/pict/hokkaido/pc/1837.jpg)](http://www.bijint.com/assets/pict/hokkaido/pc/1837.jpg)
79
+ ```
80
+
53
81
  ## Contributing
54
82
 
55
83
  1. Fork it ( https://github.com/funnythingz/bijint/fork )
data/bin/bijint CHANGED
@@ -7,7 +7,11 @@ bijint = Bijint::Bijint.new
7
7
  if ARGV.empty?
8
8
  puts bijint.now
9
9
  else
10
- puts bijint.random if ARGV.first == 'random'
11
- puts bijint.md if ARGV.first == 'md'
12
- puts bijint.md_random if ARGV.first == 'md_random'
10
+ puts bijint.random if ARGV.first == 'random'
11
+ puts bijint.area(ARGV.last) if ARGV.first == 'area'
12
+ puts bijint.area_random(ARGV.last) if ARGV.first == 'area_random'
13
+ puts bijint.md if ARGV.first == 'md'
14
+ puts bijint.md_random if ARGV.first == 'md_random'
15
+ puts bijint.md_area(ARGV.last) if ARGV.first == 'md_area'
16
+ puts bijint.md_area_random(ARGV.last) if ARGV.first == 'md_area_random'
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module Bijint
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/bijint.rb CHANGED
@@ -10,23 +10,54 @@ module Bijint
10
10
  url(set_area, time_rand)
11
11
  end
12
12
 
13
+ def area(area)
14
+ if area_list.include? area
15
+ url(area, Time.now)
16
+ else
17
+ url(set_area, Time.now)
18
+ end
19
+ end
20
+
21
+ def area_random(area)
22
+ if area_list.include? area
23
+ url(area, time_rand)
24
+ else
25
+ url(set_area, time_rand)
26
+ end
27
+ end
28
+
13
29
  def md
14
- area = set_area
15
- "[![bijint](#{url(area, Time.now)})](#{url(area, Time.now)})"
30
+ url = now
31
+ "[![bijint](#{now})](#{now})"
16
32
  end
17
33
 
18
34
  def md_random
19
- area = set_area
20
- date = time_rand
21
- "[![bijint](#{url(area, date)})](#{url(area, date)})"
35
+ url = random
36
+ "[![bijint](#{url})](#{url})"
37
+ end
38
+
39
+ def md_area(area)
40
+ url = area(area)
41
+ "[![bijint](#{url})](#{url})"
22
42
  end
23
43
 
44
+ def md_area_random(area)
45
+ url = area_random(area)
46
+ "[![bijint](#{url})](#{url})"
47
+ end
48
+
49
+ private
50
+
24
51
  def url(area, time)
25
52
  "http://www.bijint.com/assets/pict/#{area}/pc/#{time.strftime('%H%M')}.jpg"
26
53
  end
27
54
 
55
+ def area_list
56
+ %w(kyoto shizuoka saga kobe tochigi miyazaki kagoshima hiroshima kanazawa nara hokkaido nagasaki okayama gunma sendai kanagawa fukui nagoya tottori osaka akita okinawa nagano saitama tokyo ibaraki iwate niigata kagawa fukuoka kumamoto yamaguchi aomori chiba yamanashi hanayome 2012jp tv-asahi sara 2013jp cc wasedastyle megane hairstyle 2011jp bimajo thailand hawaii taiwan jakarta)
57
+ end
58
+
28
59
  def set_area
29
- %w(kyoto shizuoka saga kobe tochigi miyazaki kagoshima hiroshima kanazawa nara hokkaido nagasaki okayama gunma sendai kanagawa fukui nagoya tottori osaka akita okinawa nagano saitama tokyo ibaraki iwate niigata kagawa fukuoka kumamoto yamaguchi aomori chiba yamanashi hanayome 2012jp tv-asahi sara 2013jp cc wasedastyle megane hairstyle 2011jp bimajo thailand hawaii taiwan jakarta).shuffle.first
60
+ area_list.shuffle.first
30
61
  end
31
62
 
32
63
  def time_rand(from = 0.0, to = Time.now)
data/spec/bijint_spec.rb CHANGED
@@ -14,6 +14,16 @@ describe Bijint do
14
14
  expect(bijint.random).to match /http:\/\/www\.bijint\.com\/assets\/pict\/[a-z0-9]+\/pc\/\d{4}\.jpg/
15
15
  end
16
16
 
17
+ it 'area' do
18
+ time = Time.now
19
+ expect(bijint.area 'tokyo').to eq "http://www.bijint.com/assets/pict/tokyo/pc/#{time.strftime('%H%M')}.jpg"
20
+ end
21
+
22
+ it 'area_random' do
23
+ time = Time.now
24
+ expect(bijint.area_random 'tokyo').to match /http:\/\/www\.bijint\.com\/assets\/pict\/tokyo\/pc\/\d{4}\.jpg/
25
+ end
26
+
17
27
  it 'md' do
18
28
  time = Time.now
19
29
  expect(bijint.md).to match /\[!\[bijint\]\(http:\/\/www\.bijint\.com\/assets\/pict\/[a-z0-9]+\/pc\/#{time.strftime('%H%M')}\.jpg\)\]\(http:\/\/www\.bijint\.com\/assets\/pict\/[a-z0-9]+\/pc\/#{time.strftime('%H%M')}\.jpg\)/
@@ -22,6 +32,15 @@ describe Bijint do
22
32
  it 'md_random' do
23
33
  expect(bijint.md_random).to match /\[!\[bijint\]\(http:\/\/www\.bijint\.com\/assets\/pict\/[a-z0-9]+\/pc\/\d{4}\.jpg\)\]\(http:\/\/www\.bijint\.com\/assets\/pict\/[a-z0-9]+\/pc\/\d{4}\.jpg\)/
24
34
  end
35
+
36
+ it 'md_area' do
37
+ time = Time.now
38
+ expect(bijint.md_area 'tokyo').to match /\[!\[bijint\]\(http:\/\/www\.bijint\.com\/assets\/pict\/tokyo\/pc\/\d{4}\.jpg\)\]\(http:\/\/www\.bijint\.com\/assets\/pict\/tokyo\/pc\/\d{4}\.jpg\)/
39
+ end
40
+
41
+ it 'md_area_random' do
42
+ expect(bijint.md_area_random 'tokyo').to match /\[!\[bijint\]\(http:\/\/www\.bijint\.com\/assets\/pict\/tokyo\/pc\/\d{4}\.jpg\)\]\(http:\/\/www\.bijint\.com\/assets\/pict\/tokyo\/pc\/\d{4}\.jpg\)/
43
+ end
25
44
  end
26
45
 
27
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bijint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - funnythingz