stackbuilders-campfire_export 0.4.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 189d237398fa8a8627af4aa60e4b904175053125
4
+ data.tar.gz: 015646fd1de14d6bb230143653347da65b564ae0
5
+ SHA512:
6
+ metadata.gz: f7e312835ff6b746db2cd8a156d9eb229cd1b0476b436fae5f0ddcedddaebd4ae60c124320822a9eee7cf4d76c0f6a09bb27ac6f4a736672a6db7415bdada31a
7
+ data.tar.gz: a43541ddc5e78f6daa9485d014eaac8f8f0bd38043902fc60245ea98758178eebe43c9cf16bd9d4b235ddbc49d39c66666167e292a9941a7168897b496c0e25b
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ # Ruby
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ Gemfile.lock
15
+ pkg/*
16
+
17
+
18
+ # YARD artifacts
19
+ .yardoc
20
+ _yardoc
21
+ doc/
22
+
23
+ # Emacs
24
+ *~
25
+ \#*\#
26
+ /.emacs.desktop
27
+ /.emacs.desktop.lock
28
+ .elc
29
+ auto-save-list
30
+ tramp
31
+
32
+ # OSX
33
+ .DS_Store
34
+ Icon?
35
+
36
+ # Thumbnails
37
+ ._*
38
+
39
+ # Files that might appear on external disk
40
+ .Spotlight-V100
41
+ .Trashes
42
+
43
+ # project-specific
44
+ campfire
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in campfire_export.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,160 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and
12
+ distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by the
15
+ copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all other
18
+ entities that control, are controlled by, or are under common control with
19
+ that entity. For the purposes of this definition, "control" means (i) the
20
+ power, direct or indirect, to cause the direction or management of such
21
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
22
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of such
23
+ entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
26
+ permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation source, and
30
+ configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical transformation or
33
+ translation of a Source form, including but not limited to compiled object
34
+ code, generated documentation, and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or Object form,
37
+ made available under the License, as indicated by a copyright notice that is
38
+ included in or attached to the work (an example is provided in the Appendix
39
+ below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
42
+ is based on (or derived from) the Work and for which the editorial revisions,
43
+ annotations, elaborations, or other modifications represent, as a whole, an
44
+ original work of authorship. For the purposes of this License, Derivative
45
+ Works shall not include works that remain separable from, or merely link (or
46
+ bind by name) to the interfaces of, the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including the original
49
+ version of the Work and any modifications or additions to that Work or
50
+ Derivative Works thereof, that is intentionally submitted to Licensor for
51
+ inclusion in the Work by the copyright owner or by an individual or Legal
52
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
53
+ of this definition, "submitted" means any form of electronic, verbal, or
54
+ written communication sent to the Licensor or its representatives, including
55
+ but not limited to communication on electronic mailing lists, source code
56
+ control systems, and issue tracking systems that are managed by, or on behalf
57
+ of, the Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise designated
59
+ in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
62
+ of whom a Contribution has been received by Licensor and subsequently
63
+ incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
66
+ License, each Contributor hereby grants to You a perpetual, worldwide,
67
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
68
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
69
+ sublicense, and distribute the Work and such Derivative Works in Source or
70
+ Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of this
73
+ License, each Contributor hereby grants to You a perpetual, worldwide,
74
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
75
+ section) patent license to make, have made, use, offer to sell, sell, import,
76
+ and otherwise transfer the Work, where such license applies only to those
77
+ patent claims licensable by such Contributor that are necessarily infringed by
78
+ their Contribution(s) alone or by combination of their Contribution(s) with
79
+ the Work to which such Contribution(s) was submitted. If You institute patent
80
+ litigation against any entity (including a cross-claim or counterclaim in a
81
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
82
+ constitutes direct or contributory patent infringement, then any patent
83
+ licenses granted to You under this License for that Work shall terminate as of
84
+ the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
87
+ Derivative Works thereof in any medium, with or without modifications, and in
88
+ Source or Object form, provided that You meet the following conditions:
89
+
90
+ You must give any other recipients of the Work or Derivative Works a copy of
91
+ this License; and
92
+
93
+ You must cause any modified files to carry prominent notices stating that You
94
+ changed the files; and
95
+
96
+ You must retain, in the Source form of any Derivative Works that You
97
+ distribute, all copyright, patent, trademark, and attribution notices from the
98
+ Source form of the Work, excluding those notices that do not pertain to any
99
+ part of the Derivative Works; and
100
+
101
+ If the Work includes a "NOTICE" text file as part of its distribution, then
102
+ any Derivative Works that You distribute must include a readable copy of the
103
+ attribution notices contained within such NOTICE file, excluding those notices
104
+ that do not pertain to any part of the Derivative Works, in at least one of
105
+ the following places: within a NOTICE text file distributed as part of the
106
+ Derivative Works; within the Source form or documentation, if provided along
107
+ with the Derivative Works; or, within a display generated by the Derivative
108
+ Works, if and wherever such third-party notices normally appear. The contents
109
+ of the NOTICE file are for informational purposes only and do not modify the
110
+ License. You may add Your own attribution notices within Derivative Works that
111
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
112
+ provided that such additional attribution notices cannot be construed as
113
+ modifying the License. You may add Your own copyright statement to Your
114
+ modifications and may provide additional or different license terms and
115
+ conditions for use, reproduction, or distribution of Your modifications, or
116
+ for any such Derivative Works as a whole, provided Your use, reproduction, and
117
+ distribution of the Work otherwise complies with the conditions stated in this
118
+ License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
121
+ Contribution intentionally submitted for inclusion in the Work by You to the
122
+ Licensor shall be under the terms and conditions of this License, without any
123
+ additional terms or conditions. Notwithstanding the above, nothing herein
124
+ shall supersede or modify the terms of any separate license agreement you may
125
+ have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names,
128
+ trademarks, service marks, or product names of the Licensor, except as
129
+ required for reasonable and customary use in describing the origin of the Work
130
+ and reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
133
+ writing, Licensor provides the Work (and each Contributor provides its
134
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
135
+ KIND, either express or implied, including, without limitation, any warranties
136
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or redistributing the Work and assume any risks
139
+ associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
142
+ tort (including negligence), contract, or otherwise, unless required by
143
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
144
+ writing, shall any Contributor be liable to You for damages, including any
145
+ direct, indirect, special, incidental, or consequential damages of any
146
+ character arising as a result of this License or out of the use or inability
147
+ to use the Work (including but not limited to damages for loss of goodwill,
148
+ work stoppage, computer failure or malfunction, or any and all other
149
+ commercial damages or losses), even if such Contributor has been advised of
150
+ the possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work
153
+ or Derivative Works thereof, You may choose to offer, and charge a fee for,
154
+ acceptance of support, warranty, indemnity, or other liability obligations
155
+ and/or rights consistent with this License. However, in accepting such
156
+ obligations, You may act only on Your own behalf and on Your sole
157
+ responsibility, not on behalf of any other Contributor, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any liability
159
+ incurred by, or claims asserted against, such Contributor by reason of your
160
+ accepting any such warranty or additional liability.
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ [![Build Status](https://travis-ci.org/stackbuilders/campfire_export.png)](https://travis-ci.org/stackbuilders/campfire_export)
2
+
3
+ # campfire_export #
4
+
5
+ ## Quick Start ##
6
+
7
+ $ sudo gem install stackbuilders-campfire_export
8
+ $ campfire_export
9
+
10
+ ## Intro ##
11
+
12
+ I had an old, defunct [Campfire](http://campfirenow.com/) account with five
13
+ years' worth of transcripts in it, some of them hilarious, others just
14
+ memorable. Unfortunately, Campfire doesn't currently have an export function;
15
+ instead it provides pages of individual transcripts. I wanted a script to
16
+ export everything from all five years, using the Campfire API.
17
+
18
+ I found a [Gist](https://gist.github.com) that looked pretty good:
19
+
20
+ * [https://gist.github.com/821553](https://gist.github.com/821553)
21
+
22
+ but it wasn't quite right. So this is my modification, converted to a GitHub
23
+ repo and a [Ruby gem](http://docs.rubygems.org/read/chapter/1).
24
+
25
+ ## Features ##
26
+
27
+ * Saves HTML, XML, and plaintext versions of chat transcripts.
28
+ * Exports uploaded files to a day-specific subdirectory for easy access.
29
+ * Reports and logs export errors so you know what you're missing.
30
+ * Obsessively confirms that everything was exported correctly.
31
+
32
+ ## Installing ##
33
+
34
+ [Ruby 1.9.3](http://www.ruby-lang.org/en/downloads/) or later is required.
35
+ [RubyGems](https://rubygems.org/pages/download) is also required -- I'd
36
+ recommend having the latest version of RubyGems installed before starting.
37
+
38
+ Once you are set up, to install, run the following:
39
+
40
+ $ sudo gem install campfire_export
41
+
42
+ ## Configuring ##
43
+
44
+ There are a number of configuration variables required to run the export. The
45
+ export script will prompt you for these; just run it and away you go. If you
46
+ want to run the script repeatedly or want to control the start and end date of
47
+ the export, you can create a `.campfire_export.yaml` file in your home
48
+ directory using this template:
49
+
50
+ # Your Campfire subdomain (for 'https://myco.campfirenow.com', use 'myco').
51
+ subdomain: myco
52
+
53
+ # Your Campfire API token (see "My Info" on your Campfire site).
54
+ api_token: abababababababababababababababababababab
55
+
56
+ # OPTIONAL: Export start date - the first transcript you want exported.
57
+ # Uncomment to set. Defaults to the date each room was created.
58
+ #start_date: 2010/1/1
59
+
60
+ # OPTIONAL: Export end date - the last transcript you want exported.
61
+ # Uncomment to set. Defaults to the date of the last comment in each room.
62
+ #end_date: 2010/12/31
63
+
64
+ The `start_date` and `end_date` variables are inclusive (that is, if your
65
+ end date is Dec 31, 2010, a transcript for that date will be downloaded), and
66
+ both are optional. If they are omitted, export will run from the date each
67
+ Campfire room was created, until the date of the last message in that room.
68
+
69
+ ## Exporting ##
70
+
71
+ Just run `campfire_export` and your transcripts will be exported into a
72
+ `campfire` directory in the current directory, with subdirectories for each
73
+ site/room/year/month/day. In those directories, any uploaded files will be
74
+ saved with their original filenames, in a directory named for the upload ID
75
+ (since transcripts often have the same filename uploaded multiple times, e.g.
76
+ `Picture 1.png`). (Note that rooms and uploaded files may have odd filenames
77
+ -- for instance, spaces in the file/directory names.) Errors that happen
78
+ trying to export will be logged to `campfire/export_errors.txt`.
79
+
80
+ The Gist I forked had a plaintext transcript export, which I've kept in as
81
+ `transcript.txt` in each directory. However, the original XML and HTML are now
82
+ also saved as `transcript.xml` and `transcript.html`, which could be useful.
83
+
84
+ Days which have no messages posted will be ignored, so the resulting directory
85
+ structure will be sparse (no messages == no directory).
86
+
87
+ ## Credit ##
88
+
89
+ First, thanks a ton to [Jeffrey Hardy](https://github.com/packagethief) from
90
+ 37signals, who helped me track down some bugs in my code as well as some
91
+ confusion in what I was getting back from Campfire. His patient and determined
92
+ help made it possible to get this working. Thanks, Jeff!
93
+
94
+ Also, thanks much for all the help, comments and contributions:
95
+
96
+ * [Brad Greenlee](https://github.com/bgreenlee)
97
+ * [Andre Arko](https://github.com/indirect)
98
+ * [Brian Donovan](https://github.com/eventualbuddha)
99
+ * [Andrew Wong](https://github.com/andrewwong1221)
100
+ * [Junya Ogura](https://github.com/juno)
101
+ * [Chase Lee](https://github.com/chaselee)
102
+ * [Alex Hofsteede](https://github.com/alex-hofsteede)
103
+ * [Justin Leitgeb](https://github.com/jsl)
104
+
105
+ As mentioned above, some of the work on this was done by other people. The
106
+ Gist I forked had contributions from:
107
+
108
+ * [Pat Allan](https://github.com/freelancing-god)
109
+ * [Bruno Mattarollo](https://github.com/bruno)
110
+ * [bf4](https://github.com/bf4)
111
+
112
+ Thanks, all!
113
+
114
+ - Marc Hedlund, marc@precipice.org
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+ rescue LoadError
11
+ # no rspec available
12
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2011 Marc Hedlund <marc@precipice.org>
4
+
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # campfire_export -- export Campfire transcripts and uploaded files.
18
+ #
19
+ # Since Campfire (www.campfirenow.com) doesn't provide an export feature,
20
+ # this script implements one via the Campfire API.
21
+ #
22
+ # See https://github.com/precipice/campfire_export/blob/master/README.md
23
+ # for more information on using this script.
24
+
25
+ lib = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
26
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
27
+
28
+ require 'campfire_export'
29
+
30
+ def config_date(config, date_key)
31
+ date_str = config.fetch(date_key, nil)
32
+ date_str.nil? ? nil : Date.parse(date_str)
33
+ end
34
+
35
+ def ensure_config_for(config, key, prompt)
36
+ value = config.fetch(key, "")
37
+ while value == ""
38
+ print "#{prompt}: "
39
+ value = gets.chomp
40
+ end
41
+ config[key] = value
42
+ end
43
+
44
+ config = {}
45
+ config_file = File.join(ENV['HOME'], '.campfire_export.yaml')
46
+
47
+ if File.exists?(config_file) and File.readable?(config_file)
48
+ config = YAML.load_file(config_file)
49
+ end
50
+
51
+ ensure_config_for(config, 'subdomain',
52
+ "Your Campfire subdomain (for 'https://myco.campfirenow.com', use 'myco')")
53
+ ensure_config_for(config, 'api_token',
54
+ "Your Campfire API token (see 'My Info' on your Campfire site)")
55
+
56
+ begin
57
+ account = CampfireExport::Account.new(config['subdomain'],
58
+ config['api_token'])
59
+ account.find_timezone
60
+ account.rooms.each do |room|
61
+ room.export(config_date(config, 'start_date'),
62
+ config_date(config, 'end_date'))
63
+ end
64
+ rescue => e
65
+ puts "Unable to export account: #{e}"
66
+ end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "campfire_export/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "stackbuilders-campfire_export"
7
+ s.version = CampfireExport::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Marc Hedlund", "Justin Leitgeb"]
10
+ s.email = ["marc@precipice.org", "justin@stackbuilders.com"]
11
+ s.license = "Apache 2.0"
12
+ s.homepage = "https://github.com/stackbuilders/campfire_export"
13
+ s.summary = "Export transcripts and uploaded files from your 37signals' Campfire account."
14
+
15
+ s.description = %{Exports content from all rooms in a
16
+ 37signals Campfire account. Creates a directory containing transcripts
17
+ and content uploaded to each one of your rooms. Can be configured to
18
+ recognize start and end date of content export.}
19
+
20
+ s.rubyforge_project = "campfire_export"
21
+ s.required_ruby_version = '>= 1.9.3'
22
+
23
+ s.add_development_dependency "bundler", "~> 1"
24
+ s.add_development_dependency "rake", "~> 10"
25
+ s.add_development_dependency "rspec", "~> 2.6"
26
+
27
+ s.add_dependency "tzinfo", "~> 1.2"
28
+ s.add_dependency "httparty", "~> 0.13"
29
+ s.add_dependency "nokogiri", "~> 1.6"
30
+ s.add_dependency "retryable", "~> 2.0"
31
+
32
+ s.files = `git ls-files`.split("\n")
33
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
34
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
35
+ s.require_paths = ["lib"]
36
+ end