cheatly 0.0.1
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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +1 -0
- data/bin/cheatly +11 -0
- data/cheatly.gemspec +26 -0
- data/lib/cheatly/version.rb +3 -0
- data/lib/cheatly.rb +73 -0
- data/sheets/gem_release.yml +45 -0
- data/sheets/strftime.yml +47 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzFkNTI0M2EyMTY4YjYyMmJlODlmZTQ3ZGY4Y2U4YzI4YjA5Mzg1MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzQxOWJiMzcxMmI3MWU3NWVkZjk3YThkNjg0NGQ5MTc5OGY5NGNmOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDA4NzI0NzY0MGNlMjNhZWUxNTBlMjNjZmYzY2I2YTkyYTFhZGEzNGQyNDQ3
|
10
|
+
M2JlZDBmNjg4ZDM0Njk5MjNiZTRiMDk3OTI1ZjdmN2RlNDI4NTgxY2ZmYjY2
|
11
|
+
MGQ3OWU0YTRjNmMzMmFhNzc2MDI2NzAyYmNiMGJhYjVkYTJjZTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjNmYzY1ZDVmZDc5NTQwYTEwYjdlMTExMTFkNDcwMjA4YjRhZTlmMGNkMzI0
|
14
|
+
ZjUyMWEzN2M1NGE1MTNkYjQ1ZTcwYTAxYzQ3NGEwNzBmNjFhNzQxNWE4MDk2
|
15
|
+
YTVkNTg3ZWZmMzc4ZDVkYzMwZWNkYzA4ZjViOWU3NmZkYjk2NzQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Arthur Neves
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Cheatly
|
2
|
+
|
3
|
+
This is a command line toolset to handle the cheat-sheets reposity located at [sheets](https://github.com/arthurnn/cheatly/tree/master/sheets) folder.
|
4
|
+
This gem is inspired by https://github.com/defunkt/cheat.
|
5
|
+
|
6
|
+
## Please, help. Adding a new cheat-sheet
|
7
|
+
|
8
|
+
Submit a PR, adding a file to `sheets` folder, with the cheat-sheet name.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
$ gem install cheatly
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
$ cheatly show gem_release
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
1. Fork it
|
21
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
22
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
23
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
24
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/cheatly
ADDED
data/cheatly.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cheatly/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cheatly"
|
8
|
+
spec.version = Cheatly::VERSION
|
9
|
+
spec.authors = ["Arthur Neves"]
|
10
|
+
spec.email = ["arthurnn@gmail.com"]
|
11
|
+
spec.description = %q{A cheat-sheet cli for a cheat repository}
|
12
|
+
spec.summary = %q{A cheat-sheet cli for a cheat repository}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "httparty", "~> 0.12.0"
|
22
|
+
spec.add_dependency "pager", "~> 1.0.1"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
data/lib/cheatly.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "cheatly/version"
|
2
|
+
require "base64"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require "httparty"
|
6
|
+
require "pager"
|
7
|
+
|
8
|
+
module Cheatly
|
9
|
+
class CLI
|
10
|
+
include Pager
|
11
|
+
|
12
|
+
def initialize(args)
|
13
|
+
@command = args.shift
|
14
|
+
@handle = args.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def sheet(handle)
|
18
|
+
sheet = Sheet.find(handle)
|
19
|
+
page
|
20
|
+
puts "#{sheet.title}:"
|
21
|
+
puts sheet.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def process
|
25
|
+
sheet(@handle)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Sheet
|
30
|
+
attr_accessor :title, :body
|
31
|
+
def initialize(title, body)
|
32
|
+
@title, @body = title, body
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
" #{@body.gsub("\r",'').gsub("\n", "\n ")}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.find(handle)
|
40
|
+
sheet_yaml = adapter.find("sheets/#{handle}.yml")
|
41
|
+
yml = YAML.load(sheet_yaml).first
|
42
|
+
t, b = yml.first, yml.last
|
43
|
+
Sheet.new(t, b)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.adapter
|
47
|
+
# @adapter ||= FileAdapter.new
|
48
|
+
@adapter ||= GithubAdapter.new
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class FileAdapter
|
53
|
+
def find(path)
|
54
|
+
File.read(path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class GithubAdapter
|
59
|
+
include HTTParty
|
60
|
+
base_uri 'https://api.github.com'
|
61
|
+
|
62
|
+
def base_path
|
63
|
+
"/repos/arthurnn/cheatly/contents"
|
64
|
+
end
|
65
|
+
|
66
|
+
def find(path)
|
67
|
+
response = self.class.get("#{base_path}/#{path}")
|
68
|
+
json = JSON.parse(response.body)
|
69
|
+
Base64.decode64(json["content"])
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
gem_release: ! "$ gem release your.gemspec # builds the gem and pushes it to
|
3
|
+
rubygems.org\n$ gem release # uses the first *.gemspec in the
|
4
|
+
current\n # working directory\n$ gem release --tag
|
5
|
+
\ # also executes gem tag\n$ gem release --key KEY # use the
|
6
|
+
specified API key from\n # ~/.gem/credentials\n$
|
7
|
+
gem release --host HOST # push to a gemcutter-compatible host other\n #
|
8
|
+
than rubygems.org\n$ gem release --quiet # suppress output status messages\n\n$
|
9
|
+
gem tag # creates a git tag and pushes to the origin\n #
|
10
|
+
git repository\n\n$ gem gemspec # generates a [gem_name].gemspec
|
11
|
+
using\n # Dir[\"{lib/**/*,[A-Z]*}\"]\n$ gem gemspec
|
12
|
+
--strategy git # uses s.files = `git ls-files app\n #
|
13
|
+
lib`.split(\"\\n\")\n\n$ gem bootstrap # generates a [gem_name].gemspec
|
14
|
+
using the\n # current directory name and scaffolds\n
|
15
|
+
\ # lib/[gem_name]/version.rb, README, test/\n$ gem
|
16
|
+
bootstrap your_gem # creates a your_gem directory, bootstraps\n #
|
17
|
+
your_gem and inits a git repo\n$ gem bootstrap --github # inits a git repo,
|
18
|
+
creates it on github and\n # pushes it to github
|
19
|
+
(requires git config\n # for github.user and github.token
|
20
|
+
to be set)\n\n$ gem bump # Bump the gem version to the next
|
21
|
+
patch or\n # pre-release level (e.g. 0.0.1 to 0.0.2,\n
|
22
|
+
\ # 1.0.0.pre1 to 1.0.0.pre2, 1.0.0.rc1 to\n #
|
23
|
+
1.0.0.rc2)\n$ gem bump --version 1.1.1 # Bump the gem version to the given
|
24
|
+
version\n # number\n$ gem bump --version major #
|
25
|
+
Bump the gem version to the next major\n # level
|
26
|
+
(e.g. 0.0.1 to 1.0.0)\n$ gem bump --version minor # Bump the gem version to
|
27
|
+
the next minor\n # level (e.g. 0.0.1 to 0.1.0)\n$
|
28
|
+
gem bump --version patch # Bump the gem version to the next patch\n #
|
29
|
+
level (e.g. 0.0.1 to 0.0.2)\n$ gem bump --version pre|rc|etc # Bump the gem version
|
30
|
+
to the next\n # pre-release level (e.g. `pre`: 1.0.0.pre1\n
|
31
|
+
\ # to 1.0.0.pre2, 0.0.1 to 0.0.2.pre1;\n #
|
32
|
+
`beta`: 1.0.0.beta1 to 1.0.0.beta2, 0.0.1\n # to
|
33
|
+
0.0.2.beta1)\n$ gem bump --push # Bump and push to the origin git
|
34
|
+
repository\n$ gem bump --tag # Bump and tag gem and pushes tags
|
35
|
+
to the\n # origin repository\n$ gem bump --release
|
36
|
+
\ # Bump and release gem\n$ gem bump --release --key KEY # Bump and
|
37
|
+
release the gem, using the\n # specified API key
|
38
|
+
from ~/.gem/credentials\n$ gem bump --release --host HOST # Bump and release the
|
39
|
+
gem to a\n # gemcutter-compatible host other than\n
|
40
|
+
\ # rubygems.org\n$ gem bump --release --quiet #
|
41
|
+
Bump and release the gem, suppressing\n # output
|
42
|
+
status messages\n$ gem bump --tag --release # Bump, tag, push and release
|
43
|
+
gem\n$ gem bump --no-commit # Bump the gem version but don't git commit\n
|
44
|
+
\ # (will be ignored if combined with push,\n #
|
45
|
+
tag or release)"
|
data/sheets/strftime.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
strftime: ! "Ruby 1.8.7\r\n %a - The abbreviated weekday name (“Sun”)\r\n %A - The
|
3
|
+
\ full weekday name (“Sunday”)\r\n %b - The abbreviated month name (“Jan”)\r\n
|
4
|
+
\ %B - The full month name (“January”)\r\n %c - The preferred local date and
|
5
|
+
time representation\r\n %d - Day of the month (01..31)\r\n %H - Hour of the day,
|
6
|
+
24-hour clock (00..23)\r\n %I - Hour of the day, 12-hour clock (01..12)\r\n %l
|
7
|
+
- Hour of the day, 12-hour clock without leading zero (1..12)\r\n %j - Day of the
|
8
|
+
year (001..366)\r\n %m - Month of the year (01..12)\r\n %M - Minute of the hour
|
9
|
+
(00..59)\r\n %p - Meridian indicator (“AM” or “PM”)\r\n %S - Second of the minute
|
10
|
+
(00..60)\r\n %U - Week number of the current year,\r\n starting with
|
11
|
+
the first Sunday as the first\r\n day of the first week (00..53)\r\n %W
|
12
|
+
- Week number of the current year,\r\n starting with the first Monday
|
13
|
+
as the first\r\n day of the first week (00..53)\r\n %w - Day of the week
|
14
|
+
(Sunday is 0, 0..6)\r\n %x - Preferred representation for the date alone, no time\r\n
|
15
|
+
\ %X - Preferred representation for the time alone, no date\r\n %y - Year without
|
16
|
+
a century (00..99)\r\n %Y - Year with century\r\n %Z - Time zone name\r\n %%
|
17
|
+
- Literal “%” character\r\n\r\n t = Time.now\r\n t.strftime(\"Printed on %m/%d/%Y\")
|
18
|
+
\ #=> \"Printed on 04/09/2003\"\r\n t.strftime(\"at %I:%M%p\") #=>
|
19
|
+
\"at 08:56AM\"\r\n\r\nRuby 1.9\r\n %a - The abbreviated weekday name (“Sun”)\r\n
|
20
|
+
\ %A - The full weekday name (“Sunday”)\r\n %b - The abbreviated month name
|
21
|
+
(“Jan”)\r\n %B - The full month name (“January”)\r\n %c - The preferred local
|
22
|
+
date and time representation\r\n %d - Day of the month (01..31)\r\n %e - Day of
|
23
|
+
the month,\r\n a single digit is preceded by a space (range ' 1' to '31')\r\n
|
24
|
+
\ %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)\r\n %H - Hour of the day,
|
25
|
+
24-hour clock (00..23)\r\n %I - Hour of the day, 12-hour clock (01..12)\r\n %j
|
26
|
+
- Day of the year (001..366)\r\n %L - Millisecond of the second (000..999)\r\n
|
27
|
+
\ %m - Month of the year (01..12)\r\n %M - Minute of the hour (00..59)\r\n %N
|
28
|
+
- Fractional seconds digits, default is 9 digits (nanosecond)\r\n %3N millisecond
|
29
|
+
(3 digits)\r\n %6N microsecond (6 digits)\r\n %9N nanosecond
|
30
|
+
(9 digits)\r\n %12N picosecond (12 digits)\r\n %p - Meridian indicator
|
31
|
+
(“AM” or “PM”)\r\n %P - Meridian indicator (“am” or “pm”)\r\n %s - Number
|
32
|
+
of seconds since 1970-01-01 00:00:00 UTC.\r\n %S - Second of the minute (00..60)\r\n
|
33
|
+
\ %U - Week number of the current year,\r\n starting with the first Sunday
|
34
|
+
as the first\r\n day of the first week (00..53)\r\n %W - Week number
|
35
|
+
\ of the current year,\r\n starting with the first Monday as the first\r\n
|
36
|
+
\ day of the first week (00..53)\r\n %w - Day of the week (Sunday is 0,
|
37
|
+
0..6)\r\n %x - Preferred representation for the date alone, no time\r\n %X - Preferred
|
38
|
+
representation for the time alone, no date\r\n %y - Year without a century (00..99)\r\n
|
39
|
+
\ %Y - Year with century\r\n %z - Time zone offset from UTC (+/-0000, e.g. EST
|
40
|
+
= -0500)\r\n %Z - Time zone name\r\n %% - Literal “%” character\r\n\r\n t =
|
41
|
+
Time.now #=> 2007-11-19 08:37:48 -0600\r\n t.strftime(\"Printed
|
42
|
+
on %m/%d/%Y\") #=> \"Printed on 11/19/2007\"\r\n t.strftime(\"at %I:%M%p\")
|
43
|
+
\ #=> \"at 08:37AM\"\r\n\r\nControlling leading padding in Ruby 1.9\r\n
|
44
|
+
\ These codes work with any format code. %I is used as an example.\r\n %-I - remove
|
45
|
+
any leading zeroes or spaces (“1”)\r\n %_I - force a leading space (and no leading
|
46
|
+
zeroes) if necessary (“ 1”)\r\n %0I - force a leading zero (and no leading spaces)
|
47
|
+
if necessary (“01”)"
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cheatly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arthur Neves
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pager
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A cheat-sheet cli for a cheat repository
|
70
|
+
email:
|
71
|
+
- arthurnn@gmail.com
|
72
|
+
executables:
|
73
|
+
- cheatly
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/cheatly
|
83
|
+
- cheatly.gemspec
|
84
|
+
- lib/cheatly.rb
|
85
|
+
- lib/cheatly/version.rb
|
86
|
+
- sheets/gem_release.yml
|
87
|
+
- sheets/strftime.yml
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.1.10
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A cheat-sheet cli for a cheat repository
|
112
|
+
test_files: []
|