gyazz 1.0.1 → 1.0.2

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/lib/gyazz/page.rb CHANGED
@@ -26,8 +26,8 @@ module Gyazz
26
26
  })
27
27
  end
28
28
 
29
- def data(opts = {:version => 0})
30
- JSON.parse @wiki.get("/#{URI.encode @wiki.name}/#{URI.encode @name}/json/#{opts[:version]}")
29
+ def data(query = {:version => 0})
30
+ JSON.parse @wiki.get("/#{URI.encode @wiki.name}/#{URI.encode @name}/json", query)
31
31
  end
32
32
 
33
33
  def access
data/lib/gyazz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gyazz
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
data/lib/gyazz/wiki.rb CHANGED
@@ -25,8 +25,8 @@ module Gyazz
25
25
  Page.new name, self
26
26
  end
27
27
 
28
- def get(path)
29
- res = HTTParty.get "#{@host}#{path}", :basic_auth => @basic_auth
28
+ def get(path, query={})
29
+ res = HTTParty.get "#{@host}#{path}", :query => query, :basic_auth => @basic_auth
30
30
  case res.code
31
31
  when 200
32
32
  return res.body
@@ -47,7 +47,7 @@ module Gyazz
47
47
  end
48
48
 
49
49
  def pages
50
- JSON.parse(self.get "/#{@name}/__list").map{|i|
50
+ JSON.parse(self.get "/#{URI.encode @name}/__list").map{|i|
51
51
  Page.new(i[0], self)
52
52
  }
53
53
  end
data/test/test_page.rb CHANGED
@@ -3,7 +3,7 @@ require File.expand_path 'test_helper', File.dirname(__FILE__)
3
3
  class TestPage < MiniTest::Test
4
4
 
5
5
  def setup
6
- @wiki = Gyazz::Wiki.new('test2')
6
+ @wiki = Gyazz::Wiki.new('test')
7
7
  @wiki.host = ENV['GYAZZ_HOST'] if ENV.has_key? 'GYAZZ_HOST'
8
8
  @page = @wiki.page('aaa')
9
9
  end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
3
+
4
+ class TestPageJp < MiniTest::Test
5
+
6
+ def setup
7
+ @wiki = Gyazz::Wiki.new('テスト')
8
+ @wiki.host = ENV['GYAZZ_HOST'] if ENV.has_key? 'GYAZZ_HOST'
9
+ @page = @wiki.page('あああ')
10
+ end
11
+
12
+ def test_url
13
+ host = ENV['GYAZZ_HOST'] || 'http://gyazz.com'
14
+ assert_equal @page.url , "#{host}/#{URI.encode @wiki.name}/#{URI.encode @page.name}"
15
+ end
16
+
17
+ def test_get_text
18
+ assert_equal @page.text.class, String
19
+ end
20
+
21
+ def test_set_text
22
+ body = ["foo", "bar", Time.now.to_s].join("\n")
23
+ @page.text = body
24
+ assert_equal @page.text.strip, body
25
+ end
26
+
27
+ def test_data
28
+ assert_equal @page.data.class, Hash
29
+ end
30
+
31
+ def test_access
32
+ assert_equal @page.access.class, Array
33
+ end
34
+
35
+ def test_access
36
+ assert_equal @page.modify.class, Array
37
+ end
38
+
39
+ def test_related_pages
40
+ pages = @page.related_pages
41
+ assert_equal pages.class, Array
42
+ pages.each do |page|
43
+ assert_equal page.class, Gyazz::Page
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
3
+
4
+ class TestWikiJp < MiniTest::Test
5
+
6
+ def setup
7
+ @wiki = Gyazz::Wiki.new 'テスト'
8
+ @wiki.host = ENV['GYAZZ_HOST'] if ENV.has_key? 'GYAZZ_HOST'
9
+ end
10
+
11
+ def test_url
12
+ host = ENV['GYAZZ_HOST'] || 'http://gyazz.com'
13
+ assert_equal @wiki.url , "#{host}/#{URI.encode @wiki.name}"
14
+ end
15
+
16
+ def test_pages
17
+ pages = @wiki.pages
18
+ assert_equal pages.class, Array
19
+ pages.each do |page|
20
+ assert_equal page.class, Gyazz::Page
21
+ end
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyazz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-02 00:00:00.000000000 Z
13
+ date: 2014-01-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -118,7 +118,9 @@ files:
118
118
  - test/test_gyazz.rb
119
119
  - test/test_helper.rb
120
120
  - test/test_page.rb
121
+ - test/test_page_jp.rb
121
122
  - test/test_wiki.rb
123
+ - test/test_wiki_jp.rb
122
124
  homepage: https://github.com/masui/gyazz-ruby
123
125
  licenses:
124
126
  - MIT
@@ -149,4 +151,6 @@ test_files:
149
151
  - test/test_gyazz.rb
150
152
  - test/test_helper.rb
151
153
  - test/test_page.rb
154
+ - test/test_page_jp.rb
152
155
  - test/test_wiki.rb
156
+ - test/test_wiki_jp.rb