atlas2ipynb 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmNkZjVkNDUzNjE5MjI5NzFhODAyZDYwZTE5MmQwNWNiMjRmOGZhMQ==
4
+ NjYyYjMwOWM0MzI3YzRjN2ZlZTQyY2U5NzVhMmIzNjBjYWNjMmEzNA==
5
5
  data.tar.gz: !binary |-
6
- ZDAxNzdjODhiYjY1NjI1OGIyMjg3ZDk2YThkZWMzMGFhOGVlOTNjMg==
6
+ Y2JlNjJlNmQ5ODJkMzNjZGUxODQ5YjlmMDRkZWNmNWI1NDM5ZmVkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGJiMDdiOWNmYWU4NTM0ZmVlNTFhZjEzNjg0ODI2MzFlOTliZmViODMxODQ4
10
- NzM4ZjgzMDNkNjE1OGZiMDQyMDY2OTdhMzQyNjFjMjZlM2EyYmE1MWIzZThm
11
- NGRlOWMxNzhlMTFhNmI3YmUxMzhlYTNlZjUwM2Q4NTMzYmI1YjM=
9
+ NzEzMjBlZWQ1NjFmNmEwNmQxMzEzYWQyYTUzODliNmVkNjlmZjg1NmJhNDJj
10
+ NGVhMWY4N2EzYWNiMWUzM2MxZGM1NGI3NzBiNTZlODk1OWI2MTQ3NTQ2NDUy
11
+ ZWIwNWFlNzc4YzY1YzRmY2FiYzc2YWU5ZDQwMzg5Yjg1YTVlNDg=
12
12
  data.tar.gz: !binary |-
13
- NGE3MDJhZjFkNzc5Y2QwNDJjMTEzOTRkNWE4NjhiNjZiYzgxNmFlMmVlNjA0
14
- NWVkNjJjNGZiNGFmMDRmY2M4ZDIwMmExMzNhMzlmNDZlYTJjZjgzNGFjMzgy
15
- NmJhYmE2MDliYTQ3NTdiNjA4ZDg4N2E1NWMyMjkwYjNiNWMyYzk=
13
+ Njg3OWRiNGU0MWI4YTMwYTIyMDAzYzg0MzJmMjNiZTFkMDU0MWM2NTM1ZmUw
14
+ OGQxYmE0NzViYjgzN2E4NzM3ZDk3MTNmMDNjODIzMTcxYjk2MWEyMGJhNWUw
15
+ MjNjYTJiNjgyZWYyM2E1M2MyMGM1NTkzNTllMTg4NTgyYTdmMGQ=
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Atlas2ipynb
2
2
 
3
- This gem converts the HTML files from Atlas into iPython Notebooks.
3
+ This gem converts the HTML files from Atlas into iPython Notebooks. Basically, it uses the fact that HTML is considered valid markdown, so the gem basically just flattens the output from the HTML build from Atlas and makes each element into a corresponding ipynb "cell".
4
+
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,18 +19,25 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- Here's what you need to do:
22
+ To use this gem, you write your project in http://atlas.oreilly.com[Atlas]. Once you get a working HTML build, can generate a notebook like this:
23
+
24
+ ```
25
+ atlas2ipynb _ATLAS-API-TOKEN_ _PROJECT-NAME_
26
+ ````
27
+
28
+ For example:
29
+
30
+ ```
31
+ atlas2ipynb r1pB4y95uMxT3m8t9zRf oreillymedia/razzpisampler
32
+ ````
22
33
 
23
- * Write your project in http://atlas.oreilly.com[Atlas]
24
- * Get a working HTML build
25
- * Download and unzip the build
26
- * Run "atlas2ipynb" in the directory where you downloaded the files
27
- * Start the iPytnon notebook server
34
+ Note that you must have *curl* and *unzip* installed to (respectively) download and unpack the build.
28
35
 
29
36
  ## TODO:
30
37
 
31
- * Integrate the atlas-api gem so that you can also build, download, unzip, and convert directly from the command line
38
+ * The converter assumes that HTML is valid markdown per the markdown spec, but ipython 2.0 seems to say that embedded markdown will never be trusted. If so, the approah here won't work.
32
39
 
40
+
33
41
  ## Contributing
34
42
 
35
43
  1. Fork it ( http://github.com/<my-github-username>/atlas2ipynb/fork )
data/atlas2ipynb.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "atlas2ipynb"
7
- spec.version = "0.0.7"
7
+ spec.version = "0.0.8"
8
8
  spec.authors = ["Andrew Odewahn"]
9
9
  spec.email = ["odewahn@oreilly.com"]
10
10
  spec.summary = %q{Converts Atlas HTML build into iPythyon Notebooks.}
data/bin/atlas2ipynb CHANGED
@@ -1,9 +1,69 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- require 'rubygems'
4
+ require 'atlas-api'
5
5
  require 'atlas2ipynb'
6
6
 
7
+ ENDPOINT = "https://atlas.oreilly.com/api"
7
8
 
8
- c = Atlas2ipynb::Converter.new
9
- c.convert!
9
+ atlas_token=ARGV[0]
10
+ project = ARGV[1]
11
+ branch="master"
12
+
13
+ fn = project.split("/").pop
14
+
15
+ client = Atlas::Api::Client.new(
16
+ :auth_token => atlas_token,
17
+ :api_endpoint => ENDPOINT
18
+ )
19
+
20
+ query = {
21
+ :project => project,
22
+ :formats => "html",
23
+ :branch => branch
24
+ }
25
+
26
+ #
27
+ # Run the build and display the error messages
28
+ #
29
+ puts "Building #{project}"
30
+ @last_response = client.build_and_poll(query)
31
+
32
+ @last_response.status.each do |format|
33
+ puts "#{format.format.upcase} Build Info"
34
+ puts "--------------------------------------------------"
35
+
36
+ if format.message.is_a?(Hash)
37
+ format.message.each do |k,v|
38
+ puts "#{k}".capitalize
39
+ if v.is_a?(Array)
40
+ v.each do |me|
41
+ puts "- #{me}"
42
+ end
43
+ else
44
+ puts "- #{v}"
45
+ end
46
+ end
47
+ else
48
+ puts "#{format.message}"
49
+ end
50
+
51
+ puts ""
52
+ end
53
+
54
+ #
55
+ # Download and unzip the HTML build, and then convert it to ipynb
56
+ #
57
+ @last_response.status.each do |format|
58
+ puts "Downloading #{project}"
59
+ `curl #{format.download_url} > #{fn}.zip`
60
+ `unzip #{fn}.zip -d #{fn}`
61
+ Dir.chdir("#{Dir.pwd}/#{fn}"){
62
+ converter = Atlas2ipynb::Converter.new
63
+ converter.convert!
64
+ }
65
+ end
66
+
67
+ puts "\nAssuming things when ok, you can view the notebook by:"
68
+ puts " cd #{fn}"
69
+ puts " nbserver"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas2ipynb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Odewahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler