scrapbox 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f597491ef7a75e6d46d7b847d3d6504dacfc891e01af1c3d9e90d7256491a794
4
- data.tar.gz: 2b759b7d18addea292bd8e6e830452bf4439a673ed8cce05dd2944b1e7878d13
3
+ metadata.gz: ef9ebaeea78e01125db55ac776124c790603f792fe1fb6d9f64aa4806dd4e8e5
4
+ data.tar.gz: 269cc1b58479fc718add4eee503c74be2e0cb41db73fd84c81465fd6138e5126
5
5
  SHA512:
6
- metadata.gz: 6da03a941e717da626ef5d163ae27b1c1dbd07ba3a747ffcbddaf85ab10fd6219798d80ade18e0cb8032d638a76c5e607ac9441505e01c8ed978347fd7fb7297
7
- data.tar.gz: 1757ca9134b866451b43c63c9d770c8318979009ab3721ef1340c36ea8e66c46669f59f43f6341319ad67dd319c162c5616d6e81329577b98fd99c445f6b4812
6
+ metadata.gz: 5b26723a1de1a00501b36710e2ef70950178f9b9a2048ef89e55d6af42a1dedd33c8621d8d51886c97404ae3c3a7e4ebb18862963c294d3eadee54f468276ae3
7
+ data.tar.gz: 25a753e0e935e5f501d09c75340b6beef0164eeaf6af54f22e1894f96c38b4edd000c52c4bab2ee09910cbba58f3789d784a291b5c87fa603d4640a38537640b
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -6,14 +6,22 @@ module Scrapbox
6
6
  def initialize(project,title)
7
7
  @project = project
8
8
  @title = title
9
+ @text = nil
10
+ @code = nil
9
11
  end
10
12
 
11
13
  def text
12
- text = Scrapbox.__getsbdata("#{project.host}/api/pages/#{project.name}/#{URI.encode(title).gsub(/\//,'%2f')}/text")
14
+ unless @text
15
+ @text = Scrapbox.__getsbdata("#{project.host}/api/pages/#{project.name}/#{URI.encode(title).gsub(/\//,'%2f')}/text")
16
+ end
17
+ @text
13
18
  end
14
19
 
15
20
  def code(src)
16
- Scrapbox.__getsbdata("#{project.host}/api/code/#{project.name}/#{URI.encode(title)}/#{src}")
21
+ unless @code
22
+ @code = Scrapbox.__getsbdata("#{project.host}/api/code/#{project.name}/#{URI.encode(title)}/#{src}")
23
+ end
24
+ @code
17
25
  end
18
26
 
19
27
  end
@@ -6,14 +6,30 @@ module Scrapbox
6
6
  def initialize(name,host='https://scrapbox.io')
7
7
  @name = name
8
8
  @host = host
9
+ @titles = nil
10
+ @pages = nil
9
11
  end
10
12
 
11
- def pages
13
+ def titles
12
14
  data = Scrapbox.__getsbdata("#{@host}/api/pages/#{@name}")
13
- JSON.parse(data)['pages'].collect { |page|
14
- page['title']
15
- }
15
+ unless @titles
16
+ @titles = JSON.parse(data)['pages'].collect { |page|
17
+ page['title']
18
+ }
19
+ end
20
+ @titles
16
21
  end
17
- end
18
22
 
23
+ def pages
24
+ unless @pages
25
+ @pages = {}
26
+ titles.each { |title|
27
+ page = Scrapbox::Page.new(self,title)
28
+ @pages[title] = page
29
+ }
30
+ end
31
+ @pages
32
+ end
33
+ end
34
+
19
35
  end
@@ -1,3 +1,3 @@
1
1
  module Scrapbox
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrapbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Masui