haravan_theme 0.0.25

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: 958bc1d2190cb079a934924bf3a28df2b88a8dd0
4
+ data.tar.gz: e6c7f14ca99cc56521c65f485b66cb277f456c28
5
+ SHA512:
6
+ metadata.gz: 2f047b5aafdf57fc35c877541ee68de77e8cf4d072644c464509ea865e3ba56d23e7dafca101fe5614bb50765ada2f47dfc2a7dc12c1aed998171d8a2605ae08
7
+ data.tar.gz: 35e6176b440366968a70eb6338ba67d0703bc065fefdda17546d603a1545c3783a9597424d400267fc0f595c20ade30858b60cf53f7da86ca83c43d9de6ec5f7
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .project
6
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ langauge: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ env:
7
+ - VERIFY_CERT=true
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # v0.0.23 (Unreleased)
2
+
3
+ * Adds support for OAuth access token based authentication -- gavinballard
4
+
5
+ # v0.0.22
6
+
7
+ * Parsing of Timber release feed to always retrieve latest release
8
+ * Minor documentation improvements
9
+
10
+ # v0.0.21
11
+
12
+ * Adds Locale support
13
+ * Running `theme replace` no longer deletes unwatched files if they are found on Haravan
14
+
15
+ # v0.0.20
16
+
17
+ * Fixes issue with unknown types raising exceptions -- csaunders
18
+
19
+ # v0.0.19
20
+
21
+ * Fixes issue with incorrectly detecting binary assets -- csaunders
22
+ * Properly handle unknown event types --
23
+
24
+ # v0.0.12
25
+
26
+ * Fixes issue where app tried uploading directories
27
+
28
+ # v0.0.11
29
+
30
+ * Locks JSON api version which fixed an issue with downloading large binary files -- Tyler Ball
31
+ * Respect API limits when downloading theme assets from Haravan API -- Chris Saunders
data/CONTRIBUTING ADDED
@@ -0,0 +1,6 @@
1
+ - If the issue doesn't exist, open one to start a discussion
2
+ - If the issue is fine (it probably is) start working on your patch
3
+ - Create a Pull Request
4
+ - Be sure to update CHANGELOG.md to include the details of your fix
5
+ - Go through code review
6
+ - Get it merged
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in haravan_theme.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Haravan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,171 @@
1
+
2
+ # Edit Your Haravan Theme Locally
3
+ [![Gem Version](https://badge.fury.io/rb/haravan_theme.svg)](http://badge.fury.io/rb/haravan_theme)
4
+
5
+ ![Haravan theme gem](https://dl.dropboxusercontent.com/u/669627/terminalreadme.png)
6
+
7
+ The Haravan theme gem is a command line tool that allows you to manage and edit theme files directly on your computer. This allows you to use your preferred code editing software opposed to the built in code editor available in the “Edit HTML/CSS” page of your store. Files can be manually or automatically uploaded, downloaded, and synced. Depending on how you develop themes and your personal preference, this can allow for a more enjoyable and streamlined workflow. If the command line is scary for you, check out the [Desktop Theme Editor app](http://apps.haravan.com/desktop-theme-editor).
8
+
9
+
10
+ ## Requirements
11
+ This gem works with OS X or Windows with Ruby 1.9.
12
+
13
+ First time installing Ruby on Windows? Try [Rubyinstaller](http://rubyinstaller.org/).
14
+
15
+
16
+ ## Configuration
17
+ ### Setting up Haravan Theme
18
+
19
+ First, you will need to set up a new private app to generate an API key and password. Go to **your_store.com**/admin/apps/private in your web browser.
20
+
21
+ Click on “Create a Private App” to generate the credentials for a new app. You will need the API key and the password of this newly generated app:
22
+
23
+ ![api-key-and-password](doc/API-key-and-password.jpg)
24
+
25
+ Navigate to the directory where you theme files live, or where you'd like them to be, and execute the following command:
26
+
27
+ `theme configure api_key password store_domain`
28
+
29
+ **Important:** enter the `store_domain` with no `http://`.
30
+
31
+ In your directory you should see a file named config.yml with your credentials. If you want, you may also edit the config.yml file directly and paste your API Key and Password in the appropriate area.
32
+
33
+
34
+ ### The config.yml File
35
+ The config.yml file contains the information needed for Haravan to authenticate requests and edit/update the theme files in the manner specified. Here is an example of what the contents in a typical `config.yml` file would look like:
36
+
37
+ ```yaml
38
+ ---
39
+ :api_key: 7a8da86d3dd730b67a357dedabaac5d6
40
+ :password: 552338ce0d3aba7fc501dcf99bc57a81
41
+ :store: little-plastics.myharavan.com
42
+ :theme_id:
43
+ :whitelist_files:
44
+ - directoryToUpload/
45
+ - importantFile.txt
46
+ :ignore_files:
47
+ - config/settings.html
48
+ ```
49
+
50
+
51
+ #### Here is a Breakdown of the Fields:
52
+
53
+ `api_key`
54
+
55
+ The API key generated in your private app.
56
+
57
+ `password`
58
+
59
+ The password generated in your private app.
60
+
61
+ `store`
62
+
63
+ The address of your store (note there is no leading http:// or https://)
64
+
65
+ `theme_id`
66
+
67
+ The theme id of the theme that should be responding to commands. If no theme id is specified, the currently active theme will be modified.
68
+
69
+ `whitelist_files`
70
+
71
+ Specifies which files and directories should be responding to changes. If nothing is specified, the `assets/, config/, layout/, snippets/, templates/ and locales/` directories will be modified according to commands entered.
72
+
73
+ `ignore_files`
74
+
75
+ Specifies which files should be explicitly ignored and not affected by any commands entered.
76
+
77
+ ### Alternative OAuth configuration (for advanced users)
78
+ As of v0.0.23, you can use a Haravan application's OAuth access token to authenticate with a store and manipulate theme files.
79
+
80
+ Once your application has obtained an access token through Haravan's regular OAuth authentication flow, run the following command to configure the gem:
81
+
82
+ `theme configure_oauth access_token store_domain`
83
+
84
+ The gem can then be used in exactly the same way as if you were authenticating via a Private App.
85
+
86
+ Note that the access token your Application has obtained ***must*** be valid for the `write_themes` scope in order to use the theme gem in this way.
87
+
88
+
89
+ ## Commands
90
+
91
+ `theme download`
92
+
93
+ Downloads the theme files from your store to your computer.
94
+
95
+ `theme upload path/to/file`
96
+
97
+ Uploads a single file to your store. You can also upload directories by using the wildcard character. The command `theme upload assets/*` will upload all files in the assets directory.
98
+
99
+ `theme remove path/to/file`
100
+
101
+ Remove a single file from your store. You can also remove directories by using the wildcard character, similar to the theme upload command. The command theme `remove assets/*` will remove all files in the assets directory.
102
+ `theme replace`
103
+
104
+ **This command can be destructive so it should be used with caution.**
105
+
106
+ This command replaces all store files with local files; it ensures the store theme files mirrors the files locally. If you are familiar with FTP or SFTP to upload files to a server, this is similar but not exactly the same. In addition to transferring files, it will delete any theme files in your store that are not present locally.
107
+
108
+ `theme watch`
109
+
110
+ Once this command is entered, it continuously monitors files for changes. If a change is detected, it automatically uploads that file to your store. This is similar to [grunt watch](https://github.com/gruntjs/grunt-contrib-watch). To stop theme watch press CRTL + C.
111
+ `theme open`
112
+
113
+ This command opens your store in the default browser specified on your computer.
114
+
115
+ `theme bootstrap api_key password store theme_name --version=[version]`
116
+
117
+ This command is useful if you are starting a brand new theme. It automatically populates your store with a fresh copy of the [Haravan Timber framework](http://haravan.github.io/Timber/). If you haven’t heard of Timber, it is a theme framework designed for specifically for Haravan themes, made by Haravan. If you enjoy using frameworks like [Bootstrap](http://getbootstrap.com/) or [Foundation](http://foundation.zurb.com/) for your projects, you’ll certainly find Timber useful.
118
+
119
+ The bootstrap command requires several parameters:
120
+
121
+ `api_key`
122
+
123
+ The same API key used in your config.yml file
124
+
125
+ `password`
126
+
127
+ The same password used in your config.yml file
128
+
129
+ `store`
130
+
131
+ The same store used in your config.yml file
132
+
133
+ `theme_name`
134
+
135
+ The name of the theme that will house the Timber framework files. A directory will be created with this name and all theme assets will be copied into it.
136
+
137
+ **Options**
138
+
139
+ `--version=[latest]`
140
+
141
+ This is the only option that you can provide. You can choose any [Timber release](https://github.com/Haravan/Timber/releases) by simply specifying it (i.e. `v2.0.2`). There are two special versions you can use, `master` and `latest`.
142
+
143
+ - `master` will download the latest build on the Timber master branch.
144
+ - `latest` will figure out what the most recent release is and use it.
145
+
146
+ ## Tips and Tricks
147
+ ### Edit and Preview Inactive Themes
148
+ In many cases you may want to work on a theme behind the scenes while your current theme is still active. To accomplish this there are two steps:
149
+
150
+ * Utilize the theme preview option in your Haravan store. This is a built in feature of Haravan outside the scope of Haravan theme.
151
+ You can find your theme ID by looking at the URL:
152
+
153
+ ![themes/THEME_ID/settings](doc/how_to_find_theme_id.png)
154
+
155
+ ## Common Problems
156
+ ### SocketError or SSL Certificate Validation Error on Windows
157
+ If you receive a SocketError or SSL certificate validation error when you try to run any theme command, your install may not have any valid SSL certificates.
158
+
159
+ In short, you can solve this problem by downloading [this file](http://curl.haxx.se/ca/cacert.pem) and placing it in `C:\RailsInstaller\`. The file should retain the name cacert.pem. Once this is done, run `set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem`. The Haravan theme commands should be working now. This technique will need to be repeated each time your computer boots up. For a more detailed and permanent solution check out these resources:
160
+
161
+ * [setting a the SSL_CERT_FILE environment variable on your system](http://www.computerhope.com/issues/ch000549.htm)
162
+ * [Download a cacert.pem file for RailsInstaller](https://gist.github.com/fnichol/867550)
163
+ * [Certificate failed after update](https://github.com/Haravan/haravan_theme/issues/103)
164
+
165
+
166
+ ## Important Notes
167
+ ### Prevent Resetting of Theme Settings
168
+ In some cases you may want to add `config/settings_json.js` to the `ignore_files` list in your config.yml file. When you save your the theme settings for your store, Haravan stores the current values in this file. If you upload your local copy of config/settings_json.js your current settings may be reset to default values if it does not contain the current settings data.
169
+
170
+ ### Sass Compilation
171
+ There is no need to compile your .scss files locally when using Haravan theme. They are automatically compiled upon upload and available as .css files on the web page, retaining the same filename.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'bundler'
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+ require 'haravan_theme'
5
+
6
+ task :default => [:spec]
7
+
8
+ Rake::TestTask.new 'spec' do |t|
9
+ ENV['test'] = 'true'
10
+ t.libs = ['lib', 'spec']
11
+ t.ruby_opts << '-rubygems'
12
+ t.verbose = true
13
+ t.test_files = FileList['spec/**/*_spec.rb']
14
+ end
15
+
16
+ desc "Update the built-in CA root certificate file"
17
+ task :update_cert_file do
18
+ require 'net/http'
19
+ require 'uri'
20
+ cert_uri = URI(HaravanTheme::REMOTE_CERT_FILE)
21
+ response = Net::HTTP.get_response(cert_uri)
22
+ if response.code == '200'
23
+ File.open(HaravanTheme::CA_CERT_FILE, 'wb') { |cert_file| cert_file << response.body }
24
+ else
25
+ fail "Could not download certificate bundle from #{cert_uri}"
26
+ end
27
+ end
28
+
data/bin/theme ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This allows haravan_theme to run easily from a git checkout without install.
4
+ # Hat tip to chriseppstein of Compass fame for the code for this
5
+ def fallback_load_path(path)
6
+ retried = false
7
+ begin
8
+ yield
9
+ rescue LoadError
10
+ unless retried
11
+ $: << path
12
+ retried = true
13
+ retry
14
+ end
15
+ raise
16
+ end
17
+ end
18
+
19
+ fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do
20
+ require 'haravan_theme'
21
+ require 'haravan_theme/cli'
22
+ require 'haravan_theme/releases'
23
+ require 'haravan_theme/api_checker'
24
+ end
25
+
26
+ HaravanTheme::Cli.start(ARGV)
Binary file
Binary file
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "haravan_theme/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "haravan_theme"
7
+ s.version = HaravanTheme::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["John Duff"]
10
+ s.email = ["john.duff@shopify.com"]
11
+ s.homepage = "https://github.com/Haravan/haravan_theme"
12
+ s.summary = %q{Command line tool for developing themes}
13
+ s.description = %q{Command line tool to help with developing Haravan themes. Provides simple commands to download, upload and delete files from a theme. Also includes the watch command to watch a directory and upload files as they change.}
14
+ s.license = 'MIT'
15
+
16
+ s.rubyforge_project = "haravan_theme"
17
+ s.add_dependency('thor', '>= 0.14.4')
18
+ s.add_dependency('httparty', '~> 0.13.0')
19
+ s.add_dependency('json', '~> 1.8.0')
20
+ s.add_dependency('mimemagic')
21
+ s.add_dependency('filewatcher')
22
+ s.add_dependency('launchy')
23
+
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'minitest', '>= 5.0.0'
26
+ s.add_development_dependency 'webmock'
27
+ s.add_development_dependency 'vcr'
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = ['lib']
33
+ end