circule 0.1.0 → 0.1.4

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: 9449a7b91abcb3058201ee66d2c44925ab3cadd958421731a0269de135556e09
4
- data.tar.gz: f6bc4ede2a8ef059e4cea8e9a02a40203c157b59dd4ba2a4e3e573627b8c1b0b
3
+ metadata.gz: d43165d03d518eb31001ab176b1200778d528a8586fb984b63946bd728c79051
4
+ data.tar.gz: 5a9fc83e8949085d4fcf756bef38d298d8272bfb59eeb602295a68b04fa41e61
5
5
  SHA512:
6
- metadata.gz: 8ae5266a7208c0b6dfacc7e6dcacf0f35b04aa57a0c80ce445e5c529d8eb329c4547de66ab56830f511116b9ba27299ed09d5c0e2f861d73248fa1ccb1b7cf6d
7
- data.tar.gz: 4672cce80a11799eeccc8ef1d29a93fe4d4a144cf4aaeea21a520fe7bb7ff7627b94c5feef3edad7269adfbfa8e087af5bde82c1d5e356485283e155dd4452f6
6
+ metadata.gz: 34c059aea8a7919bd2c2316b518f5eeb47c4884cc06082f4defed64e736b1263aa4bf8c5dcde9d3956b1f2e2e433d258d7b3b75c59c330c22959e2cc2bbfc0da
7
+ data.tar.gz: d48266b32c4b2e876de388a1c5485e4f671159f958e2e1b6023c9b3468714e58b0b6c59d06fb813114fcb05c5d9d9480f103b836a2f53b2770c79e2b23e96ef5
data/.rubocop.yml CHANGED
@@ -1,13 +1,93 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.7
4
+
5
+ Layout/ExtraSpacing:
6
+ Enabled: false
7
+
8
+ Layout/FirstHashElementIndentation:
9
+ Enabled: false
10
+
11
+ Layout/HashAlignment:
12
+ Enabled: false
13
+
14
+ Layout/LeadingCommentSpace:
15
+ Enabled: false
16
+
17
+ Layout/LineLength:
18
+ Max: 160
19
+
20
+ Layout/MultilineMethodCallBraceLayout:
21
+ Enabled: false
22
+
23
+ Layout/MultilineMethodCallIndentation:
24
+ Enabled: false
25
+
26
+ Layout/SpaceAroundOperators:
27
+ Enabled: false
28
+
29
+ Layout/SpaceBeforeFirstArg:
30
+ Enabled: false
31
+
32
+ Layout/SpaceBeforeSemicolon:
33
+ Enabled: false
34
+
35
+ Layout/SpaceInsideArrayLiteralBrackets:
36
+ Enabled: false
37
+
38
+ Lint/AmbiguousOperator:
39
+ Enabled: false
40
+
41
+ Lint/AmbiguousOperatorPrecedence:
42
+ Enabled: false
43
+
44
+ Lint/EmptyWhen:
45
+ Enabled: false
46
+
47
+ Lint/Void:
48
+ Enabled: false
49
+
50
+ Metrics/AbcSize:
51
+ Enabled: false
52
+
53
+ Metrics/BlockLength:
54
+ Enabled: false
55
+
56
+ Metrics/MethodLength:
57
+ Enabled: false
58
+
59
+ Naming/MethodParameterName:
60
+ Enabled: false
61
+
62
+ Metrics/ParameterLists:
63
+ Enabled: false
64
+
65
+ Naming/MemoizedInstanceVariableName:
66
+ Enabled: false
67
+ EnforcedStyleForLeadingUnderscores: required
68
+
69
+ Style/BlockDelimiters:
70
+ EnforcedStyle: semantic
71
+ BracesRequiredMethods: [button, command, entry, frame, label, spinbox]
72
+
73
+ Style/ClassAndModuleChildren:
74
+ EnforcedStyle: compact
75
+
76
+ Style/RescueModifier:
77
+ Enabled: false
78
+
79
+ Style/Semicolon:
80
+ AllowAsExpressionSeparator: true
3
81
 
4
82
  Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
83
+ EnforcedStyle: single_quotes
7
84
 
8
85
  Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
86
  EnforcedStyle: double_quotes
11
87
 
12
- Layout/LineLength:
13
- Max: 120
88
+ Style/TrailingCommaInArguments:
89
+ Enabled: false
90
+ EnforcedStyleForMultiline: consistent_comma
91
+
92
+ Style/TrailingCommaInHashLiteral:
93
+ EnforcedStyleForMultiline: consistent_comma
data/Gemfile CHANGED
@@ -10,3 +10,7 @@ gem 'rake', '~> 13.0'
10
10
  gem 'minitest', '~> 5.0'
11
11
 
12
12
  gem 'rubocop', '~> 1.7'
13
+ gem 'rubocop-minitest'
14
+ gem 'rubocop-rake'
15
+
16
+ #em 'glimmer-dsl-tk'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- circule (0.1.0)
4
+ circule (0.1.4)
5
5
  chunky_png
6
6
 
7
7
  GEM
@@ -28,6 +28,10 @@ GEM
28
28
  unicode-display_width (>= 1.4.0, < 3.0)
29
29
  rubocop-ast (1.12.0)
30
30
  parser (>= 3.0.1.1)
31
+ rubocop-minitest (0.15.2)
32
+ rubocop (>= 0.90, < 2.0)
33
+ rubocop-rake (0.6.0)
34
+ rubocop (~> 1.0)
31
35
  ruby-progressbar (1.11.0)
32
36
  unicode-display_width (2.1.0)
33
37
 
@@ -39,6 +43,8 @@ DEPENDENCIES
39
43
  minitest (~> 5.0)
40
44
  rake (~> 13.0)
41
45
  rubocop (~> 1.7)
46
+ rubocop-minitest
47
+ rubocop-rake
42
48
 
43
49
  BUNDLED WITH
44
50
  2.2.27
data/README.md CHANGED
@@ -1,11 +1,18 @@
1
1
  # Circule
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you
4
- need to be able to package up your Ruby library into a gem. Put your
5
- Ruby code in the file `lib/circule`. To experiment with that code, run
6
- `bin/console` for an interactive prompt.
3
+ Generate an icon of overlapping circles derived from a hash.
7
4
 
8
- TODO: Delete this and the text above, and describe your gem
5
+ 1. Slice the hash into 16-bit slices starting at bit `bn`, stepping `s`
6
+ bits at a time, ending after bit `bn`.
7
+
8
+ 2. From each slice define a circle such that bits 0 through 4 is the `x`
9
+ coordinate of the center, bits 5 through 9 is the `y` coordinate of
10
+ the center, and bits 10 through 15 is the radius of the circle.
11
+
12
+ 3. Each pixel in the output will be colored based on the number of
13
+ circles that point is inside.
14
+
15
+ The [demo video](circule-demo.mp4) shows how the final image is composed.
9
16
 
10
17
  ## Installation
11
18
 
@@ -25,7 +32,33 @@ Or install it yourself as:
25
32
 
26
33
  ## Usage
27
34
 
28
- TODO: Write usage instructions here
35
+ ### CLI Options
36
+
37
+ | Short Option | Long Option | Description |
38
+ |--------------|---------------|----------------------------------|
39
+ | -h HEXSTRING | --hex | Use this hash |
40
+ | -b INTEGER | --btc-block | Use hash from this bitcoin block |
41
+ | -0 INTEGER | --bit0 | Starting bit |
42
+ | -s INTEGER | --step | Step bit |
43
+ | -n INTEGER | --bitn | Starting bit |
44
+ | -c INTEGER | --canvas | Canvas size |
45
+ | -x INTEGER | --ox | Offset x |
46
+ | -y INTEGER | --oy | Offset y |
47
+ | -z INTEGER | --zoom | Zoom in GUI |
48
+ | -f FILENAME | --file | Use hash from file |
49
+ | -s FILENAME | --save | Save image to file |
50
+ | -g | --gui | Run GUI (requires glimmer & tk) |
51
+ | -i | --interactive | Run GUI with pry |
52
+
53
+ ### CLI Example(s)
54
+
55
+ The icon for this project on GitLab:
56
+ ```
57
+ $ echo -n circule | sha256sum
58
+ 4b9ae43c4e15486ce131f733eff14547764623d27aa5d1d9aff45b67528f0b60 -
59
+
60
+ $ circule -h 4b9ae43c4e15486ce131f733eff14547764623d27aa5d1d9aff45b67528f0b60 -s /tmp/circule.png
61
+ ```
29
62
 
30
63
  ## Development
31
64
 
@@ -41,7 +74,7 @@ push the `.gem` file to [rubygems.org](https://rubygems.org).
41
74
 
42
75
  ## Contributing
43
76
 
44
- Bug reports and pull requests are welcome on GitHub at
77
+ Bug reports and pull requests are welcome on GitLab at
45
78
  https://gitlab.com/fjc/circule.
46
79
 
47
80
  ## License
data/circule-demo.mp4 ADDED
Binary file
data/circule.gemspec CHANGED
@@ -8,20 +8,20 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Frank J. Cameron']
9
9
  spec.email = ['fjc@fastmail.net']
10
10
 
11
- spec.summary = ''
11
+ spec.summary = 'Generate an icon of overlapping circles derived from a hash.'
12
12
  spec.homepage = 'https://gitlab.com/fjc/circule'
13
13
  spec.license = 'MIT'
14
- spec.required_ruby_version = '>= 2.4.0'
14
+ spec.required_ruby_version = '>= 2.7.0'
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) {
21
21
  `git ls-files -z`.split("\x0").reject do |f|
22
22
  (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
23
23
  end
24
- end
24
+ }
25
25
 
26
26
  spec.bindir = 'exe'
27
27
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
data/exe/circule CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'circule'
4
5
  require 'optparse'
5
6
 
6
7
  options = {}
7
8
  OptionParser.new do |opts|
8
- opts.banner = ''
9
+ opts.banner = 'Generate an icon of overlapping circles derived from a hash.'
9
10
 
10
11
  opts.on('-h HEXSTRING', '--hex', 'Use this hash') do |h|
11
12
  options[:hex] = h
@@ -71,7 +72,7 @@ if options[:gui]
71
72
  gui.canvas = options[:canvas] if options[:canvas]
72
73
  gui.ox = options[:ox] if options[:ox]
73
74
  gui.oy = options[:oy] if options[:oy]
74
- gui.zoom = options[:zoom] if options[:zoom]
75
+ gui.scale = options[:zoom] if options[:zoom]
75
76
 
76
77
  gui.open options[:file] if options[:file]
77
78
 
@@ -83,6 +84,7 @@ if options[:gui]
83
84
 
84
85
  if options[:interactive]
85
86
  require 'pry'
87
+ require 'trace_eval' rescue nil
86
88
  Thread.new do gui.pry ensure `reset` end
87
89
  end
88
90
 
@@ -92,7 +94,7 @@ else
92
94
  when nil
93
95
  when '-'
94
96
  require 'digest'
95
- options[:hex] = Digest::SHA256.hexdigest STDIN.read
97
+ options[:hex] = Digest::SHA256.hexdigest $stdin.read
96
98
  else
97
99
  require 'digest'
98
100
  options[:hex] = Digest::SHA256.hexdigest File.read(options[:file])
@@ -113,7 +115,7 @@ else
113
115
  case options[:save]
114
116
  when nil
115
117
  when '-'
116
- circule.image.write STDOUT
118
+ circule.image.write $stdout
117
119
  else
118
120
  circule.image.save options[:save]
119
121
  end
data/lib/circule/gui.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../circule'
2
4
 
3
5
  require 'digest'
@@ -10,6 +12,7 @@ rescue LoadError
10
12
  warn "Could not find gem 'glimmer-dsl-tk' in locally installed gems."
11
13
  end
12
14
 
15
+ # Glimmer Tk GUI for Circule
13
16
  class Circule::GUI
14
17
  include Glimmer
15
18
 
@@ -57,7 +60,8 @@ class Circule::GUI
57
60
 
58
61
  width = image.width * @scale.to_i
59
62
  height = image.height * @scale.to_i
60
- data = image.resize(width, height).save(tfile.path)
63
+
64
+ image.resize(width, height).save(tfile.path)
61
65
 
62
66
  @image_label.image = tfile.path
63
67
  end
@@ -66,31 +70,33 @@ class Circule::GUI
66
70
  @root ||= root {
67
71
  title 'Circule GUI'
68
72
 
69
- frame {
70
- entry { text <=> [self, :hex] }
71
-
72
- label { text 'bit0:' }
73
- spinbox { from 0; to 255; text <=> [self, :bit0] }
74
- label { text 'step:' }
75
- spinbox { from 4; to 64; text <=> [self, :step] }
76
- label { text 'bitn:' }
77
- spinbox { from 0; to 255; text <=> [self, :bitn] }
78
- label { text 'canvas:' }
79
- spinbox { from 24; to 96; text <=> [self, :canvas] }
80
- label { text 'ox:' }
81
- spinbox { from -96; to 96; text <=> [self, :ox] }
82
- label { text 'oy:' }
83
- spinbox { from -96; to 96; text <=> [self, :oy] }
84
- label { text 'scale:' }
85
- spinbox { from 1; to 24; text <=> [self, :scale] }
73
+ scrollbar_frame {
74
+ xscrollbar false
75
+
76
+ entry { text <=> [self, :hex] ; grid row: 1, column: 1, column_span: 2, column_weight: 1 }
77
+
78
+ label { text 'bit0:' ; grid row: 2, column: 1, column_span: 1, column_weight: 0 }
79
+ spinbox { from 0; to 255; text <=> [self, :bit0] ; grid row: 2, column: 2, column_span: 1, column_weight: 1 }
80
+ label { text 'step:' ; grid row: 3, column: 1, column_span: 1, column_weight: 0 }
81
+ spinbox { from 4; to 64; text <=> [self, :step] ; grid row: 3, column: 2, column_span: 1, column_weight: 1 }
82
+ label { text 'bitn:' ; grid row: 4, column: 1, column_span: 1, column_weight: 0 }
83
+ spinbox { from 0; to 255; text <=> [self, :bitn] ; grid row: 4, column: 2, column_span: 1, column_weight: 1 }
84
+ label { text 'canvas:' ; grid row: 5, column: 1, column_span: 1, column_weight: 0 }
85
+ spinbox { from 24; to 96; text <=> [self, :canvas] ; grid row: 5, column: 2, column_span: 1, column_weight: 1 }
86
+ label { text 'ox:' ; grid row: 6, column: 1, column_span: 1, column_weight: 0 }
87
+ spinbox { from -96; to 96; text <=> [self, :ox] ; grid row: 6, column: 2, column_span: 1, column_weight: 1 }
88
+ label { text 'oy:' ; grid row: 7, column: 1, column_span: 1, column_weight: 0 }
89
+ spinbox { from -96; to 96; text <=> [self, :oy] ; grid row: 7, column: 2, column_span: 1, column_weight: 1 }
90
+ label { text 'scale:' ; grid row: 8, column: 1, column_span: 1, column_weight: 0 }
91
+ spinbox { from 1; to 24; text <=> [self, :scale] ; grid row: 8, column: 2, column_span: 1, column_weight: 1 }
86
92
 
87
93
  frame {
88
- @image_label = label { anchor 'center' }
94
+ @image_label = label { anchor 'center' } ; grid row: 9, column: 1, column_span: 2, column_weight: 1
89
95
  }
90
96
 
91
- button { text 'Open'; command { open } }
92
- button { text 'Save'; command { save } }
93
- button { text 'Exit'; command { exit(0) } }
97
+ button { text 'Open'; command { open } ; grid row: 10, column: 1, column_span: 2, column_weight: 1 }
98
+ button { text 'Save'; command { save } ; grid row: 11, column: 1, column_span: 2, column_weight: 1 }
99
+ button { text 'Exit'; command { exit(0) } ; grid row: 12, column: 1, column_span: 2, column_weight: 1 }
94
100
  }
95
101
  }
96
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Circule
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.4'
5
5
  end
data/lib/circule.rb CHANGED
@@ -7,6 +7,7 @@ require 'net/http'
7
7
  require 'chunky_png'
8
8
  require 'securerandom'
9
9
 
10
+ # Convert a hash to an icon.
10
11
  class Circule
11
12
  class Error < StandardError; end
12
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank J. Cameron
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-30 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description:
27
+ description:
28
28
  email:
29
29
  - fjc@fastmail.net
30
30
  executables:
@@ -41,6 +41,7 @@ files:
41
41
  - Rakefile
42
42
  - bin/console
43
43
  - bin/setup
44
+ - circule-demo.mp4
44
45
  - circule.gemspec
45
46
  - exe/circule
46
47
  - lib/circule.rb
@@ -51,7 +52,7 @@ licenses:
51
52
  - MIT
52
53
  metadata:
53
54
  homepage_uri: https://gitlab.com/fjc/circule
54
- post_install_message:
55
+ post_install_message:
55
56
  rdoc_options: []
56
57
  require_paths:
57
58
  - lib
@@ -59,15 +60,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
60
  requirements:
60
61
  - - ">="
61
62
  - !ruby/object:Gem::Version
62
- version: 2.4.0
63
+ version: 2.7.0
63
64
  required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - ">="
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
68
69
  requirements: []
69
- rubygems_version: 3.1.6
70
- signing_key:
70
+ rubygems_version: 3.2.5
71
+ signing_key:
71
72
  specification_version: 4
72
- summary: ''
73
+ summary: Generate an icon of overlapping circles derived from a hash.
73
74
  test_files: []